diff --git a/homeassistant/components/home_connect/light.py b/homeassistant/components/home_connect/light.py index 97efc0413ab..e33017cd51f 100644 --- a/homeassistant/components/home_connect/light.py +++ b/homeassistant/components/home_connect/light.py @@ -16,7 +16,7 @@ from homeassistant.components.light import ( LightEntityDescription, ) from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ServiceValidationError +from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.entity_platform import AddEntitiesCallback import homeassistant.util.color as color_util @@ -150,7 +150,7 @@ class HomeConnectLight(HomeConnectEntity, LightEntity): self.device.appliance.set_setting, self.bsh_key, True ) except HomeConnectError as err: - raise ServiceValidationError( + raise HomeAssistantError( translation_domain=DOMAIN, translation_key="turn_on_light", translation_placeholders={ @@ -169,7 +169,7 @@ class HomeConnectLight(HomeConnectEntity, LightEntity): self._enable_custom_color_value_key, ) except HomeConnectError as err: - raise ServiceValidationError( + raise HomeAssistantError( translation_domain=DOMAIN, translation_key="select_light_custom_color", translation_placeholders={ @@ -187,7 +187,7 @@ class HomeConnectLight(HomeConnectEntity, LightEntity): f"#{hex_val}", ) except HomeConnectError as err: - raise ServiceValidationError( + raise HomeAssistantError( translation_domain=DOMAIN, translation_key="set_light_color", translation_placeholders={ @@ -219,7 +219,7 @@ class HomeConnectLight(HomeConnectEntity, LightEntity): f"#{hex_val}", ) except HomeConnectError as err: - raise ServiceValidationError( + raise HomeAssistantError( translation_domain=DOMAIN, translation_key="set_light_color", translation_placeholders={ @@ -244,7 +244,7 @@ class HomeConnectLight(HomeConnectEntity, LightEntity): self.device.appliance.set_setting, self._brightness_key, brightness ) except HomeConnectError as err: - raise ServiceValidationError( + raise HomeAssistantError( translation_domain=DOMAIN, translation_key="set_light_brightness", translation_placeholders={ @@ -263,7 +263,7 @@ class HomeConnectLight(HomeConnectEntity, LightEntity): self.device.appliance.set_setting, self.bsh_key, False ) except HomeConnectError as err: - raise ServiceValidationError( + raise HomeAssistantError( translation_domain=DOMAIN, translation_key="turn_off_light", translation_placeholders={ diff --git a/homeassistant/components/home_connect/number.py b/homeassistant/components/home_connect/number.py index d1063a2026f..fc53939b9d8 100644 --- a/homeassistant/components/home_connect/number.py +++ b/homeassistant/components/home_connect/number.py @@ -12,7 +12,7 @@ from homeassistant.components.number import ( NumberEntityDescription, ) from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ServiceValidationError +from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import HomeConnectConfigEntry, get_dict_from_home_connect_error @@ -117,7 +117,7 @@ class HomeConnectNumberEntity(HomeConnectEntity, NumberEntity): value, ) except HomeConnectError as err: - raise ServiceValidationError( + raise HomeAssistantError( translation_domain=DOMAIN, translation_key="set_setting", translation_placeholders={ diff --git a/homeassistant/components/home_connect/select.py b/homeassistant/components/home_connect/select.py index fdd1f38bf97..46b2bda24d6 100644 --- a/homeassistant/components/home_connect/select.py +++ b/homeassistant/components/home_connect/select.py @@ -7,7 +7,7 @@ from homeconnect.api import HomeConnectError from homeassistant.components.select import SelectEntity, SelectEntityDescription from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ServiceValidationError +from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import ( @@ -289,7 +289,7 @@ class HomeConnectProgramSelectEntity(HomeConnectEntity, SelectEntity): translation_key = "start_program" else: translation_key = "select_program" - raise ServiceValidationError( + raise HomeAssistantError( translation_domain=DOMAIN, translation_key=translation_key, translation_placeholders={ diff --git a/homeassistant/components/home_connect/strings.json b/homeassistant/components/home_connect/strings.json index f9524763020..5f5ed3cee54 100644 --- a/homeassistant/components/home_connect/strings.json +++ b/homeassistant/components/home_connect/strings.json @@ -23,43 +23,43 @@ }, "exceptions": { "turn_on_light": { - "message": "Error while trying to turn on {entity_id}: {description}" + "message": "Error turning on {entity_id}: {description}" }, "turn_off_light": { - "message": "Error while trying to turn off {entity_id}: {description}" + "message": "Error turning off {entity_id}: {description}" }, "set_light_brightness": { - "message": "Error while trying to set brightness of {entity_id}: {description}" + "message": "Error setting brightness of {entity_id}: {description}" }, "select_light_custom_color": { - "message": "Error while trying to select custom color of {entity_id}: {description}" + "message": "Error selecting custom color of {entity_id}: {description}" }, "set_light_color": { - "message": "Error while trying to set color of {entity_id}: {description}" + "message": "Error setting color of {entity_id}: {description}" }, "set_setting": { - "message": "Error while trying to assign the value \"{value}\" to the setting \"{setting_key}\" for {entity_id}: {description}" + "message": "Error assigning the value \"{value}\" to the setting \"{setting_key}\" for {entity_id}: {description}" }, "turn_on": { - "message": "Error while trying to turn on {entity_id} ({setting_key}): {description}" + "message": "Error turning on {entity_id} ({setting_key}): {description}" }, "turn_off": { - "message": "Error while trying to turn off {entity_id} ({setting_key}): {description}" + "message": "Error turning off {entity_id} ({setting_key}): {description}" }, "select_program": { - "message": "Error while trying to select program {program}: {description}" + "message": "Error selecting program {program}: {description}" }, "start_program": { - "message": "Error while trying to start program {program}: {description}" + "message": "Error starting program {program}: {description}" }, "stop_program": { - "message": "Error while trying to stop program {program}: {description}" + "message": "Error stopping program {program}: {description}" }, "power_on": { - "message": "Error while trying to turn on {appliance_name}: {description}" + "message": "Error turning on {appliance_name}: {description}" }, "power_off": { - "message": "Error while trying to turn off {appliance_name} with value \"{value}\": {description}" + "message": "Error turning off {appliance_name} with value \"{value}\": {description}" }, "turn_off_not_supported": { "message": "{appliance_name} does not support turning off or entering standby mode." diff --git a/homeassistant/components/home_connect/switch.py b/homeassistant/components/home_connect/switch.py index 2fe3ff0a010..7e3a285912b 100644 --- a/homeassistant/components/home_connect/switch.py +++ b/homeassistant/components/home_connect/switch.py @@ -8,7 +8,7 @@ from homeconnect.api import HomeConnectError from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ServiceValidationError +from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import HomeConnectConfigEntry, get_dict_from_home_connect_error @@ -134,7 +134,7 @@ class HomeConnectSwitch(HomeConnectEntity, SwitchEntity): ) except HomeConnectError as err: self._attr_available = False - raise ServiceValidationError( + raise HomeAssistantError( translation_domain=DOMAIN, translation_key="turn_on", translation_placeholders={ @@ -158,7 +158,7 @@ class HomeConnectSwitch(HomeConnectEntity, SwitchEntity): except HomeConnectError as err: _LOGGER.error("Error while trying to turn off: %s", err) self._attr_available = False - raise ServiceValidationError( + raise HomeAssistantError( translation_domain=DOMAIN, translation_key="turn_off", translation_placeholders={ @@ -209,7 +209,7 @@ class HomeConnectProgramSwitch(HomeConnectEntity, SwitchEntity): self.device.appliance.start_program, self.program_name ) except HomeConnectError as err: - raise ServiceValidationError( + raise HomeAssistantError( translation_domain=DOMAIN, translation_key="start_program", translation_placeholders={ @@ -225,7 +225,7 @@ class HomeConnectProgramSwitch(HomeConnectEntity, SwitchEntity): try: await self.hass.async_add_executor_job(self.device.appliance.stop_program) except HomeConnectError as err: - raise ServiceValidationError( + raise HomeAssistantError( translation_domain=DOMAIN, translation_key="stop_program", translation_placeholders={ @@ -278,7 +278,7 @@ class HomeConnectPowerSwitch(HomeConnectEntity, SwitchEntity): ) except HomeConnectError as err: self._attr_is_on = False - raise ServiceValidationError( + raise HomeAssistantError( translation_domain=DOMAIN, translation_key="power_on", translation_placeholders={ @@ -291,7 +291,7 @@ class HomeConnectPowerSwitch(HomeConnectEntity, SwitchEntity): async def async_turn_off(self, **kwargs: Any) -> None: """Switch the device off.""" if not hasattr(self, "power_off_state"): - raise ServiceValidationError( + raise HomeAssistantError( translation_domain=DOMAIN, translation_key="unable_to_retrieve_turn_off", translation_placeholders={ @@ -300,7 +300,7 @@ class HomeConnectPowerSwitch(HomeConnectEntity, SwitchEntity): ) if self.power_off_state is None: - raise ServiceValidationError( + raise HomeAssistantError( translation_domain=DOMAIN, translation_key="turn_off_not_supported", translation_placeholders={ @@ -316,7 +316,7 @@ class HomeConnectPowerSwitch(HomeConnectEntity, SwitchEntity): ) except HomeConnectError as err: self._attr_is_on = True - raise ServiceValidationError( + raise HomeAssistantError( translation_domain=DOMAIN, translation_key="power_off", translation_placeholders={ diff --git a/homeassistant/components/home_connect/time.py b/homeassistant/components/home_connect/time.py index f28339b3595..cad16d63cb2 100644 --- a/homeassistant/components/home_connect/time.py +++ b/homeassistant/components/home_connect/time.py @@ -7,7 +7,7 @@ from homeconnect.api import HomeConnectError from homeassistant.components.time import TimeEntity, TimeEntityDescription from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ServiceValidationError +from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import HomeConnectConfigEntry, get_dict_from_home_connect_error @@ -80,7 +80,7 @@ class HomeConnectTimeEntity(HomeConnectEntity, TimeEntity): time_to_seconds(value), ) except HomeConnectError as err: - raise ServiceValidationError( + raise HomeAssistantError( translation_domain=DOMAIN, translation_key="set_setting", translation_placeholders={ diff --git a/tests/components/home_connect/test_light.py b/tests/components/home_connect/test_light.py index 7a9747929c9..471ddf0ec54 100644 --- a/tests/components/home_connect/test_light.py +++ b/tests/components/home_connect/test_light.py @@ -27,7 +27,7 @@ from homeassistant.const import ( Platform, ) from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ServiceValidationError +from homeassistant.exceptions import HomeAssistantError from .conftest import get_all_appliances @@ -341,7 +341,7 @@ async def test_switch_exception_handling( problematic_appliance.status.update(status) service_data["entity_id"] = entity_id - with pytest.raises(ServiceValidationError, match=exception_match): + with pytest.raises(HomeAssistantError, match=exception_match): await hass.services.async_call( LIGHT_DOMAIN, service, service_data, blocking=True ) diff --git a/tests/components/home_connect/test_number.py b/tests/components/home_connect/test_number.py index f70e307cb41..bce19161cf8 100644 --- a/tests/components/home_connect/test_number.py +++ b/tests/components/home_connect/test_number.py @@ -24,7 +24,7 @@ from homeassistant.components.number import ( from homeassistant.config_entries import ConfigEntryState from homeassistant.const import ATTR_ENTITY_ID, Platform from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ServiceValidationError +from homeassistant.exceptions import HomeAssistantError from .conftest import get_all_appliances @@ -162,7 +162,7 @@ async def test_number_entity_error( getattr(problematic_appliance, mock_attr)() with pytest.raises( - ServiceValidationError, match=r"Error.*assign.*value.*to.*setting.*" + HomeAssistantError, match=r"Error.*assign.*value.*to.*setting.*" ): await hass.services.async_call( NUMBER_DOMAIN, diff --git a/tests/components/home_connect/test_select.py b/tests/components/home_connect/test_select.py index 5939d256e0a..7d5843e9525 100644 --- a/tests/components/home_connect/test_select.py +++ b/tests/components/home_connect/test_select.py @@ -14,7 +14,7 @@ from homeassistant.components.select import ATTR_OPTION, DOMAIN as SELECT_DOMAIN from homeassistant.config_entries import ConfigEntryState from homeassistant.const import ATTR_ENTITY_ID, SERVICE_SELECT_OPTION, Platform from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ServiceValidationError +from homeassistant.exceptions import HomeAssistantError from .conftest import get_all_appliances @@ -151,7 +151,7 @@ async def test_select_exception_handling( getattr(problematic_appliance, mock_attr)() problematic_appliance.status.update(status) - with pytest.raises(ServiceValidationError, match=exception_match): + with pytest.raises(HomeAssistantError, match=exception_match): await hass.services.async_call( SELECT_DOMAIN, SERVICE_SELECT_OPTION, diff --git a/tests/components/home_connect/test_switch.py b/tests/components/home_connect/test_switch.py index e4f45fbcdf9..3a89005dc59 100644 --- a/tests/components/home_connect/test_switch.py +++ b/tests/components/home_connect/test_switch.py @@ -29,7 +29,7 @@ from homeassistant.const import ( Platform, ) from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ServiceValidationError +from homeassistant.exceptions import HomeAssistantError from .conftest import get_all_appliances @@ -219,7 +219,7 @@ async def test_switch_exception_handling( with pytest.raises(HomeConnectError): getattr(problematic_appliance, mock_attr)() - with pytest.raises(ServiceValidationError, match=exception_match): + with pytest.raises(HomeAssistantError, match=exception_match): await hass.services.async_call( SWITCH_DOMAIN, service, {"entity_id": entity_id}, blocking=True ) @@ -344,7 +344,7 @@ async def test_ent_desc_switch_exception_handling( getattr(problematic_appliance, mock_attr)() problematic_appliance.status.update(status) - with pytest.raises(ServiceValidationError, match=exception_match): + with pytest.raises(HomeAssistantError, match=exception_match): await hass.services.async_call( SWITCH_DOMAIN, service, {ATTR_ENTITY_ID: entity_id}, blocking=True ) @@ -502,7 +502,7 @@ async def test_power_switch_service_validation_errors( appliance.status.update({BSH_POWER_STATE: {"value": BSH_POWER_ON}}) - with pytest.raises(ServiceValidationError, match=exception_match): + with pytest.raises(HomeAssistantError, match=exception_match): await hass.services.async_call( SWITCH_DOMAIN, service, {"entity_id": entity_id}, blocking=True ) diff --git a/tests/components/home_connect/test_time.py b/tests/components/home_connect/test_time.py index 25ce39786a5..1401e07b05a 100644 --- a/tests/components/home_connect/test_time.py +++ b/tests/components/home_connect/test_time.py @@ -12,7 +12,7 @@ from homeassistant.components.time import DOMAIN as TIME_DOMAIN, SERVICE_SET_VAL from homeassistant.config_entries import ConfigEntryState from homeassistant.const import ATTR_ENTITY_ID, ATTR_TIME, Platform from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ServiceValidationError +from homeassistant.exceptions import HomeAssistantError from .conftest import get_all_appliances @@ -136,7 +136,7 @@ async def test_time_entity_error( getattr(problematic_appliance, mock_attr)() with pytest.raises( - ServiceValidationError, match=r"Error.*assign.*value.*to.*setting.*" + HomeAssistantError, match=r"Error.*assign.*value.*to.*setting.*" ): await hass.services.async_call( TIME_DOMAIN,