Catch unexpected response in Honeywell (#103169)

catch unexpected response
This commit is contained in:
mkmer 2023-11-01 10:41:41 -04:00 committed by GitHub
parent cef68ea33c
commit 4a93465e85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 0 deletions

View File

@ -353,6 +353,11 @@ class HoneywellUSThermostat(ClimateEntity):
if mode == "heat":
await self._device.set_setpoint_heat(temperature)
except UnexpectedResponse as err:
raise HomeAssistantError(
"Honeywell set temperature failed: Invalid Response"
) from err
except SomeComfortError as err:
_LOGGER.error("Invalid temperature %.1f: %s", temperature, err)
raise ValueError(
@ -369,6 +374,11 @@ class HoneywellUSThermostat(ClimateEntity):
if temperature := kwargs.get(ATTR_TARGET_TEMP_LOW):
await self._device.set_setpoint_heat(temperature)
except UnexpectedResponse as err:
raise HomeAssistantError(
"Honeywell set temperature failed: Invalid Response"
) from err
except SomeComfortError as err:
_LOGGER.error("Invalid temperature %.1f: %s", temperature, err)
raise ValueError(

View File

@ -358,7 +358,24 @@ async def test_service_calls_off_mode(
device.set_setpoint_heat.assert_called_with(77)
assert "Invalid temperature" in caplog.text
device.set_setpoint_heat.reset_mock()
device.set_setpoint_heat.side_effect = aiosomecomfort.UnexpectedResponse
caplog.clear()
with pytest.raises(HomeAssistantError):
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)
reset_mock(device)
await hass.services.async_call(
CLIMATE_DOMAIN,
@ -702,6 +719,17 @@ async def test_service_calls_heat_mode(
device.set_hold_heat.reset_mock()
assert "Invalid temperature" in caplog.text
device.set_hold_heat.side_effect = aiosomecomfort.UnexpectedResponse
with pytest.raises(HomeAssistantError):
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()
caplog.clear()
await hass.services.async_call(
CLIMATE_DOMAIN,