mirror of
https://github.com/andvikt/mega_hacs.git
synced 2025-12-11 09:04:27 +05:00
башфикс сервисов, ускорение загрузки
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""Platform for light integration."""
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
@@ -77,11 +78,15 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
|
||||
mid = config_entry.data[CONF_ID]
|
||||
hub: MegaD = hass.data['mega'][mid]
|
||||
devices = []
|
||||
async for port, pty, m in hub.scan_ports():
|
||||
if pty == "1" and m in ['0', '1']:
|
||||
light = MegaLight(mega_id=mid, port=port, dimmer=m == '1')
|
||||
devices.append(light)
|
||||
async_add_devices(devices)
|
||||
|
||||
async def scan_ports():
|
||||
async for port, pty, m in hub.scan_ports():
|
||||
if pty == "1" and m in ['0', '1']:
|
||||
light = MegaLight(mega_id=mid, port=port, dimmer=m == '1')
|
||||
devices.append(light)
|
||||
async_add_devices(devices)
|
||||
|
||||
asyncio.create_task(scan_ports())
|
||||
|
||||
|
||||
class MegaLight(LightEntity, BaseMegaEntity):
|
||||
|
||||
Reference in New Issue
Block a user