Jelajahi Sumber

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 bulan lalu
induk
melakukan
9cc07cab3e
1 mengubah file dengan 2 tambahan dan 0 penghapusan
  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()