Skip to content

Commit

Permalink
❌ improve for disable device (#2209)
Browse files Browse the repository at this point in the history
  • Loading branch information
al-one committed Dec 27, 2024
1 parent c7d8e9b commit fdb0c3f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion custom_components/xiaomi_miot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ async def updated(event: hass_core.Event):
if device.disabled and miot_device.coordinators:
await miot_device.async_unload()
if not device.disabled and not miot_device.coordinators:
miot_device.init_converters()
await miot_device.init_coordinators()
hass.bus.async_listen(dr.EVENT_DEVICE_REGISTRY_UPDATED, updated)


Expand Down
7 changes: 4 additions & 3 deletions custom_components/xiaomi_miot/core/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,6 @@ def init_converters(self):

if not self.spec:
return
if dby := self.hass_device_disabled:
self.log.debug('Device disabled by: %s', dby)
return

for cfg in GLOBAL_CONVERTERS:
cls = cfg.get('class')
Expand Down Expand Up @@ -453,6 +450,10 @@ def init_converters(self):
self.add_converter(AttrConv(attr, d))

async def init_coordinators(self):
if dby := self.hass_device_disabled:
self.log.debug('Device disabled by: %s', dby)
return

interval = 30
interval = self.entry.get_config('scan_interval') or interval
interval = self.custom_config_integer('interval_seconds') or interval
Expand Down

0 comments on commit fdb0c3f

Please sign in to comment.