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

Air Purifier: Property "button_pressed" added #253

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion miio/airhumidifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def hardware_version(self) -> Optional[str]:

@property
def button_pressed(self) -> Optional[str]:
"""Button pressed."""
"""Last pressed button."""
return self.data["button_pressed"]

def __str__(self) -> str:
Expand Down
16 changes: 13 additions & 3 deletions miio/airpurifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ def auto_detect(self) -> Optional[bool]:

return None

@property

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redefinition of unused 'use_time' from line 176

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redefinition of unused 'use_time' from line 176

def button_pressed(self) -> Optional[str]:
"""Last pressed button."""
return self.data["button_pressed"]

@classmethod
def _get_filter_type(cls, product_id: str) -> FilterType:
ft = cls._filter_type_cache.get(product_id, None)
Expand Down Expand Up @@ -290,7 +295,9 @@ def __repr__(self) -> str:
"sleep_mode_learn_count=%s, " \
"extra_features=%s, " \
"turbo_mode_supported=%s, " \
"auto_detect=%s>" % \
"auto_detect=%s, " % \
"use_time=%s, " % \
"button_pressed=%s>" % \
(self.power,
self.aqi,
self.average_aqi,
Expand Down Expand Up @@ -319,7 +326,9 @@ def __repr__(self) -> str:
self.sleep_mode_learn_count,
self.extra_features,
self.turbo_mode_supported,
self.auto_detect)
self.auto_detect,
self.use_time,
self.button_pressed)
return s


Expand All @@ -336,7 +345,8 @@ def status(self) -> AirPurifierStatus:
# Second request
'led_b', 'bright', 'buzzer', 'child_lock', 'volume',
'rfid_product_id', 'rfid_tag', 'act_sleep', 'sleep_mode',
'sleep_time', 'sleep_data_num', 'app_extra', 'act_det']
'sleep_time', 'sleep_data_num', 'app_extra', 'act_det',
'button_pressed']

# A single request is limited to 16 properties. Therefore the
# properties are divided into multiple requests
Expand Down
4 changes: 3 additions & 1 deletion miio/tests/test_airpurifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def __init__(self, *args, **kwargs):
'sleep_time': 83890,
'sleep_data_num': 22,
'app_extra': 1,
'act_det': 'off'
'act_det': 'off',
'button_pressed': 'power',
}
self.return_values = {
'get_prop': self._get_state,
Expand Down Expand Up @@ -120,6 +121,7 @@ def test_status(self):
assert self.state().extra_features == self.device.start_state["app_extra"]
assert self.state().turbo_mode_supported == (self.device.start_state["app_extra"] == 1)
assert self.state().auto_detect == (self.device.start_state["act_det"] == 'on')
assert self.state().button_pressed == self.device.start_state["button_pressed"]

def test_set_mode(self):
def mode():
Expand Down