Sfoglia il codice sorgente

fix(device): once data is received, don't let comms get interrupted

If an entity throws an exception due to unexpected data condition, just log
it, don't propagate the exception beyond the receive loop.

This should avoid causing communication interruptions and reconnects that
cause some devices (especially protocol 3.4 ones) to eventually stop
responding on the local connection until power reset.

Issue #4949, #4965, #5056
Jason Rumney 1 giorno fa
parent
commit
50382f7926
1 ha cambiato i file con 11 aggiunte e 1 eliminazioni
  1. 11 1
      custom_components/tuya_local/device.py

+ 11 - 1
custom_components/tuya_local/device.py

@@ -270,7 +270,17 @@ class TuyaLocalDevice(object):
 
                     for entity in self._children:
                         # let entities trigger off poll contents directly
-                        entity.on_receive(poll, full_poll)
+                        try:
+                            entity.on_receive(poll, full_poll)
+                        except Exception as e:
+                            # Don't let exceptions thrown by the entities interrupt the communication loop
+                            # Just log them and move on.
+                            _LOGGER.exception(
+                                "%s on_receive error for entity %s: %s",
+                                self.name,
+                                entity.entity_id,
+                                e,
+                            )
                         # clear non-persistant dps that were not in a full poll
                         if full_poll:
                             for dp in entity._config.dps():