Skip to content

Commit

Permalink
airpurifier_miot: force aqi update prior fetching data (#1282)
Browse files Browse the repository at this point in the history
* airpurifier_miot: force aqi update prior fetching data

* use better name for aqi sensor update duration, bump the duration to five seconds

* Add explanation why we adjust the update duration for mb3
  • Loading branch information
rytilahti committed Jan 8, 2022
1 parent fb3191b commit 0558c63
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions miio/airpurifier_miot.py
Expand Up @@ -51,6 +51,7 @@
# AQI (siid=13)
"purify_volume": {"siid": 13, "piid": 1},
"average_aqi": {"siid": 13, "piid": 2},
"aqi_realtime_update_duration": {"siid": 13, "piid": 9},
# RFID (siid=14)
"filter_rfid_tag": {"siid": 14, "piid": 1},
"filter_rfid_product_id": {"siid": 14, "piid": 3},
Expand Down Expand Up @@ -406,6 +407,11 @@ class AirPurifierMiot(BasicAirPurifierMiot):
)
def status(self) -> AirPurifierMiotStatus:
"""Retrieve properties."""
# Some devices update the aqi information only every 30min.
# This forces the device to poll the sensor for 5 seconds,
# so that we get always the most recent values. See #1281.
if self.model == "zhimi.airpurifier.mb3":
self.set_property("aqi_realtime_update_duration", 5)

return AirPurifierMiotStatus(
{
Expand Down

0 comments on commit 0558c63

Please sign in to comment.