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 commitb818a2674d
. * Revert "tests: airzone: fix python 3.10 tests" This reverts commit93f8bd1430
. * Revert "airzone: select: change options to lists (from enums)" This reverts commite503a1dd3a
. * 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
3 changed files with 51 additions and 29 deletions
|
@ -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
|
||||
|
@ -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,
|
||||
"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,
|
||||
"30m": SleepTimeout.SLEEP_30,
|
||||
"60m": SleepTimeout.SLEEP_60,
|
||||
"90m": SleepTimeout.SLEEP_90,
|
||||
|
@ -61,21 +61,27 @@ ZONE_SELECT_TYPES: Final[tuple[AirzoneSelectDescription, ...]] = (
|
|||
entity_category=EntityCategory.CONFIG,
|
||||
key=AZD_COLD_ANGLE,
|
||||
name="Cold Angle",
|
||||
options=list(GRILLE_ANGLE_DICT),
|
||||
options_dict=GRILLE_ANGLE_DICT,
|
||||
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,
|
||||
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",
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
||||
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:
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"
|
||||
|
|
Loading…
Add table
Reference in a new issue