Skip to content

Commit

Permalink
Fix if device entry doesn't exists #314
Browse files Browse the repository at this point in the history
  • Loading branch information
xZetsubou committed Aug 11, 2024
1 parent 16c8e6c commit 3ffcbc5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions custom_components/localtuya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ async def async_remove_orphan_entities(hass, entry):

@callback
def check_if_device_disabled(hass: HomeAssistant, entry: ConfigEntry, dev_id):
"""Return whether if the device disbaled or not"""
"""Return whether if the device disbaled or not."""
ent_reg = er.async_get(hass)
entries = er.async_entries_for_config_entry(ent_reg, entry.entry_id)
ha_device_id: str = None
Expand All @@ -429,8 +429,8 @@ def check_if_device_disabled(hass: HomeAssistant, entry: ConfigEntry, dev_id):
ha_device_id = entitiy.device_id
break

if ha_device_id:
return dr.async_get(hass).async_get(ha_device_id).disabled
if ha_device_id and (device := dr.async_get(hass).async_get(ha_device_id)):
return device.disabled


@callback
Expand Down

0 comments on commit 3ffcbc5

Please sign in to comment.