diff --git a/homeassistant/components/nibe_heatpump/climate.py b/homeassistant/components/nibe_heatpump/climate.py index 3a0a405d5b8..2bea3f2b9a4 100644 --- a/homeassistant/components/nibe_heatpump/climate.py +++ b/homeassistant/components/nibe_heatpump/climate.py @@ -26,6 +26,7 @@ from homeassistant.components.climate import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant, callback +from homeassistant.exceptions import ServiceValidationError from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import CoordinatorEntity @@ -219,9 +220,11 @@ class NibeClimateEntity(CoordinatorEntity[Coordinator], ClimateEntity): self._coil_setpoint_cool, temperature ) else: - raise ValueError(f"{hvac_mode} mode not supported for {self.name}") + raise ServiceValidationError( + f"{hvac_mode} mode not supported for {self.name}" + ) else: - raise ValueError( + raise ServiceValidationError( "'set_temperature' requires 'hvac_mode' when passing" " 'temperature' and 'hvac_mode' is not already set to" " 'heat' or 'cool'" @@ -256,4 +259,6 @@ class NibeClimateEntity(CoordinatorEntity[Coordinator], ClimateEntity): ) await coordinator.async_write_coil(self._coil_use_room_sensor, "OFF") else: - raise ValueError(f"{hvac_mode} mode not supported for {self.name}") + raise ServiceValidationError( + f"{hvac_mode} mode not supported for {self.name}" + ) diff --git a/tests/components/nibe_heatpump/test_climate.py b/tests/components/nibe_heatpump/test_climate.py index c845f0eac4b..010bd3d71b1 100644 --- a/tests/components/nibe_heatpump/test_climate.py +++ b/tests/components/nibe_heatpump/test_climate.py @@ -26,6 +26,7 @@ from homeassistant.components.climate import ( ) from homeassistant.const import ATTR_ENTITY_ID, Platform from homeassistant.core import HomeAssistant +from homeassistant.exceptions import ServiceValidationError from . import MockConnection, async_add_model @@ -196,7 +197,7 @@ async def test_set_temperature_supported_cooling( ] mock_connection.write_coil.reset_mock() - with pytest.raises(ValueError): + with pytest.raises(ServiceValidationError): await hass.services.async_call( PLATFORM_DOMAIN, SERVICE_SET_TEMPERATURE, @@ -268,8 +269,8 @@ async def test_set_temperature_unsupported_cooling( call(CoilData(coil_setpoint_heat, 22)) ] - # Attempt to set temperature to cool should raise ValueError - with pytest.raises(ValueError): + # Attempt to set temperature to cool should raise ServiceValidationError + with pytest.raises(ServiceValidationError): await hass.services.async_call( PLATFORM_DOMAIN, SERVICE_SET_TEMPERATURE, @@ -362,7 +363,7 @@ async def test_set_invalid_hvac_mode( _setup_climate_group(coils, model, climate_id) await async_add_model(hass, model) - with pytest.raises(ValueError): + with pytest.raises(ServiceValidationError): await hass.services.async_call( PLATFORM_DOMAIN, SERVICE_SET_HVAC_MODE,