From 2aacae7acd4f7698ac2c2dfc82b2f56e28d1d94a Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sun, 28 Jan 2018 09:34:22 +0100 Subject: [PATCH 1/3] New property "time_state" added. --- miio/airqualitymonitor.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) 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", From b15ac5c5f990b1ab648573d72f96fe7e40eb41dc Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sun, 28 Jan 2018 09:36:45 +0100 Subject: [PATCH 2/3] Tests updated. --- miio/tests/test_airqualitymonitor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/miio/tests/test_airqualitymonitor.py b/miio/tests/test_airqualitymonitor.py index 243bf6015..c93983db0 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"] \ No newline at end of file From 7c7378c3883ce224c4a77c43cc5b6a358116ca4f Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sun, 28 Jan 2018 10:55:29 +0100 Subject: [PATCH 3/3] Make hound happy. --- miio/tests/test_airqualitymonitor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/miio/tests/test_airqualitymonitor.py b/miio/tests/test_airqualitymonitor.py index c93983db0..578599d53 100644 --- a/miio/tests/test_airqualitymonitor.py +++ b/miio/tests/test_airqualitymonitor.py @@ -11,7 +11,7 @@ def __init__(self, *args, **kwargs): 'aqi': 34, 'battery': 100, 'usb_state': 'off', - 'time_state' : 'format unknown' + 'time_state': 'format unknown' } self.return_values = { 'get_prop': self._get_state, @@ -57,4 +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"] \ No newline at end of file + assert self.state().time_state == self.device.start_state["time_state"]