瀏覽代碼

Add ability for climate device to specify min and max temperature.

Some devices feedback the minimum and maximum temperature range for the mode
they are in on dps.  Pass this through to the UI so the correct range is
displayed even if the logic is too complex to model in the config.
Service call failure will still depend on the range specified in the
temperature dps, but at least the UI won't have to allow setting outside the
range to avoid over-restricting.
Jason Rumney 4 年之前
父節點
當前提交
ed46475116
共有 1 個文件被更改,包括 10 次插入0 次删除
  1. 10 0
      custom_components/tuya_local/generic/climate.py

+ 10 - 0
custom_components/tuya_local/generic/climate.py

@@ -69,6 +69,8 @@ class TuyaLocalClimate(TuyaLocalEntity, ClimateEntity):
         self._temp_high_dps = dps_map.pop(ATTR_TARGET_TEMP_HIGH, None)
         self._temp_high_dps = dps_map.pop(ATTR_TARGET_TEMP_HIGH, None)
         self._temp_low_dps = dps_map.pop(ATTR_TARGET_TEMP_LOW, None)
         self._temp_low_dps = dps_map.pop(ATTR_TARGET_TEMP_LOW, None)
         self._unit_dps = dps_map.pop("temperature_unit", None)
         self._unit_dps = dps_map.pop("temperature_unit", None)
+        self._mintemp_dps = dps_map.pop("min_temperature", None)
+        self._maxtemp_dps = dps_map.pop("max_temperature", None)
 
 
         self._init_end(dps_map)
         self._init_end(dps_map)
         self._support_flags = 0
         self._support_flags = 0
@@ -156,6 +158,10 @@ class TuyaLocalClimate(TuyaLocalEntity, ClimateEntity):
     @property
     @property
     def min_temp(self):
     def min_temp(self):
         """Return the minimum supported target temperature."""
         """Return the minimum supported target temperature."""
+        # if a separate min_temperature dps is specified, the device tells us.
+        if self._mintemp_dps is not None:
+            return self._mintemp_dps.get_value(self._device)
+
         if self._temperature_dps is None:
         if self._temperature_dps is None:
             if self._temp_low_dps is None:
             if self._temp_low_dps is None:
                 return None
                 return None
@@ -167,6 +173,10 @@ class TuyaLocalClimate(TuyaLocalEntity, ClimateEntity):
     @property
     @property
     def max_temp(self):
     def max_temp(self):
         """Return the maximum supported target temperature."""
         """Return the maximum supported target temperature."""
+        # if a separate max_temperature dps is specified, the device tells us.
+        if self._maxtemp_dps is not None:
+            return self._maxtemp_dps.get_value(self._device)
+
         if self._temperature_dps is None:
         if self._temperature_dps is None:
             if self._temp_high_dps is None:
             if self._temp_high_dps is None:
                 return None
                 return None