소스 검색

feat(number): allow max and min dps to be optional

Fall back on using the range of the value dp when maximum and minimum
are configured, but not reported by the device.

For implementation of idea in discussion #3373
Jason Rumney 1 년 전
부모
커밋
36cda0a3b1
1개의 변경된 파일과 6개의 추가작업 그리고 2개의 파일을 삭제
  1. 6 2
      custom_components/tuya_local/number.py

+ 6 - 2
custom_components/tuya_local/number.py

@@ -70,14 +70,18 @@ class TuyaLocalNumber(TuyaLocalEntity, NumberEntity):
     @property
     def native_min_value(self):
         if self._min_dps is not None:
-            return self._min_dps.get_value(self._device)
+            minimum = self._min_dps.get_value(self._device)
+            if minimum is not None:
+                return minimum
         r = self._value_dps.range(self._device)
         return DEFAULT_MIN_VALUE if r is None else r[0]
 
     @property
     def native_max_value(self):
         if self._max_dps is not None:
-            return self._max_dps.get_value(self._device)
+            maximum = self._max_dps.get_value(self._device)
+            if maximum is not None:
+                return maximum
         r = self._value_dps.range(self._device)
         return DEFAULT_MAX_VALUE if r is None else r[1]