Skip to content

Commit

Permalink
Add gesture control setting for zhimi.airpurifier.za1
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-klode committed May 12, 2022
1 parent d8f6e24 commit e9d9270
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions miio/integrations/airpurifier/zhimi/airpurifier_miot.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@
"filter_rfid_product_id": {"siid": 14, "piid": 3},
# Device Display Unit
"device-display-unit": {"siid": 16, "piid": 1},
# Other
"gestures": {"siid": 15, "piid": 13},
}


Expand Down Expand Up @@ -440,6 +442,11 @@ def filter_left_time(self) -> Optional[int]:
"""How many days can the filter still be used."""
return self.data.get("filter_left_time")

@property
def gestures(self) -> Optional[bool]:
"""Return True if gesture control is on."""
return self.data.get("gestures")


class AirPurifierMiot(MiotDevice):
"""Main class representing the air purifier which uses MIoT protocol."""
Expand All @@ -462,6 +469,7 @@ class AirPurifierMiot(MiotDevice):
"LED: {result.led}\n"
"LED brightness: {result.led_brightness}\n"
"LED brightness level: {result.led_brightness_level}\n"
"Gestures: {result.gestures}\n"
"Buzzer: {result.buzzer}\n"
"Buzzer vol.: {result.buzzer_volume}\n"
"Child lock: {result.child_lock}\n"
Expand Down Expand Up @@ -559,6 +567,23 @@ def set_buzzer(self, buzzer: bool):

return self.set_property("buzzer", buzzer)

@command(
click.argument("gestures", type=bool),
default_output=format_output(
lambda gestures: "Turning on gestures"
if gestures
else "Turning off gestures"
),
)
def set_gestures(self, gestures: bool):
"""Set gestures on/off."""
if "gestures" not in self._get_mapping():
raise AirPurifierMiotException(
"Unsupported buzzer for model '%s'" % self.model
)

return self.set_property("gestures", gestures)

@command(
click.argument("lock", type=bool),
default_output=format_output(
Expand Down

0 comments on commit e9d9270

Please sign in to comment.