fix temperature/humidity sensors valid values (#10024)

pull/9796/merge
Maciej Bieniek 2017-10-22 11:59:24 +02:00 committed by Daniel Høyer Iversen
parent 80053ef21b
commit 62caea6bfb
1 changed files with 4 additions and 4 deletions

View File

@ -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