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

Refactor climate precision logic

Logic for temperature scale was too complex, separate into two statements.
Jason Rumney 2 лет назад
Родитель
Сommit
f79c9c532c
1 измененных файлов с 2 добавлено и 7 удалено
  1. 2 7
      custom_components/tuya_local/climate.py

+ 2 - 7
custom_components/tuya_local/climate.py

@@ -134,13 +134,8 @@ class TuyaLocalClimate(TuyaLocalEntity, ClimateEntity):
         """Return the precision of the temperature setting."""
         # unlike sensor, this is a decimal of the smallest unit that can be
         # represented, not a number of decimal places.
-        temp = (
-            self._temperature_dps.scale(self._device)
-            if self._temperature_dps
-            else self._temp_high_dps.scale(self._device)
-            if self._temp_high_dps
-            else 1
-        )
+        dp = self._temperature_dps or self._temp_high_dps
+        temp = dp.scale(self._device) if dp else 1
         current = (
             self._current_temperature_dps.scale(self._device)
             if self._current_temperature_dps