Browse Source

fix (device): ignore null return values in heartbeatless polls.

Or even if there was a heartbeat, but not a full poll request.

We listen on the socket in case the device sends something, but the
default timeout is 100ms so we can check for outgoing messages and
send them in a timely fashion. If nothing comes during that period,
it is not an error.

Possible fix for issue #4845
Jason Rumney 1 month ago
parent
commit
16b0b37754
1 changed files with 4 additions and 1 deletions
  1. 4 1
      custom_components/tuya_local/device.py

+ 4 - 1
custom_components/tuya_local/device.py

@@ -365,10 +365,13 @@ class TuyaLocalDevice(object):
                             True,
                         )
                         last_heartbeat = now
-
                     poll = await self._hass.async_add_executor_job(
                         self._api.receive,
                     )
+                    # Ignore Payload error 904, as 3.4 protocol devices seem to return
+                    # this when there is no new data, instead of just returning nothing.
+                    if "Err" in poll and poll["Err"] == 904:
+                        poll = None
                 else:
                     force_backoff = True
                     poll = None