diff --git a/custom_components/xiaomi_miio_raw/manifest.json b/custom_components/xiaomi_miio_raw/manifest.json index 693d400..0006a33 100644 --- a/custom_components/xiaomi_miio_raw/manifest.json +++ b/custom_components/xiaomi_miio_raw/manifest.json @@ -1,17 +1,17 @@ { "domain": "xiaomi_miio_raw", "name": "Custom component for Home Assistant to faciliate the reverse engeneering of Xiaomi MiIO devices", - "version": "2022.12.0.0", - "iot_class": "local_polling", + "codeowners": [ + "@syssi" + ], "config_flow": false, + "dependencies": [], "documentation": "https://github.com/syssi/xiaomi_raw", + "iot_class": "local_polling", "issue_tracker": "https://github.com/syssi/xiaomi_raw/issues", "requirements": [ "construct==2.10.56", "python-miio>=0.5.12" ], - "dependencies": [], - "codeowners": [ - "@syssi" - ] + "version": "2023.6.0.0" } diff --git a/custom_components/xiaomi_miio_raw/sensor.py b/custom_components/xiaomi_miio_raw/sensor.py index 2825acd..2df1d2a 100644 --- a/custom_components/xiaomi_miio_raw/sensor.py +++ b/custom_components/xiaomi_miio_raw/sensor.py @@ -81,8 +81,7 @@ # pylint: disable=unused-argument -@asyncio.coroutine -def async_setup_platform(hass, config, async_add_devices, discovery_info=None): +async def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up the sensor from config.""" if DATA_KEY not in hass.data: hass.data[DATA_KEY] = {} @@ -110,8 +109,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): hass.data[DATA_KEY][host] = device async_add_devices([device], update_before_add=True) - @asyncio.coroutine - def async_service_handler(service): + async def async_service_handler(service): """Map services to methods on XiaomiMiioDevice.""" method = SERVICE_TO_METHOD.get(service.service) params = { @@ -129,11 +127,13 @@ def async_service_handler(service): update_tasks = [] for device in devices: - yield from getattr(device, method["method"])(**params) - update_tasks.append(device.async_update_ha_state(True)) + if not hasattr(device, method["method"]): + continue + await getattr(device, method["method"])(**params) + update_tasks.append(asyncio.create_task(device.async_update_ha_state(True))) if update_tasks: - yield from asyncio.wait(update_tasks) + await asyncio.wait(update_tasks) for service in SERVICE_TO_METHOD: schema = SERVICE_TO_METHOD[service].get("schema", SERVICE_SCHEMA)