Support xiaomi_miio Smartmi Air Purifier (zhimi.airpurifier.za1) ()

This commit is contained in:
an0nfunc 2022-11-29 10:29:34 +01:00 committed by GitHub
parent f88487be25
commit a5890b2374
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 50 additions and 7 deletions
homeassistant/components/xiaomi_miio

View file

@ -1,8 +1,13 @@
"""Constants for the Xiaomi Miio component.""" """Constants for the Xiaomi Miio component."""
from miio.vacuum import ( from miio.integrations.vacuum.roborock.vacuum import (
ROCKROBO_E2,
ROCKROBO_S4,
ROCKROBO_S4_MAX,
ROCKROBO_S5, ROCKROBO_S5,
ROCKROBO_S5_MAX,
ROCKROBO_S6, ROCKROBO_S6,
ROCKROBO_S6_MAXV, ROCKROBO_S6_MAXV,
ROCKROBO_S6_PURE,
ROCKROBO_S7, ROCKROBO_S7,
ROCKROBO_S7_MAXV, ROCKROBO_S7_MAXV,
ROCKROBO_V1, ROCKROBO_V1,
@ -70,6 +75,7 @@ MODEL_AIRPURIFIER_V1 = "zhimi.airpurifier.v1"
MODEL_AIRPURIFIER_V2 = "zhimi.airpurifier.v2" MODEL_AIRPURIFIER_V2 = "zhimi.airpurifier.v2"
MODEL_AIRPURIFIER_V3 = "zhimi.airpurifier.v3" MODEL_AIRPURIFIER_V3 = "zhimi.airpurifier.v3"
MODEL_AIRPURIFIER_V5 = "zhimi.airpurifier.v5" MODEL_AIRPURIFIER_V5 = "zhimi.airpurifier.v5"
MODEL_AIRPURIFIER_ZA1 = "zhimi.airpurifier.za1"
MODEL_AIRHUMIDIFIER_V1 = "zhimi.humidifier.v1" MODEL_AIRHUMIDIFIER_V1 = "zhimi.humidifier.v1"
MODEL_AIRHUMIDIFIER_CA1 = "zhimi.humidifier.ca1" MODEL_AIRHUMIDIFIER_CA1 = "zhimi.humidifier.ca1"
@ -124,6 +130,7 @@ MODELS_PURIFIER_MIOT = [
MODEL_AIRPURIFIER_4_LITE_RMB1, MODEL_AIRPURIFIER_4_LITE_RMB1,
MODEL_AIRPURIFIER_4, MODEL_AIRPURIFIER_4,
MODEL_AIRPURIFIER_4_PRO, MODEL_AIRPURIFIER_4_PRO,
MODEL_AIRPURIFIER_ZA1,
] ]
MODELS_PURIFIER_MIIO = [ MODELS_PURIFIER_MIIO = [
MODEL_AIRPURIFIER_V1, MODEL_AIRPURIFIER_V1,
@ -213,12 +220,6 @@ MODELS_LIGHT = (
+ MODELS_LIGHT_MONO + MODELS_LIGHT_MONO
) )
# TODO: use const from pythonmiio once new release with the constant has been published. # pylint: disable=fixme
ROCKROBO_S4 = "roborock.vacuum.s4"
ROCKROBO_S4_MAX = "roborock.vacuum.a19"
ROCKROBO_S5_MAX = "roborock.vacuum.s5e"
ROCKROBO_S6_PURE = "roborock.vacuum.a08"
ROCKROBO_E2 = "roborock.vacuum.e2"
ROBOROCK_GENERIC = "roborock.vacuum" ROBOROCK_GENERIC = "roborock.vacuum"
ROCKROBO_GENERIC = "rockrobo.vacuum" ROCKROBO_GENERIC = "rockrobo.vacuum"
MODELS_VACUUM = [ MODELS_VACUUM = [
@ -397,6 +398,10 @@ FEATURE_FLAGS_AIRPURIFIER_V3 = (
FEATURE_SET_BUZZER | FEATURE_SET_CHILD_LOCK | FEATURE_SET_LED FEATURE_SET_BUZZER | FEATURE_SET_CHILD_LOCK | FEATURE_SET_LED
) )
FEATURE_FLAGS_AIRPURIFIER_ZA1 = (
FEATURE_SET_BUZZER | FEATURE_SET_CHILD_LOCK | FEATURE_SET_FAVORITE_LEVEL
)
FEATURE_FLAGS_AIRHUMIDIFIER = ( FEATURE_FLAGS_AIRHUMIDIFIER = (
FEATURE_SET_BUZZER | FEATURE_SET_CHILD_LOCK | FEATURE_SET_TARGET_HUMIDITY FEATURE_SET_BUZZER | FEATURE_SET_CHILD_LOCK | FEATURE_SET_TARGET_HUMIDITY
) )

View file

@ -55,6 +55,7 @@ from .const import (
FEATURE_FLAGS_AIRPURIFIER_PRO, FEATURE_FLAGS_AIRPURIFIER_PRO,
FEATURE_FLAGS_AIRPURIFIER_PRO_V7, FEATURE_FLAGS_AIRPURIFIER_PRO_V7,
FEATURE_FLAGS_AIRPURIFIER_V3, FEATURE_FLAGS_AIRPURIFIER_V3,
FEATURE_FLAGS_AIRPURIFIER_ZA1,
FEATURE_FLAGS_FAN, FEATURE_FLAGS_FAN,
FEATURE_FLAGS_FAN_1C, FEATURE_FLAGS_FAN_1C,
FEATURE_FLAGS_FAN_P5, FEATURE_FLAGS_FAN_P5,
@ -77,6 +78,7 @@ from .const import (
MODEL_AIRPURIFIER_PRO, MODEL_AIRPURIFIER_PRO,
MODEL_AIRPURIFIER_PRO_V7, MODEL_AIRPURIFIER_PRO_V7,
MODEL_AIRPURIFIER_V3, MODEL_AIRPURIFIER_V3,
MODEL_AIRPURIFIER_ZA1,
MODEL_FAN_1C, MODEL_FAN_1C,
MODEL_FAN_P5, MODEL_FAN_P5,
MODEL_FAN_P9, MODEL_FAN_P9,
@ -160,6 +162,7 @@ PRESET_MODES_AIRPURIFIER_PRO = ["Auto", "Silent", "Favorite"]
PRESET_MODES_AIRPURIFIER_PRO_V7 = PRESET_MODES_AIRPURIFIER_PRO PRESET_MODES_AIRPURIFIER_PRO_V7 = PRESET_MODES_AIRPURIFIER_PRO
PRESET_MODES_AIRPURIFIER_2S = ["Auto", "Silent", "Favorite"] PRESET_MODES_AIRPURIFIER_2S = ["Auto", "Silent", "Favorite"]
PRESET_MODES_AIRPURIFIER_3C = ["Auto", "Silent", "Favorite"] PRESET_MODES_AIRPURIFIER_3C = ["Auto", "Silent", "Favorite"]
PRESET_MODES_AIRPURIFIER_ZA1 = ["Auto", "Silent", "Favorite"]
PRESET_MODES_AIRPURIFIER_V3 = [ PRESET_MODES_AIRPURIFIER_V3 = [
"Auto", "Auto",
"Silent", "Silent",
@ -449,6 +452,12 @@ class XiaomiAirPurifier(XiaomiGenericAirPurifier):
self._preset_modes = PRESET_MODES_AIRPURIFIER_2S self._preset_modes = PRESET_MODES_AIRPURIFIER_2S
self._attr_supported_features = FanEntityFeature.PRESET_MODE self._attr_supported_features = FanEntityFeature.PRESET_MODE
self._speed_count = 1 self._speed_count = 1
elif self._model == MODEL_AIRPURIFIER_ZA1:
self._device_features = FEATURE_FLAGS_AIRPURIFIER_ZA1
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_MIOT
self._preset_modes = PRESET_MODES_AIRPURIFIER_ZA1
self._attr_supported_features = FanEntityFeature.PRESET_MODE
self._speed_count = 1
elif self._model in MODELS_PURIFIER_MIOT: elif self._model in MODELS_PURIFIER_MIOT:
self._device_features = FEATURE_FLAGS_AIRPURIFIER_MIOT self._device_features = FEATURE_FLAGS_AIRPURIFIER_MIOT
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_MIOT self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_MIOT

View file

@ -39,6 +39,7 @@ from .const import (
FEATURE_FLAGS_AIRPURIFIER_PRO_V7, FEATURE_FLAGS_AIRPURIFIER_PRO_V7,
FEATURE_FLAGS_AIRPURIFIER_V1, FEATURE_FLAGS_AIRPURIFIER_V1,
FEATURE_FLAGS_AIRPURIFIER_V3, FEATURE_FLAGS_AIRPURIFIER_V3,
FEATURE_FLAGS_AIRPURIFIER_ZA1,
FEATURE_FLAGS_FAN, FEATURE_FLAGS_FAN,
FEATURE_FLAGS_FAN_1C, FEATURE_FLAGS_FAN_1C,
FEATURE_FLAGS_FAN_P5, FEATURE_FLAGS_FAN_P5,
@ -73,6 +74,7 @@ from .const import (
MODEL_AIRPURIFIER_PRO_V7, MODEL_AIRPURIFIER_PRO_V7,
MODEL_AIRPURIFIER_V1, MODEL_AIRPURIFIER_V1,
MODEL_AIRPURIFIER_V3, MODEL_AIRPURIFIER_V3,
MODEL_AIRPURIFIER_ZA1,
MODEL_FAN_1C, MODEL_FAN_1C,
MODEL_FAN_P5, MODEL_FAN_P5,
MODEL_FAN_P9, MODEL_FAN_P9,
@ -249,6 +251,7 @@ MODEL_TO_FEATURES_MAP = {
MODEL_AIRPURIFIER_4_LITE_RMB1: FEATURE_FLAGS_AIRPURIFIER_4_LITE, MODEL_AIRPURIFIER_4_LITE_RMB1: FEATURE_FLAGS_AIRPURIFIER_4_LITE,
MODEL_AIRPURIFIER_4: FEATURE_FLAGS_AIRPURIFIER_4, MODEL_AIRPURIFIER_4: FEATURE_FLAGS_AIRPURIFIER_4,
MODEL_AIRPURIFIER_4_PRO: FEATURE_FLAGS_AIRPURIFIER_4, MODEL_AIRPURIFIER_4_PRO: FEATURE_FLAGS_AIRPURIFIER_4,
MODEL_AIRPURIFIER_ZA1: FEATURE_FLAGS_AIRPURIFIER_ZA1,
MODEL_FAN_1C: FEATURE_FLAGS_FAN_1C, MODEL_FAN_1C: FEATURE_FLAGS_FAN_1C,
MODEL_FAN_P10: FEATURE_FLAGS_FAN_P10_P11, MODEL_FAN_P10: FEATURE_FLAGS_FAN_P10_P11,
MODEL_FAN_P11: FEATURE_FLAGS_FAN_P10_P11, MODEL_FAN_P11: FEATURE_FLAGS_FAN_P10_P11,

View file

@ -53,6 +53,7 @@ from .const import (
MODEL_AIRPURIFIER_M1, MODEL_AIRPURIFIER_M1,
MODEL_AIRPURIFIER_M2, MODEL_AIRPURIFIER_M2,
MODEL_AIRPURIFIER_PROH, MODEL_AIRPURIFIER_PROH,
MODEL_AIRPURIFIER_ZA1,
MODEL_FAN_SA1, MODEL_FAN_SA1,
MODEL_FAN_V2, MODEL_FAN_V2,
MODEL_FAN_V3, MODEL_FAN_V3,
@ -113,6 +114,9 @@ MODEL_TO_ATTR_MAP: dict[str, list] = {
MODEL_AIRPURIFIER_3: [ MODEL_AIRPURIFIER_3: [
AttributeEnumMapping(ATTR_LED_BRIGHTNESS, AirpurifierMiotLedBrightness) AttributeEnumMapping(ATTR_LED_BRIGHTNESS, AirpurifierMiotLedBrightness)
], ],
MODEL_AIRPURIFIER_ZA1: [
AttributeEnumMapping(ATTR_LED_BRIGHTNESS, AirpurifierMiotLedBrightness)
],
MODEL_AIRPURIFIER_3H: [ MODEL_AIRPURIFIER_3H: [
AttributeEnumMapping(ATTR_LED_BRIGHTNESS, AirpurifierMiotLedBrightness) AttributeEnumMapping(ATTR_LED_BRIGHTNESS, AirpurifierMiotLedBrightness)
], ],

View file

@ -70,6 +70,7 @@ from .const import (
MODEL_AIRPURIFIER_PRO_V7, MODEL_AIRPURIFIER_PRO_V7,
MODEL_AIRPURIFIER_V2, MODEL_AIRPURIFIER_V2,
MODEL_AIRPURIFIER_V3, MODEL_AIRPURIFIER_V3,
MODEL_AIRPURIFIER_ZA1,
MODEL_FAN_P5, MODEL_FAN_P5,
MODEL_FAN_V2, MODEL_FAN_V2,
MODEL_FAN_V3, MODEL_FAN_V3,
@ -97,6 +98,7 @@ UNIT_LUMEN = "lm"
ATTR_ACTUAL_SPEED = "actual_speed" ATTR_ACTUAL_SPEED = "actual_speed"
ATTR_AIR_QUALITY = "air_quality" ATTR_AIR_QUALITY = "air_quality"
ATTR_TVOC = "tvoc"
ATTR_AQI = "aqi" ATTR_AQI = "aqi"
ATTR_BATTERY = "battery" ATTR_BATTERY = "battery"
ATTR_CARBON_DIOXIDE = "co2" ATTR_CARBON_DIOXIDE = "co2"
@ -262,6 +264,13 @@ SENSOR_TYPES = {
icon="mdi:cloud", icon="mdi:cloud",
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
ATTR_TVOC: XiaomiMiioSensorDescription(
key=ATTR_TVOC,
name="TVOC",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
device_class=SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS,
),
ATTR_PM10: XiaomiMiioSensorDescription( ATTR_PM10: XiaomiMiioSensorDescription(
key=ATTR_PM10, key=ATTR_PM10,
name="PM10", name="PM10",
@ -452,6 +461,15 @@ PURIFIER_3C_SENSORS = (
ATTR_MOTOR_SPEED, ATTR_MOTOR_SPEED,
ATTR_PM25, ATTR_PM25,
) )
PURIFIER_ZA1_SENSORS = (
ATTR_FILTER_LIFE_REMAINING,
ATTR_FILTER_USE,
ATTR_MOTOR_SPEED,
ATTR_PM25,
ATTR_TVOC,
ATTR_HUMIDITY,
ATTR_TEMPERATURE,
)
PURIFIER_V2_SENSORS = ( PURIFIER_V2_SENSORS = (
ATTR_FILTER_LIFE_REMAINING, ATTR_FILTER_LIFE_REMAINING,
ATTR_FILTER_USE, ATTR_FILTER_USE,
@ -548,6 +566,7 @@ MODEL_TO_SENSORS_MAP: dict[str, tuple[str, ...]] = {
MODEL_AIRPURIFIER_PRO_V7: PURIFIER_PRO_V7_SENSORS, MODEL_AIRPURIFIER_PRO_V7: PURIFIER_PRO_V7_SENSORS,
MODEL_AIRPURIFIER_V2: PURIFIER_V2_SENSORS, MODEL_AIRPURIFIER_V2: PURIFIER_V2_SENSORS,
MODEL_AIRPURIFIER_V3: PURIFIER_V3_SENSORS, MODEL_AIRPURIFIER_V3: PURIFIER_V3_SENSORS,
MODEL_AIRPURIFIER_ZA1: PURIFIER_ZA1_SENSORS,
MODEL_FAN_V2: FAN_V2_V3_SENSORS, MODEL_FAN_V2: FAN_V2_V3_SENSORS,
MODEL_FAN_V3: FAN_V2_V3_SENSORS, MODEL_FAN_V3: FAN_V2_V3_SENSORS,
MODEL_FAN_ZA5: FAN_ZA5_SENSORS, MODEL_FAN_ZA5: FAN_ZA5_SENSORS,

View file

@ -53,6 +53,7 @@ from .const import (
FEATURE_FLAGS_AIRPURIFIER_PRO_V7, FEATURE_FLAGS_AIRPURIFIER_PRO_V7,
FEATURE_FLAGS_AIRPURIFIER_V1, FEATURE_FLAGS_AIRPURIFIER_V1,
FEATURE_FLAGS_AIRPURIFIER_V3, FEATURE_FLAGS_AIRPURIFIER_V3,
FEATURE_FLAGS_AIRPURIFIER_ZA1,
FEATURE_FLAGS_FAN, FEATURE_FLAGS_FAN,
FEATURE_FLAGS_FAN_1C, FEATURE_FLAGS_FAN_1C,
FEATURE_FLAGS_FAN_P5, FEATURE_FLAGS_FAN_P5,
@ -90,6 +91,7 @@ from .const import (
MODEL_AIRPURIFIER_PRO_V7, MODEL_AIRPURIFIER_PRO_V7,
MODEL_AIRPURIFIER_V1, MODEL_AIRPURIFIER_V1,
MODEL_AIRPURIFIER_V3, MODEL_AIRPURIFIER_V3,
MODEL_AIRPURIFIER_ZA1,
MODEL_FAN_1C, MODEL_FAN_1C,
MODEL_FAN_P5, MODEL_FAN_P5,
MODEL_FAN_P9, MODEL_FAN_P9,
@ -204,6 +206,7 @@ MODEL_TO_FEATURES_MAP = {
MODEL_AIRPURIFIER_4_LITE_RMB1: FEATURE_FLAGS_AIRPURIFIER_4_LITE, MODEL_AIRPURIFIER_4_LITE_RMB1: FEATURE_FLAGS_AIRPURIFIER_4_LITE,
MODEL_AIRPURIFIER_4: FEATURE_FLAGS_AIRPURIFIER_4, MODEL_AIRPURIFIER_4: FEATURE_FLAGS_AIRPURIFIER_4,
MODEL_AIRPURIFIER_4_PRO: FEATURE_FLAGS_AIRPURIFIER_4, MODEL_AIRPURIFIER_4_PRO: FEATURE_FLAGS_AIRPURIFIER_4,
MODEL_AIRPURIFIER_ZA1: FEATURE_FLAGS_AIRPURIFIER_ZA1,
MODEL_FAN_1C: FEATURE_FLAGS_FAN_1C, MODEL_FAN_1C: FEATURE_FLAGS_FAN_1C,
MODEL_FAN_P10: FEATURE_FLAGS_FAN_P10_P11, MODEL_FAN_P10: FEATURE_FLAGS_FAN_P10_P11,
MODEL_FAN_P11: FEATURE_FLAGS_FAN_P10_P11, MODEL_FAN_P11: FEATURE_FLAGS_FAN_P10_P11,