diff --git a/miio/integrations/airpurifier/zhimi/airpurifier_miot.py b/miio/integrations/airpurifier/zhimi/airpurifier_miot.py index ce3d4e135..eed06b717 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)