Explorar el Código

Log exception from tinytuya Device constructor.

When tinytuya Device constructor throws an exception, Home Assistant logs
a stack trace without any details of the exception itself.
Log the exception details before passing the exception on to HA.

Issue #484
Jason Rumney hace 3 años
padre
commit
fce36083bd
Se han modificado 1 ficheros con 11 adiciones y 1 borrados
  1. 11 1
      custom_components/tuya_local/device.py

+ 11 - 1
custom_components/tuya_local/device.py

@@ -62,7 +62,17 @@ class TuyaLocalDevice(object):
         self._startup_listener = None
         self._api_protocol_version_index = None
         self._api_protocol_working = False
-        self._api = tinytuya.Device(dev_id, address, local_key)
+        try:
+            self._api = tinytuya.Device(dev_id, address, local_key)
+        except Exception as e:
+            _LOGGER.error(
+                "%s: %s while initialising device %s",
+                type(e),
+                e,
+                dev_id,
+            )
+            raise e
+
         # we handle retries at a higher level so we can rotate protocol version
         self._api.set_socketRetryLimit(1)
         self._refresh_task = None