Explorar el Código

device communication: ignore HA poll requests once started

We keep our own receive loop to handle push from devices. But when devices
are set to poll only, the receive loop also handles the polling. Handling
the poll requests from HA in this can cause simultaneous requests to be
sent to the device, which many devices cannot handle.

Instead of ignoring the HA requests when a persistent connection is being
used, ignore them when the receive loop is running.

Issue #653, #1804
Jason Rumney hace 1 año
padre
commit
46e4428761
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  1. 1 1
      custom_components/tuya_local/device.py

+ 1 - 1
custom_components/tuya_local/device.py

@@ -441,7 +441,7 @@ class TuyaLocalDevice(object):
 
 
     async def async_refresh(self):
     async def async_refresh(self):
         _LOGGER.debug("Refreshing device state for %s", self.name)
         _LOGGER.debug("Refreshing device state for %s", self.name)
-        if self.should_poll:
+        if not self._running:
             await self._retry_on_failed_connection(
             await self._retry_on_failed_connection(
                 lambda: self._refresh_cached_state(),
                 lambda: self._refresh_cached_state(),
                 f"Failed to refresh device state for {self.name}.",
                 f"Failed to refresh device state for {self.name}.",