Explorar el Código

fix(time): return None if all time components are None

Some devices do not return data for an unset timer, so we need to handle
the None case since timedelta does not handle it.

Discussion #3565
Jason Rumney hace 9 meses
padre
commit
9cc07cab3e
Se han modificado 1 ficheros con 2 adiciones y 0 borrados
  1. 2 0
      custom_components/tuya_local/time.py

+ 2 - 0
custom_components/tuya_local/time.py

@@ -65,6 +65,8 @@ class TuyaLocalTime(TuyaLocalEntity, TimeEntity):
             minutes = self._minute_dps.get_value(self._device)
         if self._second_dps:
             seconds = self._second_dps.get_value(self._device)
+        if hours is None and minutes is None and seconds is None:
+            return None
         delta = timedelta(hours=hours, minutes=minutes, seconds=seconds)
         return (MIDNIGHT + delta).time()