diff --git a/homeassistant/components/huum/climate.py b/homeassistant/components/huum/climate.py index c3220d261e9..319f2475ba7 100644 --- a/homeassistant/components/huum/climate.py +++ b/homeassistant/components/huum/climate.py @@ -2,7 +2,6 @@ from __future__ import annotations -import logging from typing import Any from huum.const import SaunaStatus @@ -18,12 +17,10 @@ from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback -from .const import CONFIG_DEFAULT_MAX_TEMP, CONFIG_DEFAULT_MIN_TEMP +from .const import CONFIG_DEFAULT_MAX_TEMP, CONFIG_DEFAULT_MIN_TEMP, DOMAIN from .coordinator import HuumConfigEntry, HuumDataUpdateCoordinator from .entity import HuumBaseEntity -_LOGGER = logging.getLogger(__name__) - PARALLEL_UPDATES = 1 @@ -113,5 +110,7 @@ class HuumDevice(HuumBaseEntity, ClimateEntity): try: await self.coordinator.huum.turn_on(temperature) except (ValueError, SafetyException) as err: - _LOGGER.error(str(err)) - raise HomeAssistantError(f"Unable to turn on sauna: {err}") from err + raise HomeAssistantError( + translation_domain=DOMAIN, + translation_key="unable_to_turn_on", + ) from err diff --git a/homeassistant/components/huum/coordinator.py b/homeassistant/components/huum/coordinator.py index 532e78a8175..fac9f234ea8 100644 --- a/homeassistant/components/huum/coordinator.py +++ b/homeassistant/components/huum/coordinator.py @@ -56,5 +56,6 @@ class HuumDataUpdateCoordinator(DataUpdateCoordinator[HuumStatusResponse]): return await self.huum.status() except (Forbidden, NotAuthenticated) as err: raise ConfigEntryAuthFailed( - "Could not log in to Huum with given credentials" + translation_domain=DOMAIN, + translation_key="auth_failed", ) from err diff --git a/homeassistant/components/huum/quality_scale.yaml b/homeassistant/components/huum/quality_scale.yaml index b08f4c054de..fec8eea47a1 100644 --- a/homeassistant/components/huum/quality_scale.yaml +++ b/homeassistant/components/huum/quality_scale.yaml @@ -62,7 +62,7 @@ rules: status: exempt comment: All entities are core functionality. entity-translations: done - exception-translations: todo + exception-translations: done icon-translations: done reconfiguration-flow: todo repair-issues: diff --git a/homeassistant/components/huum/strings.json b/homeassistant/components/huum/strings.json index 9ad89b5daaf..8b50fcd5eee 100644 --- a/homeassistant/components/huum/strings.json +++ b/homeassistant/components/huum/strings.json @@ -45,5 +45,13 @@ "name": "[%key:component::sensor::entity_component::humidity::name%]" } } + }, + "exceptions": { + "auth_failed": { + "message": "Could not log in to Huum with the given credentials." + }, + "unable_to_turn_on": { + "message": "Unable to turn on the sauna." + } } } diff --git a/tests/components/huum/test_climate.py b/tests/components/huum/test_climate.py index 61be0f5b6b9..168a9004170 100644 --- a/tests/components/huum/test_climate.py +++ b/tests/components/huum/test_climate.py @@ -132,7 +132,7 @@ async def test_turn_on_safety_exception( mock_huum_client.turn_on.side_effect = SafetyException("Door is open") mock_huum_client.status.return_value.status = SaunaStatus.ONLINE_HEATING - with pytest.raises(HomeAssistantError, match="Unable to turn on sauna"): + with pytest.raises(HomeAssistantError, match="Unable to turn on the sauna"): await hass.services.async_call( CLIMATE_DOMAIN, SERVICE_SET_TEMPERATURE,