From df9a9f8ba36095fb74a050ca6a9e40bb2f3cccfd Mon Sep 17 00:00:00 2001 From: treetip Date: Sat, 7 Sep 2024 14:09:13 +0300 Subject: [PATCH] Translate profile names for service --- homeassistant/components/vallox/__init__.py | 6 +++--- homeassistant/components/vallox/const.py | 8 ++++++++ homeassistant/components/vallox/services.yaml | 11 +++++----- homeassistant/components/vallox/strings.json | 11 ++++++++++ tests/components/vallox/test_init.py | 20 +++++++++---------- 5 files changed, 38 insertions(+), 18 deletions(-) diff --git a/homeassistant/components/vallox/__init__.py b/homeassistant/components/vallox/__init__.py index 3a9ffb6381070..09080f1a5f621 100644 --- a/homeassistant/components/vallox/__init__.py +++ b/homeassistant/components/vallox/__init__.py @@ -22,7 +22,7 @@ DEFAULT_FAN_SPEED_HOME, DEFAULT_NAME, DOMAIN, - PRESET_MODE_TO_VALLOX_PROFILE, + I18N_KEY_TO_VALLOX_PROFILE, ) from .coordinator import ValloxDataUpdateCoordinator @@ -67,7 +67,7 @@ SERVICE_SCHEMA_SET_PROFILE = vol.Schema( { - vol.Required(ATTR_PROFILE): vol.In(PRESET_MODE_TO_VALLOX_PROFILE), + vol.Required(ATTR_PROFILE): vol.In(I18N_KEY_TO_VALLOX_PROFILE), vol.Optional(ATTR_DURATION): vol.All( vol.Coerce(int), vol.Clamp(min=1, max=65535) ), @@ -207,7 +207,7 @@ async def async_set_profile( _LOGGER.debug("Activating profile %s for %s min", profile, duration) try: await self._client.set_profile( - PRESET_MODE_TO_VALLOX_PROFILE[profile], duration + I18N_KEY_TO_VALLOX_PROFILE[profile], duration ) except ValloxApiException as err: _LOGGER.error( diff --git a/homeassistant/components/vallox/const.py b/homeassistant/components/vallox/const.py index 97f6ca4189a8b..418f57a22c825 100644 --- a/homeassistant/components/vallox/const.py +++ b/homeassistant/components/vallox/const.py @@ -22,6 +22,14 @@ DEFAULT_FAN_SPEED_AWAY = 25 DEFAULT_FAN_SPEED_BOOST = 65 +I18N_KEY_TO_VALLOX_PROFILE = { + "home": VALLOX_PROFILE.HOME, + "away": VALLOX_PROFILE.AWAY, + "boost": VALLOX_PROFILE.BOOST, + "fireplace": VALLOX_PROFILE.FIREPLACE, + "extra": VALLOX_PROFILE.EXTRA, +} + VALLOX_PROFILE_TO_PRESET_MODE = { VALLOX_PROFILE.HOME: "Home", VALLOX_PROFILE.AWAY: "Away", diff --git a/homeassistant/components/vallox/services.yaml b/homeassistant/components/vallox/services.yaml index d690e738627ec..f2a55032b9314 100644 --- a/homeassistant/components/vallox/services.yaml +++ b/homeassistant/components/vallox/services.yaml @@ -34,12 +34,13 @@ set_profile: required: true selector: select: + translation_key: "profile" options: - - "Home" - - "Away" - - "Boost" - - "Fireplace" - - "Extra" + - "home" + - "away" + - "boost" + - "fireplace" + - "extra" duration: required: false selector: diff --git a/homeassistant/components/vallox/strings.json b/homeassistant/components/vallox/strings.json index 5dbec4773e13d..8a30ed4ad011a 100644 --- a/homeassistant/components/vallox/strings.json +++ b/homeassistant/components/vallox/strings.json @@ -148,5 +148,16 @@ } } } + }, + "selector": { + "profile": { + "options": { + "home": "Home", + "away": "Away", + "boost": "Boost", + "fireplace": "Fireplace", + "extra": "Extra" + } + } } } diff --git a/tests/components/vallox/test_init.py b/tests/components/vallox/test_init.py index 525e894d1c13c..ecff2ee7af925 100644 --- a/tests/components/vallox/test_init.py +++ b/tests/components/vallox/test_init.py @@ -55,16 +55,16 @@ async def test_create_service( @pytest.mark.parametrize( ("profile", "duration"), [ - ("Home", None), - ("Home", 15), - ("Away", None), - ("Away", 15), - ("Boost", None), - ("Boost", 15), - ("Fireplace", None), - ("Fireplace", 15), - ("Extra", None), - ("Extra", 15), + ("home", None), + ("home", 15), + ("away", None), + ("away", 15), + ("boost", None), + ("boost", 15), + ("fireplace", None), + ("fireplace", 15), + ("extra", None), + ("extra", 15), ], ) async def test_set_profile_service(