Allow to change MQTT climate hold mode (#28988)
This commit is contained in:
parent
5f4fc271d4
commit
4881bc04d8
2 changed files with 27 additions and 5 deletions
|
@ -23,6 +23,7 @@ from homeassistant.components.climate.const import (
|
|||
HVAC_MODE_FAN_ONLY,
|
||||
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
||||
PRESET_NONE,
|
||||
PRESET_ECO,
|
||||
)
|
||||
from homeassistant.components.mqtt.discovery import async_start
|
||||
from homeassistant.const import STATE_OFF, STATE_UNAVAILABLE
|
||||
|
@ -446,6 +447,19 @@ async def test_set_away_mode(hass, mqtt_mock):
|
|||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get("preset_mode") is None
|
||||
|
||||
await common.async_set_preset_mode(hass, "hold-on", ENTITY_CLIMATE)
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
|
||||
await common.async_set_preset_mode(hass, "away", ENTITY_CLIMATE)
|
||||
mqtt_mock.async_publish.assert_has_calls(
|
||||
[
|
||||
unittest.mock.call("hold-topic", "off", 0, False),
|
||||
unittest.mock.call("away-mode-topic", "AN", 0, False),
|
||||
]
|
||||
)
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get("preset_mode") == "away"
|
||||
|
||||
|
||||
async def test_set_hvac_action(hass, mqtt_mock):
|
||||
"""Test setting of the HVAC action."""
|
||||
|
@ -495,6 +509,12 @@ async def test_set_hold(hass, mqtt_mock):
|
|||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get("preset_mode") == "hold-on"
|
||||
|
||||
await common.async_set_preset_mode(hass, PRESET_ECO, ENTITY_CLIMATE)
|
||||
mqtt_mock.async_publish.assert_called_once_with("hold-topic", "eco", 0, False)
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get("preset_mode") == PRESET_ECO
|
||||
|
||||
await common.async_set_preset_mode(hass, PRESET_NONE, ENTITY_CLIMATE)
|
||||
mqtt_mock.async_publish.assert_called_once_with("hold-topic", "off", 0, False)
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue