Kaynağa Gözat

climate precision: only return tenths or whole.

Although the API is documented as accepting arbitrary precision,
hundredths does not seem to be working, so stick with the ones that
home-assistant defined constants for.
For non-scientific apparatus, tenths of degrees should be plenty.

Issue #587
Jason Rumney 2 yıl önce
ebeveyn
işleme
419987d706
1 değiştirilmiş dosya ile 5 ekleme ve 1 silme
  1. 5 1
      custom_components/tuya_local/climate.py

+ 5 - 1
custom_components/tuya_local/climate.py

@@ -26,6 +26,8 @@ from homeassistant.components.climate.const import (
 )
 from homeassistant.const import (
     ATTR_TEMPERATURE,
+    PRECISION_TENTHS,
+    PRECISION_WHOLE,
     UnitOfTemperature,
 )
 import logging
@@ -144,7 +146,9 @@ class TuyaLocalClimate(TuyaLocalEntity, ClimateEntity):
             if self._current_temperature_dps
             else 1
         )
-        return 1.0 / max(temp, current)
+        if max(temp, current) > 1.0:
+            return PRECISION_TENTHS
+        return PRECISION_WHOLE
 
     @property
     def target_temperature(self):