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

Add support for zhimi.airp.mb5a #1527

Merged
merged 1 commit into from Sep 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 12 additions & 12 deletions miio/integrations/airpurifier/zhimi/airpurifier_miot.py
Expand Up @@ -244,13 +244,23 @@
"zhimi.airpurifier.mb4": _MAPPING_MB4, # airpurifier 3c
"zhimi.airp.mb4a": _MAPPING_MB4, # airpurifier 3c
"zhimi.airp.mb5": _MAPPING_VA2, # airpurifier 4
"zhimi.airp.mb5a": _MAPPING_VA2, # airpurifier 4
"zhimi.airp.va2": _MAPPING_VA2, # airpurifier 4 pro
"zhimi.airp.vb4": _MAPPING_VB4, # airpurifier 4 pro
"zhimi.airpurifier.rma1": _MAPPING_RMA1, # airpurifier 4 lite
"zhimi.airp.rmb1": _MAPPING_RMB1, # airpurifier 4 lite
"zhimi.airpurifier.za1": _MAPPING_ZA1, # smartmi air purifier
}

# Models requiring reversed led brightness value
REVERSED_LED_BRIGHTNESS = [
"zhimi.airp.va2",
"zhimi.airp.mb5",
"zhimi.airp.mb5a",
"zhimi.airp.vb4",
"zhimi.airp.rmb1",
]


class AirPurifierMiotException(DeviceException):
pass
Expand Down Expand Up @@ -401,15 +411,9 @@ def led(self) -> Optional[bool]:
@property
def led_brightness(self) -> Optional[LedBrightness]:
"""Brightness of the LED."""

value = self.data.get("led_brightness")
if value is not None:
if self.model in (
"zhimi.airp.va2",
"zhimi.airp.mb5",
"zhimi.airp.vb4",
"zhimi.airp.rmb1",
):
if self.model in REVERSED_LED_BRIGHTNESS:
value = 2 - value
try:
return LedBrightness(value)
Expand Down Expand Up @@ -690,11 +694,7 @@ def set_led_brightness(self, brightness: LedBrightness):
)

value = brightness.value
if (
self.model
in ("zhimi.airp.va2", "zhimi.airp.mb5", "zhimi.airp.vb4", "zhimi.airp.rmb1")
and value is not None
):
if self.model in REVERSED_LED_BRIGHTNESS and value is not None:
value = 2 - value
return self.set_property("led_brightness", value)

Expand Down