Skip to content

Commit

Permalink
Some known properties of the Water Purifier added. (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi authored and rytilahti committed Mar 17, 2018
1 parent 17e8e69 commit c9078d9
Showing 1 changed file with 108 additions and 3 deletions.
111 changes: 108 additions & 3 deletions miio/waterpurifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,110 @@ def power(self) -> str:
def is_on(self) -> bool:
return self.power == "on"

def __str__(self) -> str:
return "<WaterPurifierStatus power=%s>" % 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 "<WaterPurifierStatus " \
"power=%s, " \
"mode=%s, " \
"tds=%s, " \
"filter_life_remaining=%s, " \
"filter_state=%s, " \
"filter2_life_remaining=%s, " \
"filter2_state=%s, " \
"life=%s, " \
"state=%s, " \
"level=%s, " \
"volume=%s, " \
"filter=%s, " \
"usage=%s, " \
"temperature=%s, " \
"uv_filter_life_remaining=%s, " \
"uv_filter_state=%s, " \
"valve=%s>" % \
(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):
Expand All @@ -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",
Expand Down

0 comments on commit c9078d9

Please sign in to comment.