Explorar o 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 hai 9 meses
pai
achega
9cc07cab3e
Modificáronse 1 ficheiros con 2 adicións e 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()