From 8e7148706e1029bebd361c8f7d5019086762891a Mon Sep 17 00:00:00 2001 From: Alone Date: Wed, 25 Sep 2024 18:52:26 +0800 Subject: [PATCH] v1 --- custom_components/xiaomi_miot/__init__.py | 2 +- custom_components/xiaomi_miot/core/device.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/custom_components/xiaomi_miot/__init__.py b/custom_components/xiaomi_miot/__init__.py index 21eeb65ff..257edd35d 100644 --- a/custom_components/xiaomi_miot/__init__.py +++ b/custom_components/xiaomi_miot/__init__.py @@ -1256,7 +1256,7 @@ async def async_update(self): async def async_update_for_main_entity(self): if self._miot_service: for d in [ - 'fan', 'cover', 'scanner', 'number_select', + 'fan', 'cover', 'scanner', ]: pls = self.custom_config_list(f'{d}_properties') or [] if pls: diff --git a/custom_components/xiaomi_miot/core/device.py b/custom_components/xiaomi_miot/core/device.py index d3dfd7511..da8b326eb 100644 --- a/custom_components/xiaomi_miot/core/device.py +++ b/custom_components/xiaomi_miot/core/device.py @@ -256,13 +256,17 @@ def init_converters(self): self.dispatch_info() for d in [ - 'sensor', 'binary_sensor', 'switch', 'number', 'select', 'button', - # 'fan', 'cover', 'scanner', 'number_select', + 'sensor', 'binary_sensor', 'switch', 'number', 'select', 'button', 'number_select', + # 'fan', 'cover', 'scanner', ]: pls = self.custom_config_list(f'{d}_properties') or [] if not pls: continue for prop in self.spec.get_properties(*pls): + if d == 'number_select' and (prop.value_range or prop.value_list): + d = 'number' if prop.value_range else 'select' + else: + continue if d == 'button': if prop.value_list: for pv in prop.value_list: @@ -292,8 +296,9 @@ async def init_coordinators(self, _): if self.miot_entity: return + interval = self.custom_config_integer('interval_seconds') or 30 lst = [ - DataCoordinator(self, name='update_miot_status', update_interval=timedelta(seconds=30)), + DataCoordinator(self, name='update_miot_status', update_interval=timedelta(seconds=interval)), ] for coo in lst: await coo.async_config_entry_first_refresh()