Skip to content

Commit

Permalink
Adjust add_dps_to_request for 3.2 devices attempt to fix #262
Browse files Browse the repository at this point in the history
  • Loading branch information
xZetsubou committed Jun 4, 2024
1 parent 23bed62 commit 82b73aa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions custom_components/localtuya/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def __init__(
self.set_logger(_LOGGER, dev.id, dev.enable_debug, dev.name)

# This has to be done in case the device type is type_0d
for entity in self._device_config.entities:
self.dps_to_request[entity[CONF_ID]] = None
for dp in self._device_config.dps_strings:
self.dps_to_request[dp.split(" ")[0]] = None

def add_entities(self, entities):
"""Set the entities associated with this device."""
Expand Down Expand Up @@ -475,7 +475,10 @@ def disconnected(self):
# If it disconnects unexpectedly.
if not self._is_closing and not self.is_subdevice and not self._quick_retry:
self._quick_retry = True
asyncio.run_coroutine_threadsafe(self.async_connect(), self._hass.loop)
self._unsub_on_close.append(
async_call_later(self._hass, 1, self.async_connect)
)
# asyncio.run_coroutine_threadsafe(self.async_connect(), self._hass.loop)

if not self._is_closing:
delay = (0 if self.is_subdevice else 3) + sleep_time
Expand Down

0 comments on commit 82b73aa

Please sign in to comment.