From 8ba4897decfbbd7ad0e170154758017b33fb3e85 Mon Sep 17 00:00:00 2001 From: Alone Date: Wed, 6 Nov 2024 18:45:24 +0800 Subject: [PATCH] fix temperature for climate --- custom_components/xiaomi_miot/__init__.py | 22 +++++--------------- custom_components/xiaomi_miot/core/device.py | 3 +++ 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/custom_components/xiaomi_miot/__init__.py b/custom_components/xiaomi_miot/__init__.py index d1b1b7a77..42034cb25 100644 --- a/custom_components/xiaomi_miot/__init__.py +++ b/custom_components/xiaomi_miot/__init__.py @@ -1109,12 +1109,6 @@ async def async_update(self): await asyncio.sleep(self._vars.get('delay_update')) self._vars.pop('delay_update', 0) attrs = {} - - if pls := self.custom_config_list('miio_properties'): - self._vars['miio_properties'] = pls - if self._miio2miot: - self._miio2miot.extend_miio_props(pls) - result = await self.device.update_miot_status( use_local=self.custom_config_bool('miot_local'), use_cloud=self.custom_config_bool('miot_cloud'), @@ -1140,19 +1134,13 @@ async def async_update(self): ) return False - attrs.update(result.to_attributes(self._state_attrs, self._miot_mapping)) - if self._miio2miot: - attrs.update(self._miio2miot.entity_attrs()) - attrs['state_updater'] = result.updater - self._state = True if self._state_attrs.get('power') else False - - await self.async_update_attrs(attrs, update_subs=True) if self.is_main_entity: + attrs.update(self.device.props) + attrs['state_updater'] = result.updater await self.async_update_for_main_entity() - if self._subs: - await self.async_update_attrs({ - 'sub_entities': list(self._subs.keys()), - }, update_subs=False) + else: + attrs.update(result.to_attributes(self._state_attrs, self._miot_mapping)) + await self.async_update_attrs(attrs, update_subs=True) self.logger.debug('%s: Got new state: %s', self.name_model, attrs) async def async_update_for_main_entity(self): diff --git a/custom_components/xiaomi_miot/core/device.py b/custom_components/xiaomi_miot/core/device.py index 03330e9c4..ce05985f3 100644 --- a/custom_components/xiaomi_miot/core/device.py +++ b/custom_components/xiaomi_miot/core/device.py @@ -177,6 +177,9 @@ async def async_init(self): spec = await self.get_spec() if spec and self.local and not self.cloud_only: self.miio2miot = Miio2MiotHelper.from_model(self.hass, self.model, spec) + mps = self.custom_config_list('miio_properties') + if mps and self.miio2miot: + self.miio2miot.extend_miio_props(mps) self._exclude_miot_services = self.custom_config_list('exclude_miot_services', []) self._exclude_miot_properties = self.custom_config_list('exclude_miot_properties', [])