Skip to content

Commit

Permalink
AirPurifier MIoT: round temperature to one decimal point to return te…
Browse files Browse the repository at this point in the history
…mperature "20.8 °C" instead of "20.799999 °C" (#753)
  • Loading branch information
petrkotek committed Jul 6, 2020
1 parent 0155ebc commit a25ecd3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion miio/airpurifier_miot.py
Expand Up @@ -100,7 +100,7 @@ def humidity(self) -> int:
def temperature(self) -> Optional[float]:
"""Current temperature, if available."""
if self.data["temperature"] is not None:
return self.data["temperature"]
return round(self.data["temperature"], 1)

return None

Expand Down
4 changes: 2 additions & 2 deletions miio/tests/test_airpurifier_miot.py
Expand Up @@ -13,7 +13,7 @@
"aqi": 10,
"average_aqi": 8,
"humidity": 62,
"temperature": 18.6,
"temperature": 18.599999,
"fan_level": 2,
"mode": 0,
"led": True,
Expand Down Expand Up @@ -84,7 +84,7 @@ def test_status(self):
assert status.aqi == _INITIAL_STATE["aqi"]
assert status.average_aqi == _INITIAL_STATE["average_aqi"]
assert status.humidity == _INITIAL_STATE["humidity"]
assert status.temperature == _INITIAL_STATE["temperature"]
assert status.temperature == 18.6
assert status.fan_level == _INITIAL_STATE["fan_level"]
assert status.mode == OperationMode(_INITIAL_STATE["mode"])
assert status.led == _INITIAL_STATE["led"]
Expand Down

0 comments on commit a25ecd3

Please sign in to comment.