mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Update nest climate to avoid duplicate set mode commands (#79445)
This commit is contained in:
parent
8a73795f50
commit
7b8b73f826
@ -320,6 +320,8 @@ class ThermostatEntity(ClimateEntity):
|
|||||||
"""Set new target preset mode."""
|
"""Set new target preset mode."""
|
||||||
if preset_mode not in self.preset_modes:
|
if preset_mode not in self.preset_modes:
|
||||||
raise ValueError(f"Unsupported preset_mode '{preset_mode}'")
|
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]
|
trait = self._device.traits[ThermostatEcoTrait.NAME]
|
||||||
try:
|
try:
|
||||||
await trait.set_mode(PRESET_INV_MODE_MAP[preset_mode])
|
await trait.set_mode(PRESET_INV_MODE_MAP[preset_mode])
|
||||||
|
@ -602,6 +602,29 @@ async def test_thermostat_set_eco_preset(
|
|||||||
"params": {"mode": "OFF"},
|
"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(
|
async def test_thermostat_set_cool(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user