Răsfoiți Sursa

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 9 luni în urmă
părinte
comite
9cc07cab3e
1 a modificat fișierele cu 2 adăugiri și 0 ștergeri
  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()