Skip to content

Commit

Permalink
Xiaomi 2S air purifier mode selection support (home-assistant#86649)
Browse files Browse the repository at this point in the history
* Xiaomi 2S air purifier mode selection support

* Update homeassistant/components/xiaomi_miio/select.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* rename fix translation keys and rename key to be specific to airpurifiers

Co-authored-by: Teemu R. <tpr@iki.fi>
  • Loading branch information
2 people authored and cereal2nd committed Feb 6, 2023
1 parent 6efb462 commit 642a923
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
16 changes: 15 additions & 1 deletion homeassistant/components/xiaomi_miio/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
)
from miio.integrations.airpurifier.zhimi.airpurifier import (
LedBrightness as AirpurifierLedBrightness,
OperationMode as AirpurifierOperationMode,
)
from miio.integrations.airpurifier.zhimi.airpurifier_miot import (
LedBrightness as AirpurifierMiotLedBrightness,
Expand Down Expand Up @@ -52,6 +53,7 @@
MODEL_AIRPURIFIER_4_PRO,
MODEL_AIRPURIFIER_M1,
MODEL_AIRPURIFIER_M2,
MODEL_AIRPURIFIER_MA2,
MODEL_AIRPURIFIER_PROH,
MODEL_AIRPURIFIER_ZA1,
MODEL_FAN_SA1,
Expand All @@ -66,7 +68,7 @@
ATTR_DISPLAY_ORIENTATION = "display_orientation"
ATTR_LED_BRIGHTNESS = "led_brightness"
ATTR_PTC_LEVEL = "ptc_level"

ATTR_MODE = "mode"

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -111,6 +113,7 @@ class AttributeEnumMapping(NamedTuple):
MODEL_AIRHUMIDIFIER_V1: [
AttributeEnumMapping(ATTR_LED_BRIGHTNESS, AirhumidifierLedBrightness)
],
MODEL_AIRPURIFIER_MA2: [AttributeEnumMapping(ATTR_MODE, AirpurifierOperationMode)],
MODEL_AIRPURIFIER_3: [
AttributeEnumMapping(ATTR_LED_BRIGHTNESS, AirpurifierMiotLedBrightness)
],
Expand Down Expand Up @@ -160,6 +163,17 @@ class AttributeEnumMapping(NamedTuple):
options=["forward", "left", "right"],
entity_category=EntityCategory.CONFIG,
),
XiaomiMiioSelectDescription(
key=ATTR_MODE,
attr_name=ATTR_MODE,
name="Mode",
set_method="set_mode",
set_method_error_message="Setting the mode of the fan failed.",
icon="mdi:fan",
translation_key="airpurifier_mode",
options=["silent", "auto", "favorite"],
entity_category=EntityCategory.CONFIG,
),
XiaomiMiioSelectDescription(
key=ATTR_LED_BRIGHTNESS,
attr_name=ATTR_LED_BRIGHTNESS,
Expand Down
7 changes: 7 additions & 0 deletions homeassistant/components/xiaomi_miio/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@
"right": "Right"
}
},
"airpurifier_mode": {
"state": {
"silent": "Silent",
"auto": "Auto",
"favorite": "Favorite"
}
},
"ptc_level": {
"state": {
"low": "Low",
Expand Down

0 comments on commit 642a923

Please sign in to comment.