Skip to content

Commit

Permalink
fix: IndexError - change fillter is entry check #410
Browse files Browse the repository at this point in the history
xZetsubou committed Dec 3, 2024
1 parent a7e9ebf commit 8976714
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions custom_components/localtuya/__init__.py
Original file line number Diff line number Diff line change
@@ -461,8 +461,8 @@ def _run_async_listen(hass: HomeAssistant, entry: ConfigEntry):
@callback
def _event_filtter(data: dr.EventDeviceRegistryUpdatedData) -> bool:
device_reg = dr.async_get(hass).async_get(data["device_id"])
is_localtuya = device_reg and DOMAIN in list(device_reg.identifiers)[0]
return bool(data["action"] == "update" and is_localtuya)
is_entry = device_reg and entry.entry_id in device_reg.config_entries
return data["action"] == "update" and is_entry

async def device_state_changed(event: Event[dr.EventDeviceRegistryUpdatedData]):
"""Close connection if device disabled."""
@@ -471,9 +471,6 @@ async def device_state_changed(event: Event[dr.EventDeviceRegistryUpdatedData]):

device_registry = dr.async_get(hass).async_get(event.data["device_id"])

if device_registry.primary_config_entry != entry.entry_id:
return

hass_localtuya: HassLocalTuyaData = hass.data[DOMAIN][entry.entry_id]

dev_id = _device_id_by_identifiers(device_registry.identifiers)

0 comments on commit 8976714

Please sign in to comment.