mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Raise HomeAssistantError/ValueError for service calls in Honeywell (#100041)
This commit is contained in:
parent
d56ad14673
commit
59e87c0864
@ -27,6 +27,7 @@ from homeassistant.components.climate import (
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
@ -315,6 +316,9 @@ class HoneywellUSThermostat(ClimateEntity):
|
||||
|
||||
except SomeComfortError as err:
|
||||
_LOGGER.error("Invalid temperature %.1f: %s", temperature, err)
|
||||
raise ValueError(
|
||||
f"Honeywell set temperature failed: invalid temperature {temperature}."
|
||||
) from err
|
||||
|
||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set new target temperature."""
|
||||
@ -328,14 +332,23 @@ class HoneywellUSThermostat(ClimateEntity):
|
||||
|
||||
except SomeComfortError as err:
|
||||
_LOGGER.error("Invalid temperature %.1f: %s", temperature, err)
|
||||
raise ValueError(
|
||||
f"Honeywell set temperature failed: invalid temperature: {temperature}."
|
||||
) from err
|
||||
|
||||
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
||||
"""Set new target fan mode."""
|
||||
await self._device.set_fan_mode(self._fan_mode_map[fan_mode])
|
||||
try:
|
||||
await self._device.set_fan_mode(self._fan_mode_map[fan_mode])
|
||||
except SomeComfortError as err:
|
||||
raise HomeAssistantError("Honeywell could not set fan mode.") from err
|
||||
|
||||
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||
"""Set new target hvac mode."""
|
||||
await self._device.set_system_mode(self._hvac_mode_map[hvac_mode])
|
||||
try:
|
||||
await self._device.set_system_mode(self._hvac_mode_map[hvac_mode])
|
||||
except SomeComfortError as err:
|
||||
raise HomeAssistantError("Honeywell could not set system mode.") from err
|
||||
|
||||
async def _turn_away_mode_on(self) -> None:
|
||||
"""Turn away on.
|
||||
@ -355,13 +368,16 @@ class HoneywellUSThermostat(ClimateEntity):
|
||||
if mode in HEATING_MODES:
|
||||
await self._device.set_hold_heat(True, self._heat_away_temp)
|
||||
|
||||
except SomeComfortError:
|
||||
except SomeComfortError as err:
|
||||
_LOGGER.error(
|
||||
"Temperature out of range. Mode: %s, Heat Temperature: %.1f, Cool Temperature: %.1f",
|
||||
mode,
|
||||
self._heat_away_temp,
|
||||
self._cool_away_temp,
|
||||
)
|
||||
raise ValueError(
|
||||
f"Honeywell set temperature failed: temperature out of range. Mode: {mode}, Heat Temperuature: {self._heat_away_temp}, Cool Temperature: {self._cool_away_temp}."
|
||||
) from err
|
||||
|
||||
async def _turn_hold_mode_on(self) -> None:
|
||||
"""Turn permanent hold on."""
|
||||
@ -376,10 +392,14 @@ class HoneywellUSThermostat(ClimateEntity):
|
||||
if mode in HEATING_MODES:
|
||||
await self._device.set_hold_heat(True)
|
||||
|
||||
except SomeComfortError:
|
||||
except SomeComfortError as err:
|
||||
_LOGGER.error("Couldn't set permanent hold")
|
||||
raise HomeAssistantError(
|
||||
"Honeywell couldn't set permanent hold."
|
||||
) from err
|
||||
else:
|
||||
_LOGGER.error("Invalid system mode returned: %s", mode)
|
||||
raise HomeAssistantError(f"Honeywell invalid system mode returned {mode}.")
|
||||
|
||||
async def _turn_away_mode_off(self) -> None:
|
||||
"""Turn away/hold off."""
|
||||
@ -388,8 +408,9 @@ class HoneywellUSThermostat(ClimateEntity):
|
||||
# Disabling all hold modes
|
||||
await self._device.set_hold_cool(False)
|
||||
await self._device.set_hold_heat(False)
|
||||
except SomeComfortError:
|
||||
except SomeComfortError as err:
|
||||
_LOGGER.error("Can not stop hold mode")
|
||||
raise HomeAssistantError("Honeywell could not stop hold mode") from err
|
||||
|
||||
async def async_set_preset_mode(self, preset_mode: str) -> None:
|
||||
"""Set new preset mode."""
|
||||
@ -403,14 +424,22 @@ class HoneywellUSThermostat(ClimateEntity):
|
||||
|
||||
async def async_turn_aux_heat_on(self) -> None:
|
||||
"""Turn auxiliary heater on."""
|
||||
await self._device.set_system_mode("emheat")
|
||||
try:
|
||||
await self._device.set_system_mode("emheat")
|
||||
except SomeComfortError as err:
|
||||
raise HomeAssistantError(
|
||||
"Honeywell could not set system mode to aux heat."
|
||||
) from err
|
||||
|
||||
async def async_turn_aux_heat_off(self) -> None:
|
||||
"""Turn auxiliary heater off."""
|
||||
if HVACMode.HEAT in self.hvac_modes:
|
||||
await self.async_set_hvac_mode(HVACMode.HEAT)
|
||||
else:
|
||||
await self.async_set_hvac_mode(HVACMode.OFF)
|
||||
try:
|
||||
if HVACMode.HEAT in self.hvac_modes:
|
||||
await self.async_set_hvac_mode(HVACMode.HEAT)
|
||||
else:
|
||||
await self.async_set_hvac_mode(HVACMode.OFF)
|
||||
except HomeAssistantError as err:
|
||||
raise HomeAssistantError("Honeywell could turn off aux heat mode.") from err
|
||||
|
||||
async def async_update(self) -> None:
|
||||
"""Get the latest state from the service."""
|
||||
|
@ -37,6 +37,7 @@ from homeassistant.const import (
|
||||
STATE_UNAVAILABLE,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
@ -193,6 +194,15 @@ async def test_mode_service_calls(
|
||||
device.set_system_mode.assert_called_once_with("auto")
|
||||
|
||||
device.set_system_mode.reset_mock()
|
||||
device.set_system_mode.side_effect = aiosomecomfort.SomeComfortError
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_HVAC_MODE: HVACMode.HEAT_COOL},
|
||||
blocking=True,
|
||||
)
|
||||
device.set_system_mode.assert_called_once_with("auto")
|
||||
|
||||
|
||||
async def test_auxheat_service_calls(
|
||||
@ -211,6 +221,7 @@ async def test_auxheat_service_calls(
|
||||
device.set_system_mode.assert_called_once_with("emheat")
|
||||
|
||||
device.set_system_mode.reset_mock()
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_AUX_HEAT,
|
||||
@ -219,6 +230,27 @@ async def test_auxheat_service_calls(
|
||||
)
|
||||
device.set_system_mode.assert_called_once_with("heat")
|
||||
|
||||
device.set_system_mode.reset_mock()
|
||||
device.set_system_mode.side_effect = aiosomecomfort.SomeComfortError
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_AUX_HEAT,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_AUX_HEAT: True},
|
||||
blocking=True,
|
||||
)
|
||||
device.set_system_mode.assert_called_once_with("emheat")
|
||||
|
||||
device.set_system_mode.reset_mock()
|
||||
device.set_system_mode.side_effect = aiosomecomfort.SomeComfortError
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_AUX_HEAT,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_AUX_HEAT: False},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
|
||||
async def test_fan_modes_service_calls(
|
||||
hass: HomeAssistant, device: MagicMock, config_entry: MagicMock
|
||||
@ -256,6 +288,17 @@ async def test_fan_modes_service_calls(
|
||||
|
||||
device.set_fan_mode.assert_called_once_with("circulate")
|
||||
|
||||
device.set_fan_mode.reset_mock()
|
||||
|
||||
device.set_fan_mode.side_effect = aiosomecomfort.SomeComfortError
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_FAN_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_FAN_MODE: FAN_DIFFUSE},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
|
||||
async def test_service_calls_off_mode(
|
||||
hass: HomeAssistant,
|
||||
@ -299,16 +342,18 @@ async def test_service_calls_off_mode(
|
||||
device.set_setpoint_heat.reset_mock()
|
||||
device.set_setpoint_heat.side_effect = aiosomecomfort.SomeComfortError
|
||||
caplog.clear()
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{
|
||||
ATTR_ENTITY_ID: entity_id,
|
||||
ATTR_TARGET_TEMP_LOW: 25.0,
|
||||
ATTR_TARGET_TEMP_HIGH: 35.0,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{
|
||||
ATTR_ENTITY_ID: entity_id,
|
||||
ATTR_TARGET_TEMP_LOW: 25.0,
|
||||
ATTR_TARGET_TEMP_HIGH: 35.0,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
device.set_setpoint_cool.assert_called_with(95)
|
||||
device.set_setpoint_heat.assert_called_with(77)
|
||||
assert "Invalid temperature" in caplog.text
|
||||
@ -387,7 +432,6 @@ async def test_service_calls_off_mode(
|
||||
device.set_hold_heat.side_effect = aiosomecomfort.SomeComfortError
|
||||
device.raw_ui_data["StatusHeat"] = 2
|
||||
device.raw_ui_data["StatusCool"] = 2
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
@ -443,16 +487,18 @@ async def test_service_calls_cool_mode(
|
||||
caplog.clear()
|
||||
device.set_setpoint_cool.reset_mock()
|
||||
device.set_setpoint_cool.side_effect = aiosomecomfort.SomeComfortError
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{
|
||||
ATTR_ENTITY_ID: entity_id,
|
||||
ATTR_TARGET_TEMP_LOW: 25.0,
|
||||
ATTR_TARGET_TEMP_HIGH: 35.0,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{
|
||||
ATTR_ENTITY_ID: entity_id,
|
||||
ATTR_TARGET_TEMP_LOW: 25.0,
|
||||
ATTR_TARGET_TEMP_HIGH: 35.0,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
device.set_setpoint_cool.assert_called_with(95)
|
||||
device.set_setpoint_heat.assert_called_with(77)
|
||||
assert "Invalid temperature" in caplog.text
|
||||
@ -474,12 +520,13 @@ async def test_service_calls_cool_mode(
|
||||
device.set_hold_cool.side_effect = aiosomecomfort.SomeComfortError
|
||||
caplog.clear()
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_AWAY},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_AWAY},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_hold_cool.assert_called_once_with(True, 12)
|
||||
device.set_hold_heat.assert_not_called()
|
||||
@ -491,12 +538,13 @@ async def test_service_calls_cool_mode(
|
||||
device.raw_ui_data["StatusHeat"] = 2
|
||||
device.raw_ui_data["StatusCool"] = 2
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_hold_cool.assert_called_once_with(True)
|
||||
device.set_hold_heat.assert_not_called()
|
||||
@ -504,12 +552,13 @@ async def test_service_calls_cool_mode(
|
||||
device.hold_heat = True
|
||||
device.hold_cool = True
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_TEMPERATURE: "20"},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_TEMPERATURE: "20"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_setpoint_cool.assert_called_once()
|
||||
|
||||
@ -519,25 +568,25 @@ async def test_service_calls_cool_mode(
|
||||
device.raw_ui_data["StatusHeat"] = 2
|
||||
device.raw_ui_data["StatusCool"] = 2
|
||||
caplog.clear()
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
device.set_hold_cool.assert_called_once_with(True)
|
||||
device.set_hold_heat.assert_not_called()
|
||||
assert "Couldn't set permanent hold" in caplog.text
|
||||
|
||||
reset_mock(device)
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_NONE},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_NONE},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_hold_heat.assert_not_called()
|
||||
device.set_hold_cool.assert_called_once_with(False)
|
||||
@ -546,13 +595,13 @@ async def test_service_calls_cool_mode(
|
||||
caplog.clear()
|
||||
|
||||
device.set_hold_cool.side_effect = aiosomecomfort.SomeComfortError
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_NONE},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_NONE},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_hold_heat.assert_not_called()
|
||||
device.set_hold_cool.assert_called_once_with(False)
|
||||
@ -563,12 +612,13 @@ async def test_service_calls_cool_mode(
|
||||
device.raw_ui_data["StatusHeat"] = 2
|
||||
device.raw_ui_data["StatusCool"] = 2
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_hold_cool.assert_called_once_with(True)
|
||||
device.set_hold_heat.assert_not_called()
|
||||
@ -580,13 +630,13 @@ async def test_service_calls_cool_mode(
|
||||
|
||||
device.raw_ui_data["StatusHeat"] = 2
|
||||
device.raw_ui_data["StatusCool"] = 2
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_hold_cool.assert_called_once_with(True)
|
||||
device.set_hold_heat.assert_not_called()
|
||||
@ -599,12 +649,13 @@ async def test_service_calls_cool_mode(
|
||||
device.raw_ui_data["StatusCool"] = 2
|
||||
device.system_mode = "Junk"
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_hold_cool.assert_not_called()
|
||||
device.set_hold_heat.assert_not_called()
|
||||
@ -640,13 +691,13 @@ async def test_service_calls_heat_mode(
|
||||
device.set_hold_heat.reset_mock()
|
||||
|
||||
device.set_hold_heat.side_effect = aiosomecomfort.SomeComfortError
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_TEMPERATURE: 15},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_TEMPERATURE: 15},
|
||||
blocking=True,
|
||||
)
|
||||
device.set_hold_heat.assert_called_once_with(datetime.time(2, 30), 59)
|
||||
device.set_hold_heat.reset_mock()
|
||||
assert "Invalid temperature" in caplog.text
|
||||
@ -667,16 +718,17 @@ async def test_service_calls_heat_mode(
|
||||
|
||||
device.set_setpoint_heat.reset_mock()
|
||||
device.set_setpoint_heat.side_effect = aiosomecomfort.SomeComfortError
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{
|
||||
ATTR_ENTITY_ID: entity_id,
|
||||
ATTR_TARGET_TEMP_LOW: 25.0,
|
||||
ATTR_TARGET_TEMP_HIGH: 35.0,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{
|
||||
ATTR_ENTITY_ID: entity_id,
|
||||
ATTR_TARGET_TEMP_LOW: 25.0,
|
||||
ATTR_TARGET_TEMP_HIGH: 35.0,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
device.set_setpoint_cool.assert_called_with(95)
|
||||
device.set_setpoint_heat.assert_called_with(77)
|
||||
assert "Invalid temperature" in caplog.text
|
||||
@ -685,12 +737,13 @@ async def test_service_calls_heat_mode(
|
||||
device.raw_ui_data["StatusHeat"] = 2
|
||||
device.raw_ui_data["StatusCool"] = 2
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_hold_heat.assert_called_once_with(True)
|
||||
device.set_hold_cool.assert_not_called()
|
||||
@ -698,12 +751,13 @@ async def test_service_calls_heat_mode(
|
||||
device.hold_heat = True
|
||||
device.hold_cool = True
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_TEMPERATURE: "20"},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_TEMPERATURE: "20"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_setpoint_heat.assert_called_once()
|
||||
|
||||
@ -715,24 +769,26 @@ async def test_service_calls_heat_mode(
|
||||
device.raw_ui_data["StatusHeat"] = 2
|
||||
device.raw_ui_data["StatusCool"] = 2
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
device.set_hold_heat.assert_called_once_with(True)
|
||||
device.set_hold_cool.assert_not_called()
|
||||
assert "Couldn't set permanent hold" in caplog.text
|
||||
|
||||
reset_mock(device)
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_AWAY},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_AWAY},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_hold_heat.assert_called_once_with(True, 22)
|
||||
device.set_hold_cool.assert_not_called()
|
||||
@ -743,12 +799,13 @@ async def test_service_calls_heat_mode(
|
||||
|
||||
device.set_hold_heat.side_effect = aiosomecomfort.SomeComfortError
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_AWAY},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_AWAY},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_hold_heat.assert_called_once_with(True, 22)
|
||||
device.set_hold_cool.assert_not_called()
|
||||
@ -757,13 +814,13 @@ async def test_service_calls_heat_mode(
|
||||
|
||||
reset_mock(device)
|
||||
caplog.clear()
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_NONE},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_NONE},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_hold_heat.assert_called_once_with(False)
|
||||
device.set_hold_cool.assert_called_once_with(False)
|
||||
@ -771,13 +828,13 @@ async def test_service_calls_heat_mode(
|
||||
device.set_hold_heat.reset_mock()
|
||||
device.set_hold_cool.reset_mock()
|
||||
device.set_hold_heat.side_effect = aiosomecomfort.SomeComfortError
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_NONE},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_NONE},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_hold_heat.assert_called_once_with(False)
|
||||
assert "Can not stop hold mode" in caplog.text
|
||||
@ -786,12 +843,13 @@ async def test_service_calls_heat_mode(
|
||||
device.raw_ui_data["StatusHeat"] = 2
|
||||
device.raw_ui_data["StatusCool"] = 2
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_hold_heat.assert_called_once_with(True)
|
||||
device.set_hold_cool.assert_not_called()
|
||||
@ -802,12 +860,13 @@ async def test_service_calls_heat_mode(
|
||||
device.raw_ui_data["StatusHeat"] = 2
|
||||
device.raw_ui_data["StatusCool"] = 2
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_hold_heat.assert_called_once_with(True)
|
||||
device.set_hold_cool.assert_not_called()
|
||||
@ -863,13 +922,13 @@ async def test_service_calls_auto_mode(
|
||||
|
||||
device.set_hold_cool.side_effect = aiosomecomfort.SomeComfortError
|
||||
device.set_hold_heat.side_effect = aiosomecomfort.SomeComfortError
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_TEMPERATURE: 15},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_TEMPERATURE: 15},
|
||||
blocking=True,
|
||||
)
|
||||
device.set_setpoint_heat.assert_not_called()
|
||||
assert "Invalid temperature" in caplog.text
|
||||
|
||||
@ -878,16 +937,17 @@ async def test_service_calls_auto_mode(
|
||||
|
||||
device.set_setpoint_heat.side_effect = aiosomecomfort.SomeComfortError
|
||||
device.set_setpoint_cool.side_effect = aiosomecomfort.SomeComfortError
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{
|
||||
ATTR_ENTITY_ID: entity_id,
|
||||
ATTR_TARGET_TEMP_LOW: 25.0,
|
||||
ATTR_TARGET_TEMP_HIGH: 35.0,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{
|
||||
ATTR_ENTITY_ID: entity_id,
|
||||
ATTR_TARGET_TEMP_LOW: 25.0,
|
||||
ATTR_TARGET_TEMP_HIGH: 35.0,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
device.set_setpoint_heat.assert_not_called()
|
||||
assert "Invalid temperature" in caplog.text
|
||||
|
||||
@ -917,12 +977,13 @@ async def test_service_calls_auto_mode(
|
||||
device.raw_ui_data["StatusHeat"] = 2
|
||||
device.raw_ui_data["StatusCool"] = 2
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
device.set_hold_cool.assert_called_once_with(True)
|
||||
device.set_hold_heat.assert_called_once_with(True)
|
||||
assert "Couldn't set permanent hold" in caplog.text
|
||||
@ -931,12 +992,13 @@ async def test_service_calls_auto_mode(
|
||||
device.set_setpoint_heat.side_effect = None
|
||||
device.set_setpoint_cool.side_effect = None
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_AWAY},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_AWAY},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_hold_cool.assert_called_once_with(True, 12)
|
||||
device.set_hold_heat.assert_called_once_with(True, 22)
|
||||
@ -944,25 +1006,26 @@ async def test_service_calls_auto_mode(
|
||||
reset_mock(device)
|
||||
caplog.clear()
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_NONE},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_NONE},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_hold_heat.assert_called_once_with(False)
|
||||
device.set_hold_cool.assert_called_once_with(False)
|
||||
|
||||
reset_mock(device)
|
||||
device.set_hold_cool.side_effect = aiosomecomfort.SomeComfortError
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_NONE},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_NONE},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_hold_heat.assert_not_called()
|
||||
device.set_hold_cool.assert_called_once_with(False)
|
||||
@ -974,12 +1037,13 @@ async def test_service_calls_auto_mode(
|
||||
device.raw_ui_data["StatusHeat"] = 2
|
||||
device.raw_ui_data["StatusCool"] = 2
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_hold_cool.assert_called_once_with(True)
|
||||
device.set_hold_heat.assert_not_called()
|
||||
@ -990,12 +1054,13 @@ async def test_service_calls_auto_mode(
|
||||
device.raw_ui_data["StatusHeat"] = 2
|
||||
device.raw_ui_data["StatusCool"] = 2
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_PRESET_MODE: PRESET_HOLD},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
device.set_hold_cool.assert_called_once_with(True)
|
||||
device.set_hold_heat.assert_not_called()
|
||||
|
Loading…
x
Reference in New Issue
Block a user