Skip to content

Commit

Permalink
fix temperature for climate
Browse files Browse the repository at this point in the history
  • Loading branch information
al-one committed Nov 6, 2024
1 parent 86b4736 commit 8ba4897
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
22 changes: 5 additions & 17 deletions custom_components/xiaomi_miot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions custom_components/xiaomi_miot/core/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', [])
Expand Down

0 comments on commit 8ba4897

Please sign in to comment.