From 135370c132f994aa3f9b266cf2d7ff86df9ea0b5 Mon Sep 17 00:00:00 2001 From: Teemu R Date: Thu, 15 Sep 2022 19:52:56 +0200 Subject: [PATCH] Add support for zhimi.airp.mb5a (#1527) --- .../airpurifier/zhimi/airpurifier_miot.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/miio/integrations/airpurifier/zhimi/airpurifier_miot.py b/miio/integrations/airpurifier/zhimi/airpurifier_miot.py index 5178e8879..61a1f8bee 100644 --- a/miio/integrations/airpurifier/zhimi/airpurifier_miot.py +++ b/miio/integrations/airpurifier/zhimi/airpurifier_miot.py @@ -244,6 +244,7 @@ "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 @@ -251,6 +252,15 @@ "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 @@ -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) @@ -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)