Просмотр исходного кода

Water heater: handle missing current_temperature dp in precision

When calculating precision, we consider both temperature and
current_temperature dps. But if the latter is not present, our
calculation needs to avoid exceptions that will cause initialisation
of the entity to fail.

Issue #1542
Jason Rumney 2 лет назад
Родитель
Сommit
37d9d1d130
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      custom_components/tuya_local/water_heater.py

+ 1 - 1
custom_components/tuya_local/water_heater.py

@@ -104,7 +104,7 @@ class TuyaLocalWaterHeater(TuyaLocalEntity, WaterHeaterEntity):
         # represented, not a number of decimal places.
         return 1.0 / max(
             self._temperature_dps.scale(self._device),
-            self._current_temperature_dps.scale(self._device),
+            self._current_temperature_dps.scale(self._device) if self_current_tempereature_dps else 1.0,
         )
 
     @property