fix temperature/humidity sensors valid values (#10024)
parent
80053ef21b
commit
62caea6bfb
|
@ -67,6 +67,10 @@ class XiaomiSensor(XiaomiDevice):
|
|||
if value is None:
|
||||
return False
|
||||
value = float(value)
|
||||
if self._data_key in ['temperature', 'humidity', 'pressure']:
|
||||
value /= 100
|
||||
elif self._data_key in ['illumination']:
|
||||
value = max(value - 300, 0)
|
||||
if self._data_key == 'temperature' and (value < -20 or value > 60):
|
||||
return False
|
||||
elif self._data_key == 'humidity' and (value <= 0 or value > 100):
|
||||
|
@ -75,9 +79,5 @@ class XiaomiSensor(XiaomiDevice):
|
|||
return False
|
||||
elif self._data_key == 'pressure' and value == 0:
|
||||
return False
|
||||
if self._data_key in ['temperature', 'humidity', 'pressure']:
|
||||
value /= 100
|
||||
elif self._data_key in ['illumination']:
|
||||
value = max(value - 300, 0)
|
||||
self._state = round(value, 2)
|
||||
return True
|
||||
|
|
Loading…
Reference in New Issue