Skip to content

Commit

Permalink
Call disconnect() only once for offlined sub-device (#344)
Browse files Browse the repository at this point in the history
* Call disconnect() only once

* Typo error in a comment
  • Loading branch information
Lurker00 authored Sep 3, 2024
1 parent 8394bb5 commit 882623e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion custom_components/localtuya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,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 disabled 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 Down
2 changes: 1 addition & 1 deletion custom_components/localtuya/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ def subdevice_state(self, state: SubdeviceState):
off_count += 1
if off_count == 1:
self.warning(f"Sub-device is offline {node_id}")
elif off_count >= MIN_OFFLINE_EVENTS:
elif off_count == MIN_OFFLINE_EVENTS:
self.disconnected("Device is offline")

def _remove_from_gateway(self):
Expand Down

0 comments on commit 882623e

Please sign in to comment.