From 7723aa51a077f206e53d9af4654ffaa8f40e38df Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sat, 17 Mar 2018 08:46:52 +0100 Subject: [PATCH] Some known properties of the Water Purifier added. --- miio/waterpurifier.py | 111 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 108 insertions(+), 3 deletions(-) diff --git a/miio/waterpurifier.py b/miio/waterpurifier.py index 5777526de..8ca30ff8c 100644 --- a/miio/waterpurifier.py +++ b/miio/waterpurifier.py @@ -20,8 +20,110 @@ def power(self) -> str: def is_on(self) -> bool: return self.power == "on" - def __str__(self) -> str: - return "" % self.power + @property + def mode(self) -> str: + """Current operation mode.""" + return self.data["mode"] + + @property + def tds(self) -> str: + return self.data["tds"] + + @property + def filter_life_remaining(self) -> int: + """Time until the filter should be changed.""" + return self.data["filter1_life"] + + @property + def filter_state(self) -> str: + return self.data["filter1_state"] + + @property + def filter2_life_remaining(self) -> int: + """Time until the filter should be changed.""" + return self.data["filter_life"] + + @property + def filter2_state(self) -> str: + return self.data["filter_state"] + + @property + def life(self) -> str: + return self.data["life"] + + @property + def state(self) -> str: + return self.data["state"] + + @property + def level(self) -> str: + return self.data["level"] + + @property + def volume(self) -> str: + return self.data["volume"] + + @property + def filter(self) -> str: + return self.data["filter"] + + @property + def usage(self) -> str: + return self.data["usage"] + + @property + def temperature(self) -> str: + return self.data["temperature"] + + @property + def uv_filter_life_remaining(self) -> int: + """Time until the filter should be changed.""" + return self.data["uv_life"] + + @property + def uv_filter_state(self) -> str: + return self.data["uv_state"] + + @property + def valve(self) -> str: + return self.data["elecval_state"] + + def __repr__(self) -> str: + return "" % \ + (self.power, + self.mode, + self.tds, + self.filter_life_remaining, + self.filter_state, + self.filter2_life_remaining, + self.filter2_state, + self.life, + self.state, + self.level, + self.volume, + self.filter, + self.usage, + self.temperature, + self.uv_filter_life_remaining, + self.uv_filter_state, + self.valve) class WaterPurifier(Device): @@ -30,7 +132,10 @@ class WaterPurifier(Device): def status(self) -> WaterPurifierStatus: """Retrieve properties.""" - properties = ['power'] + properties = ['power', 'mode', 'tds', 'filter1_life', 'filter1_state', + 'filter_life', 'filter_state', 'life', 'state', 'level', + 'volume', 'filter', 'usage', 'temperature', 'uv_life', + 'uv_state', 'elecval_state'] values = self.send( "get_prop",