Avoid Nest climate set_temperature eating error (#86920)
* Update climate_sdm.py * Update test case to detect KeyError * Throw a defined exception if the condition in encoutered Include keys from device_traits in error message * Less diagnostic information in error messagepull/86960/head
parent
2c12171e25
commit
d22e670334
|
@ -304,7 +304,9 @@ class ThermostatEntity(ClimateEntity):
|
|||
high_temp = kwargs.get(ATTR_TARGET_TEMP_HIGH)
|
||||
temp = kwargs.get(ATTR_TEMPERATURE)
|
||||
if ThermostatTemperatureSetpointTrait.NAME not in self._device.traits:
|
||||
return
|
||||
raise HomeAssistantError(
|
||||
f"Error setting {self.entity_id} temperature to {kwargs}: Unable to find setpoint trait."
|
||||
)
|
||||
trait = self._device.traits[ThermostatTemperatureSetpointTrait.NAME]
|
||||
try:
|
||||
if self.preset_mode == PRESET_ECO or hvac_mode == HVACMode.HEAT_COOL:
|
||||
|
|
|
@ -1259,8 +1259,12 @@ async def test_thermostat_missing_temperature_trait(
|
|||
assert ATTR_FAN_MODE not in thermostat.attributes
|
||||
assert ATTR_FAN_MODES not in thermostat.attributes
|
||||
|
||||
await common.async_set_temperature(hass, temperature=24.0)
|
||||
with pytest.raises(HomeAssistantError) as e_info:
|
||||
await common.async_set_temperature(hass, temperature=24.0)
|
||||
await hass.async_block_till_done()
|
||||
assert "temperature" in str(e_info)
|
||||
assert "climate.my_thermostat" in str(e_info)
|
||||
assert "24.0" in str(e_info)
|
||||
assert thermostat.attributes[ATTR_TEMPERATURE] is None
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue