fix temperature/humidity sensors valid values (#10024)
This commit is contained in:
parent
80053ef21b
commit
62caea6bfb
1 changed files with 4 additions and 4 deletions
|
@ -67,6 +67,10 @@ class XiaomiSensor(XiaomiDevice):
|
||||||
if value is None:
|
if value is None:
|
||||||
return False
|
return False
|
||||||
value = float(value)
|
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):
|
if self._data_key == 'temperature' and (value < -20 or value > 60):
|
||||||
return False
|
return False
|
||||||
elif self._data_key == 'humidity' and (value <= 0 or value > 100):
|
elif self._data_key == 'humidity' and (value <= 0 or value > 100):
|
||||||
|
@ -75,9 +79,5 @@ class XiaomiSensor(XiaomiDevice):
|
||||||
return False
|
return False
|
||||||
elif self._data_key == 'pressure' and value == 0:
|
elif self._data_key == 'pressure' and value == 0:
|
||||||
return False
|
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)
|
self._state = round(value, 2)
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Add table
Reference in a new issue