Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Water Purifier: Some properties added #271

Merged
merged 1 commit into from
Mar 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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