Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Airzone select improvements #92894

Merged
merged 12 commits into from
May 24, 2023
24 changes: 13 additions & 11 deletions homeassistant/components/airzone/select.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Support for the Airzone sensors."""
from __future__ import annotations

from dataclasses import dataclass, replace
from dataclasses import dataclass
from typing import Any, Final

from aioairzone.common import GrilleAngle, SleepTimeout
Expand Down Expand Up @@ -41,14 +41,14 @@ class AirzoneSelectDescription(SelectEntityDescription, AirzoneSelectDescription


GRILLE_ANGLE_DICT: Final[dict[str, int]] = {
"90º": GrilleAngle.DEG_90,
"50º": GrilleAngle.DEG_50,
"45º": GrilleAngle.DEG_45,
"40º": GrilleAngle.DEG_40,
"90deg": GrilleAngle.DEG_90,
gjohansson-ST marked this conversation as resolved.
Show resolved Hide resolved
"50deg": GrilleAngle.DEG_50,
"45deg": GrilleAngle.DEG_45,
"40deg": GrilleAngle.DEG_40,
}

SLEEP_DICT: Final[dict[str, int]] = {
"Off": SleepTimeout.SLEEP_OFF,
"off": SleepTimeout.SLEEP_OFF,
gjohansson-ST marked this conversation as resolved.
Show resolved Hide resolved
"30m": SleepTimeout.SLEEP_30,
"60m": SleepTimeout.SLEEP_60,
"90m": SleepTimeout.SLEEP_90,
Expand All @@ -61,21 +61,27 @@ class AirzoneSelectDescription(SelectEntityDescription, AirzoneSelectDescription
entity_category=EntityCategory.CONFIG,
key=AZD_COLD_ANGLE,
name="Cold Angle",
options=list(GRILLE_ANGLE_DICT),
options_dict=GRILLE_ANGLE_DICT,
gjohansson-ST marked this conversation as resolved.
Show resolved Hide resolved
translation_key="grille_angles",
),
AirzoneSelectDescription(
api_param=API_HEAT_ANGLE,
entity_category=EntityCategory.CONFIG,
key=AZD_HEAT_ANGLE,
name="Heat Angle",
options=list(GRILLE_ANGLE_DICT),
options_dict=GRILLE_ANGLE_DICT,
gjohansson-ST marked this conversation as resolved.
Show resolved Hide resolved
translation_key="grille_angles",
),
AirzoneSelectDescription(
api_param=API_SLEEP,
entity_category=EntityCategory.CONFIG,
key=AZD_SLEEP,
name="Sleep",
options=list(SLEEP_DICT),
options_dict=SLEEP_DICT,
translation_key="sleep_times",
),
)

Expand All @@ -91,14 +97,10 @@ async def async_setup_entry(
for system_zone_id, zone_data in coordinator.data[AZD_ZONES].items():
for description in ZONE_SELECT_TYPES:
if description.key in zone_data:
_desc = replace(
description,
options=list(description.options_dict.keys()),
)
entities.append(
AirzoneZoneSelect(
coordinator,
_desc,
description,
entry,
system_zone_id,
zone_data,
Expand Down
20 changes: 20 additions & 0 deletions homeassistant/components/airzone/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,25 @@
}
}
}
},
"entity": {
"select": {
"grille_angles": {
"state": {
"90deg": "90º",
"50deg": "50º",
"45deg": "45º",
"40deg": "40º"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use the degree symbol here

Suggested change
"90deg": "90º",
"50deg": "50º",
"45deg": "45º",
"40deg": "40º"
"90deg": "90°",
"50deg": "50°",
"45deg": "45°",
"40deg": "40°"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 4087cde

}
},
"sleep_times": {
"state": {
"off": "[%key:common::state::off%]",
"30m": "30 minutes",
"60m": "60 minutes",
"90m": "90 minutes"
}
}
}
}
}
36 changes: 18 additions & 18 deletions tests/components/airzone/test_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,49 +25,49 @@ async def test_airzone_create_selects(hass: HomeAssistant) -> None:
await async_init_integration(hass)

state = hass.states.get("select.despacho_cold_angle")
assert state.state == "90º"
assert state.state == "90deg"

state = hass.states.get("select.despacho_heat_angle")
assert state.state == "90º"
assert state.state == "90deg"

state = hass.states.get("select.despacho_sleep")
assert state.state == "Off"
assert state.state == "off"

state = hass.states.get("select.dorm_1_cold_angle")
assert state.state == "90º"
assert state.state == "90deg"

state = hass.states.get("select.dorm_1_heat_angle")
assert state.state == "90º"
assert state.state == "90deg"

state = hass.states.get("select.dorm_1_sleep")
assert state.state == "Off"
assert state.state == "off"

state = hass.states.get("select.dorm_2_cold_angle")
assert state.state == "90º"
assert state.state == "90deg"

state = hass.states.get("select.dorm_2_heat_angle")
assert state.state == "90º"
assert state.state == "90deg"

state = hass.states.get("select.dorm_2_sleep")
assert state.state == "Off"
assert state.state == "off"

state = hass.states.get("select.dorm_ppal_cold_angle")
assert state.state == "45º"
assert state.state == "45deg"

state = hass.states.get("select.dorm_ppal_heat_angle")
assert state.state == "50º"
assert state.state == "50deg"

state = hass.states.get("select.dorm_ppal_sleep")
assert state.state == "30m"

state = hass.states.get("select.salon_cold_angle")
assert state.state == "90º"
assert state.state == "90deg"

state = hass.states.get("select.salon_heat_angle")
assert state.state == "90º"
assert state.state == "90deg"

state = hass.states.get("select.salon_sleep")
assert state.state == "Off"
assert state.state == "off"


async def test_airzone_select_sleep(hass: HomeAssistant) -> None:
Expand Down Expand Up @@ -140,13 +140,13 @@ async def test_airzone_select_grille_angle(hass: HomeAssistant) -> None:
SERVICE_SELECT_OPTION,
{
ATTR_ENTITY_ID: "select.dorm_1_cold_angle",
ATTR_OPTION: "50º",
ATTR_OPTION: "50deg",
},
blocking=True,
)

state = hass.states.get("select.dorm_1_cold_angle")
assert state.state == "50º"
assert state.state == "50deg"

# Heat Angle

Expand All @@ -168,10 +168,10 @@ async def test_airzone_select_grille_angle(hass: HomeAssistant) -> None:
SERVICE_SELECT_OPTION,
{
ATTR_ENTITY_ID: "select.dorm_1_heat_angle",
ATTR_OPTION: "45º",
ATTR_OPTION: "45deg",
},
blocking=True,
)

state = hass.states.get("select.dorm_1_heat_angle")
assert state.state == "45º"
assert state.state == "45deg"