diff --git a/custom_components/xiaomi_miio_airpurifier/fan.py b/custom_components/xiaomi_miio_airpurifier/fan.py index c0f4f90..0d7172b 100644 --- a/custom_components/xiaomi_miio_airpurifier/fan.py +++ b/custom_components/xiaomi_miio_airpurifier/fan.py @@ -123,6 +123,8 @@ MODEL_AIRPURIFIER_3 = "zhimi.airpurifier.ma4" MODEL_AIRPURIFIER_3H = "zhimi.airpurifier.mb3" MODEL_AIRPURIFIER_ZA1 = "zhimi.airpurifier.za1" +MODEL_AIRPURIFIER_4_PRO = "zhimi.airp.vb4" +MODEL_AIRPURIFIER_4_LITE = "zhimi.airp.rmb1" MODEL_AIRPURIFIER_AIRDOG_X3 = "airdog.airpurifier.x3" MODEL_AIRPURIFIER_AIRDOG_X5 = "airdog.airpurifier.x5" MODEL_AIRPURIFIER_AIRDOG_X7SM = "airdog.airpurifier.x7sm" @@ -183,6 +185,8 @@ MODEL_AIRPURIFIER_3, MODEL_AIRPURIFIER_3H, MODEL_AIRPURIFIER_ZA1, + MODEL_AIRPURIFIER_4_PRO, + MODEL_AIRPURIFIER_4_LITE, MODEL_AIRPURIFIER_AIRDOG_X3, MODEL_AIRPURIFIER_AIRDOG_X5, MODEL_AIRPURIFIER_AIRDOG_X7SM, @@ -259,6 +263,11 @@ ATTR_VOLUME = "volume" ATTR_USE_TIME = "use_time" ATTR_BUTTON_PRESSED = "button_pressed" +ATTR_ANION = "anion" +ATTR_PM10_DENSITY = "pm10_density" +ATTR_FILTER_LEFT_TIME = "filter_left_time" +ATTR_FAVORITE_RPM = "favorite_rpm" +ATTR_DISPLAY_UNIT = "device-display-unit" # Air Humidifier ATTR_TARGET_HUMIDITY = "target_humidity" @@ -322,7 +331,7 @@ # Fan Leshow SS4 ATTR_ERROR_DETECTED = "error_detected" -PURIFIER_MIOT = [MODEL_AIRPURIFIER_3, MODEL_AIRPURIFIER_3H, MODEL_AIRPURIFIER_ZA1] +PURIFIER_MIOT = [MODEL_AIRPURIFIER_3, MODEL_AIRPURIFIER_3H, MODEL_AIRPURIFIER_ZA1, MODEL_AIRPURIFIER_4_PRO, MODEL_AIRPURIFIER_4_LITE] HUMIDIFIER_MIOT = [MODEL_AIRHUMIDIFIER_CA4] # AirDogX7SM @@ -465,6 +474,48 @@ ATTR_BUTTON_PRESSED: "button_pressed", } +AVAILABLE_ATTRIBUTES_AIRPURIFIER_4_PRO = { + ATTR_POWER: "power", + ATTR_MODE: "mode", + ATTR_FAN_LEVEL: "fan_level", + ATTR_ANION: "anion", + ATTR_HUMIDITY: "humidity", + ATTR_AIR_QUALITY_INDEX: "aqi", + ATTR_TEMPERATURE: "temperature", + ATTR_PM10_DENSITY: "pm10_density", + ATTR_FILTER_LIFE: "filter_life_remaining", + ATTR_FILTER_HOURS_USED: "filter_hours_used", + ATTR_FILTER_LEFT_TIME: "filter_left_time", + ATTR_BUZZER: "buzzer", + ATTR_CHILD_LOCK: "child_lock", + ATTR_MOTOR_SPEED: "motor_speed", + ATTR_FAVORITE_RPM: "favorite_rpm", + ATTR_FAVORITE_LEVEL: "favorite_level", + ATTR_PURIFY_VOLUME: "purify_volume", + ATTR_AVERAGE_AIR_QUALITY_INDEX: "average_aqi", + ATTR_FILTER_RFID_TAG: "filter_rfid_tag", + ATTR_FILTER_RFID_PRODUCT_ID: "filter_rfid_product_id", + ATTR_LED_BRIGHTNESS: "led_brightness", + ATTR_DISPLAY_UNIT: "device-display-unit" +} + +AVAILABLE_ATTRIBUTES_AIRPURIFIER_4_LITE = { + ATTR_POWER: "power", + ATTR_MODE: "mode", + ATTR_HUMIDITY: "humidity", + ATTR_AIR_QUALITY_INDEX: "aqi", + ATTR_TEMPERATURE: "temperature", + ATTR_FILTER_LIFE: "filter_life_remaining", + ATTR_FILTER_HOURS_USED: "filter_hours_used", + ATTR_FILTER_LEFT_TIME: "filter_left_time", + ATTR_BUZZER: "buzzer", + ATTR_CHILD_LOCK: "child_lock", + ATTR_MOTOR_SPEED: "motor_speed", + ATTR_FAVORITE_LEVEL: "favorite_level", + ATTR_LED_BRIGHTNESS: "led_brightness", + ATTR_DISPLAY_UNIT: "device-display-unit" +} + AVAILABLE_ATTRIBUTES_AIRHUMIDIFIER_COMMON = { ATTR_TEMPERATURE: "temperature", ATTR_HUMIDITY: "humidity", @@ -722,6 +773,8 @@ "High", "Strong", ] +OPERATION_MODES_AIRPURIFIER_4_PRO = ["Auto", "Sleep", "Favorite", "Manual"] +OPERATION_MODES_AIRPURIFIER_4_LITE = ["Auto", "Sleep", "Favorite"] OPERATION_MODES_AIRFRESH = ["Auto", "Silent", "Interval", "Low", "Middle", "Strong"] OPERATION_MODES_AIRFRESH_T2017 = ["Auto", "Sleep", "Favorite"] @@ -808,6 +861,24 @@ FEATURE_SET_BUZZER | FEATURE_SET_CHILD_LOCK | FEATURE_SET_LED ) +FEATURE_FLAGS_AIRPURIFIER_4_PRO = ( + FEATURE_SET_BUZZER + | FEATURE_SET_CHILD_LOCK + | FEATURE_SET_LED + | FEATURE_SET_FAVORITE_LEVEL + | FEATURE_SET_FAN_LEVEL + | FEATURE_SET_LED_BRIGHTNESS +) + +FEATURE_FLAGS_AIRPURIFIER_4_LITE = ( + FEATURE_SET_BUZZER + | FEATURE_SET_CHILD_LOCK + | FEATURE_SET_LED + | FEATURE_SET_FAVORITE_LEVEL + | FEATURE_SET_FAN_LEVEL + | FEATURE_SET_LED_BRIGHTNESS +) + FEATURE_FLAGS_AIRHUMIDIFIER = ( FEATURE_SET_BUZZER | FEATURE_SET_CHILD_LOCK @@ -1424,6 +1495,14 @@ def __init__(self, name, device, model, unique_id, retries=0): self._device_features = FEATURE_FLAGS_AIRPURIFIER_V3 self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_V3 self._preset_modes = OPERATION_MODES_AIRPURIFIER_V3 + elif self._model == MODEL_AIRPURIFIER_4_PRO: + self._device_features = FEATURE_FLAGS_AIRPURIFIER_4_PRO + self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_4_PRO + self._preset_modes = OPERATION_MODES_AIRPURIFIER_4_PRO + elif self._model == MODEL_AIRPURIFIER_4_LITE: + self._device_features = FEATURE_FLAGS_AIRPURIFIER_4_LITE + self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_4_LITE + self._preset_modes = OPERATION_MODES_AIRPURIFIER_4_LITE else: self._device_features = FEATURE_FLAGS_AIRPURIFIER self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER