diff --git a/custom_components/mega/binary_sensor.py b/custom_components/mega/binary_sensor.py index e335594..a616f94 100644 --- a/custom_components/mega/binary_sensor.py +++ b/custom_components/mega/binary_sensor.py @@ -70,7 +70,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn async_add_devices(devices) - hass.async_create_task(scan()) + asyncio.create_task(scan()) + class MegaBinarySensor(BinarySensorEntity, BaseMegaEntity): diff --git a/custom_components/mega/hub.py b/custom_components/mega/hub.py index 34832d9..bfaafaf 100644 --- a/custom_components/mega/hub.py +++ b/custom_components/mega/hub.py @@ -268,8 +268,7 @@ class MegaD: return pty, m async def scan_ports(self,): - async with self.lck: - for x in range(38): - ret = await self.scan_port(x) - if ret: - yield [x, *ret] + for x in range(38): + ret = await self.scan_port(x) + if ret: + yield [x, *ret] diff --git a/custom_components/mega/light.py b/custom_components/mega/light.py index c322239..38367cb 100644 --- a/custom_components/mega/light.py +++ b/custom_components/mega/light.py @@ -85,7 +85,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn devices.append(light) async_add_devices(devices) - hass.async_create_task(scan_ports()) + asyncio.create_task(scan_ports()) class MegaLight(LightEntity, BaseMegaEntity): diff --git a/custom_components/mega/sensor.py b/custom_components/mega/sensor.py index c9068a5..fcd8ca1 100644 --- a/custom_components/mega/sensor.py +++ b/custom_components/mega/sensor.py @@ -112,7 +112,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn async_add_devices(devices) - hass.async_create_task(scan()) + asyncio.create_task(scan()) class Mega1WSensor(BaseMegaEntity):