Sfoglia il codice sorgente

Device comms: ensure errors get counted.

Errors were counted in retry_on_failed_connection, but error handling
in receive_loop is reporting warnings when error count is 0 (debug otherwise),
so obviously they have not been counted yet in that case. Make sure they do
get counted if detected at that level, but check against the previous error
count to ensure that they are not counted twice.

May prevent the frequent warnings reported in issue #3083 when devices are
offline long term.
Jason Rumney 11 mesi fa
parent
commit
cece01d690
1 ha cambiato i file con 5 aggiunte e 1 eliminazioni
  1. 5 1
      custom_components/tuya_local/device.py

+ 5 - 1
custom_components/tuya_local/device.py

@@ -287,6 +287,7 @@ class TuyaLocalDevice(object):
             self._api.parent.set_socketPersistent(persist)
             self._api.parent.set_socketPersistent(persist)
 
 
         while self._running:
         while self._running:
+            error_count = self._api_working_protocol_failures
             try:
             try:
                 last_cache = self._cached_state.get("updated_at", 0)
                 last_cache = self._cached_state.get("updated_at", 0)
                 now = time()
                 now = time()
@@ -336,7 +337,10 @@ class TuyaLocalDevice(object):
 
 
                 if poll:
                 if poll:
                     if "Error" in poll:
                     if "Error" in poll:
-                        if self._api_working_protocol_failures == 0:
+                        # increment the error count if not done already
+                        if error_count == self._api_working_protocol_failures:
+                            self._api_working_protocol_failures += 1
+                        if self._api_working_protocol_failures == 1:
                             _LOGGER.warning(
                             _LOGGER.warning(
                                 "%s error reading: %s", self.name, poll["Error"]
                                 "%s error reading: %s", self.name, poll["Error"]
                             )
                             )