Pārlūkot izejas kodu

unixtime: move handling to _map_from_dps.

decoded_value is used only when there is a mask set, so is not effective.
Jason Rumney 2 gadi atpakaļ
vecāks
revīzija
ef39903d46

+ 7 - 6
custom_components/tuya_local/helpers/device_config.py

@@ -432,12 +432,6 @@ class TuyaDpsConfig:
                     self.name,
                 )
                 return None
-        elif self.rawtype == "unixtime" and isinstance(v, int):
-            try:
-                return datetime.fromtimestamp(v)
-            except:
-                _LOGGER.warning("Invalid timestamp %d", v)
-                return None
         else:
             return v
 
@@ -696,6 +690,13 @@ class TuyaDpsConfig:
                 result = result / scale
                 replaced = True
 
+            if self.rawtype == "unixtime" and isinstance(result, int):
+                try:
+                    result = datetime.fromtimestamp(result)
+                    replaced = true
+                except:
+                    _LOGGER.warning("Invalid timestamp %d", result)
+
             if replaced:
                 _LOGGER.debug(
                     "%s: Mapped dps %s value from %s to %s",