diff --git a/miio/airqualitymonitor.py b/miio/airqualitymonitor.py index 075e9b55d..71cf51d03 100644 --- a/miio/airqualitymonitor.py +++ b/miio/airqualitymonitor.py @@ -28,21 +28,39 @@ def usb_power(self) -> bool: @property def aqi(self) -> int: - """Air quality index value.""" + """Air quality index value. (0...600).""" return self.data["aqi"] @property def battery(self) -> int: - """Current battery level.""" + """Current battery level (0...100).""" return self.data["battery"] + @property + def time_state(self) -> str: + """Current time state.""" + return self.data["time_state"] + + def __repr__(self) -> str: + s = "" % \ + (self.power, + self.aqi, + self.battery, + self.usb, + self.time_state) + return s + class AirQualityMonitor(Device): """Xiaomi PM2.5 Air Quality Monitor.""" def status(self) -> AirQualityMonitorStatus: """Return device status.""" - properties = ['power', 'aqi', 'battery', 'usb_state'] + properties = ['power', 'aqi', 'battery', 'usb_state', 'time_state'] values = self.send( "get_prop", diff --git a/miio/tests/test_airqualitymonitor.py b/miio/tests/test_airqualitymonitor.py index 243bf6015..578599d53 100644 --- a/miio/tests/test_airqualitymonitor.py +++ b/miio/tests/test_airqualitymonitor.py @@ -10,7 +10,8 @@ def __init__(self, *args, **kwargs): 'power': 'on', 'aqi': 34, 'battery': 100, - 'usb_state': 'off' + 'usb_state': 'off', + 'time_state': 'format unknown' } self.return_values = { 'get_prop': self._get_state, @@ -56,3 +57,4 @@ def test_status(self): assert self.state().aqi == self.device.start_state["aqi"] assert self.state().battery == self.device.start_state["battery"] assert self.state().usb_power == (self.device.start_state["usb_state"] == 'on') + assert self.state().time_state == self.device.start_state["time_state"]