Update nest climate to avoid duplicate set mode commands (#79445)
This commit is contained in:
parent
8a73795f50
commit
7b8b73f826
2 changed files with 25 additions and 0 deletions
|
@ -320,6 +320,8 @@ class ThermostatEntity(ClimateEntity):
|
|||
"""Set new target preset mode."""
|
||||
if preset_mode not in self.preset_modes:
|
||||
raise ValueError(f"Unsupported preset_mode '{preset_mode}'")
|
||||
if self.preset_mode == preset_mode: # API doesn't like duplicate preset modes
|
||||
return
|
||||
trait = self._device.traits[ThermostatEcoTrait.NAME]
|
||||
try:
|
||||
await trait.set_mode(PRESET_INV_MODE_MAP[preset_mode])
|
||||
|
|
|
@ -602,6 +602,29 @@ async def test_thermostat_set_eco_preset(
|
|||
"params": {"mode": "OFF"},
|
||||
}
|
||||
|
||||
# Simulate the mode changing
|
||||
await create_event(
|
||||
{
|
||||
"sdm.devices.traits.ThermostatEco": {
|
||||
"availableModes": ["HEAT", "COOL", "HEATCOOL", "OFF"],
|
||||
"mode": "OFF",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
auth.method = None
|
||||
auth.url = None
|
||||
auth.json = None
|
||||
|
||||
# Attempting to set the preset mode when already in that mode will
|
||||
# not send any messages to the API (it would otherwise fail)
|
||||
await common.async_set_preset_mode(hass, PRESET_NONE)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert auth.method is None
|
||||
assert auth.url is None
|
||||
assert auth.json is None
|
||||
|
||||
|
||||
async def test_thermostat_set_cool(
|
||||
hass: HomeAssistant,
|
||||
|
|
Loading…
Add table
Reference in a new issue