mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Airzone select improvements (#92894)
* airzone: select: remove unneed .keys() Fixes late comment when select platform was introduced. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> * airzone: select: make options translatable This was a late comment when the select platform was introduced. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> * airzone: select: change options to lists (from enums) Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> * tests: airzone: fix python 3.10 tests Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> * airzone: select: add manual dict values This was requested in order to keep control of the translation strings. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> * Revert "airzone: select: add manual dict values" This reverts commit b818a2674d6bdec7792fbb76e00b3a3a261d663b. * Revert "tests: airzone: fix python 3.10 tests" This reverts commit 93f8bd1430adece0a1296b4c44df8162437f82af. * Revert "airzone: select: change options to lists (from enums)" This reverts commit e503a1dd3abab2139220f44996afb6991aaa1ee9. * airzone: select: options: copy dict to list Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> * airzone: select: use degree symbol Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> --------- Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
This commit is contained in:
parent
869f970e59
commit
a29adc0a6a
@ -1,7 +1,7 @@
|
|||||||
"""Support for the Airzone sensors."""
|
"""Support for the Airzone sensors."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass, replace
|
from dataclasses import dataclass
|
||||||
from typing import Any, Final
|
from typing import Any, Final
|
||||||
|
|
||||||
from aioairzone.common import GrilleAngle, SleepTimeout
|
from aioairzone.common import GrilleAngle, SleepTimeout
|
||||||
@ -41,14 +41,14 @@ class AirzoneSelectDescription(SelectEntityDescription, AirzoneSelectDescription
|
|||||||
|
|
||||||
|
|
||||||
GRILLE_ANGLE_DICT: Final[dict[str, int]] = {
|
GRILLE_ANGLE_DICT: Final[dict[str, int]] = {
|
||||||
"90º": GrilleAngle.DEG_90,
|
"90deg": GrilleAngle.DEG_90,
|
||||||
"50º": GrilleAngle.DEG_50,
|
"50deg": GrilleAngle.DEG_50,
|
||||||
"45º": GrilleAngle.DEG_45,
|
"45deg": GrilleAngle.DEG_45,
|
||||||
"40º": GrilleAngle.DEG_40,
|
"40deg": GrilleAngle.DEG_40,
|
||||||
}
|
}
|
||||||
|
|
||||||
SLEEP_DICT: Final[dict[str, int]] = {
|
SLEEP_DICT: Final[dict[str, int]] = {
|
||||||
"Off": SleepTimeout.SLEEP_OFF,
|
"off": SleepTimeout.SLEEP_OFF,
|
||||||
"30m": SleepTimeout.SLEEP_30,
|
"30m": SleepTimeout.SLEEP_30,
|
||||||
"60m": SleepTimeout.SLEEP_60,
|
"60m": SleepTimeout.SLEEP_60,
|
||||||
"90m": SleepTimeout.SLEEP_90,
|
"90m": SleepTimeout.SLEEP_90,
|
||||||
@ -61,21 +61,27 @@ ZONE_SELECT_TYPES: Final[tuple[AirzoneSelectDescription, ...]] = (
|
|||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
key=AZD_COLD_ANGLE,
|
key=AZD_COLD_ANGLE,
|
||||||
name="Cold Angle",
|
name="Cold Angle",
|
||||||
|
options=list(GRILLE_ANGLE_DICT),
|
||||||
options_dict=GRILLE_ANGLE_DICT,
|
options_dict=GRILLE_ANGLE_DICT,
|
||||||
|
translation_key="grille_angles",
|
||||||
),
|
),
|
||||||
AirzoneSelectDescription(
|
AirzoneSelectDescription(
|
||||||
api_param=API_HEAT_ANGLE,
|
api_param=API_HEAT_ANGLE,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
key=AZD_HEAT_ANGLE,
|
key=AZD_HEAT_ANGLE,
|
||||||
name="Heat Angle",
|
name="Heat Angle",
|
||||||
|
options=list(GRILLE_ANGLE_DICT),
|
||||||
options_dict=GRILLE_ANGLE_DICT,
|
options_dict=GRILLE_ANGLE_DICT,
|
||||||
|
translation_key="grille_angles",
|
||||||
),
|
),
|
||||||
AirzoneSelectDescription(
|
AirzoneSelectDescription(
|
||||||
api_param=API_SLEEP,
|
api_param=API_SLEEP,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
key=AZD_SLEEP,
|
key=AZD_SLEEP,
|
||||||
name="Sleep",
|
name="Sleep",
|
||||||
|
options=list(SLEEP_DICT),
|
||||||
options_dict=SLEEP_DICT,
|
options_dict=SLEEP_DICT,
|
||||||
|
translation_key="sleep_times",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -91,14 +97,10 @@ async def async_setup_entry(
|
|||||||
for system_zone_id, zone_data in coordinator.data[AZD_ZONES].items():
|
for system_zone_id, zone_data in coordinator.data[AZD_ZONES].items():
|
||||||
for description in ZONE_SELECT_TYPES:
|
for description in ZONE_SELECT_TYPES:
|
||||||
if description.key in zone_data:
|
if description.key in zone_data:
|
||||||
_desc = replace(
|
|
||||||
description,
|
|
||||||
options=list(description.options_dict.keys()),
|
|
||||||
)
|
|
||||||
entities.append(
|
entities.append(
|
||||||
AirzoneZoneSelect(
|
AirzoneZoneSelect(
|
||||||
coordinator,
|
coordinator,
|
||||||
_desc,
|
description,
|
||||||
entry,
|
entry,
|
||||||
system_zone_id,
|
system_zone_id,
|
||||||
zone_data,
|
zone_data,
|
||||||
|
@ -23,5 +23,25 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"entity": {
|
||||||
|
"select": {
|
||||||
|
"grille_angles": {
|
||||||
|
"state": {
|
||||||
|
"90deg": "90°",
|
||||||
|
"50deg": "50°",
|
||||||
|
"45deg": "45°",
|
||||||
|
"40deg": "40°"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sleep_times": {
|
||||||
|
"state": {
|
||||||
|
"off": "[%key:common::state::off%]",
|
||||||
|
"30m": "30 minutes",
|
||||||
|
"60m": "60 minutes",
|
||||||
|
"90m": "90 minutes"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,49 +25,49 @@ async def test_airzone_create_selects(hass: HomeAssistant) -> None:
|
|||||||
await async_init_integration(hass)
|
await async_init_integration(hass)
|
||||||
|
|
||||||
state = hass.states.get("select.despacho_cold_angle")
|
state = hass.states.get("select.despacho_cold_angle")
|
||||||
assert state.state == "90º"
|
assert state.state == "90deg"
|
||||||
|
|
||||||
state = hass.states.get("select.despacho_heat_angle")
|
state = hass.states.get("select.despacho_heat_angle")
|
||||||
assert state.state == "90º"
|
assert state.state == "90deg"
|
||||||
|
|
||||||
state = hass.states.get("select.despacho_sleep")
|
state = hass.states.get("select.despacho_sleep")
|
||||||
assert state.state == "Off"
|
assert state.state == "off"
|
||||||
|
|
||||||
state = hass.states.get("select.dorm_1_cold_angle")
|
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")
|
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")
|
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")
|
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")
|
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")
|
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")
|
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")
|
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")
|
state = hass.states.get("select.dorm_ppal_sleep")
|
||||||
assert state.state == "30m"
|
assert state.state == "30m"
|
||||||
|
|
||||||
state = hass.states.get("select.salon_cold_angle")
|
state = hass.states.get("select.salon_cold_angle")
|
||||||
assert state.state == "90º"
|
assert state.state == "90deg"
|
||||||
|
|
||||||
state = hass.states.get("select.salon_heat_angle")
|
state = hass.states.get("select.salon_heat_angle")
|
||||||
assert state.state == "90º"
|
assert state.state == "90deg"
|
||||||
|
|
||||||
state = hass.states.get("select.salon_sleep")
|
state = hass.states.get("select.salon_sleep")
|
||||||
assert state.state == "Off"
|
assert state.state == "off"
|
||||||
|
|
||||||
|
|
||||||
async def test_airzone_select_sleep(hass: HomeAssistant) -> None:
|
async def test_airzone_select_sleep(hass: HomeAssistant) -> None:
|
||||||
@ -140,13 +140,13 @@ async def test_airzone_select_grille_angle(hass: HomeAssistant) -> None:
|
|||||||
SERVICE_SELECT_OPTION,
|
SERVICE_SELECT_OPTION,
|
||||||
{
|
{
|
||||||
ATTR_ENTITY_ID: "select.dorm_1_cold_angle",
|
ATTR_ENTITY_ID: "select.dorm_1_cold_angle",
|
||||||
ATTR_OPTION: "50º",
|
ATTR_OPTION: "50deg",
|
||||||
},
|
},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("select.dorm_1_cold_angle")
|
state = hass.states.get("select.dorm_1_cold_angle")
|
||||||
assert state.state == "50º"
|
assert state.state == "50deg"
|
||||||
|
|
||||||
# Heat Angle
|
# Heat Angle
|
||||||
|
|
||||||
@ -168,10 +168,10 @@ async def test_airzone_select_grille_angle(hass: HomeAssistant) -> None:
|
|||||||
SERVICE_SELECT_OPTION,
|
SERVICE_SELECT_OPTION,
|
||||||
{
|
{
|
||||||
ATTR_ENTITY_ID: "select.dorm_1_heat_angle",
|
ATTR_ENTITY_ID: "select.dorm_1_heat_angle",
|
||||||
ATTR_OPTION: "45º",
|
ATTR_OPTION: "45deg",
|
||||||
},
|
},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("select.dorm_1_heat_angle")
|
state = hass.states.get("select.dorm_1_heat_angle")
|
||||||
assert state.state == "45º"
|
assert state.state == "45deg"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user