Introduce PRESET_NONE for climate (#25360)

* Introduce PRESET_NONE for climate

* Require preset mode to be a string

* Lint

* Fix tests
This commit is contained in:
Paulus Schoutsen
2019-07-21 11:10:24 -07:00
parent 2228a0dcac
commit c795c93034
18 changed files with 44 additions and 38 deletions
@@ -9,7 +9,7 @@ import voluptuous as vol
from homeassistant.components import input_boolean, switch
from homeassistant.components.climate.const import (
ATTR_PRESET_MODE, DOMAIN, HVAC_MODE_COOL, HVAC_MODE_HEAT, HVAC_MODE_OFF,
PRESET_AWAY)
PRESET_AWAY, PRESET_NONE)
from homeassistant.const import (
ATTR_TEMPERATURE, SERVICE_TURN_OFF, SERVICE_TURN_ON, STATE_OFF, STATE_ON,
TEMP_CELSIUS, TEMP_FAHRENHEIT)
@@ -202,7 +202,7 @@ async def test_set_away_mode_and_restore_prev_temp(hass, setup_comp_2):
await common.async_set_preset_mode(hass, PRESET_AWAY)
state = hass.states.get(ENTITY)
assert 16 == state.attributes.get('temperature')
await common.async_set_preset_mode(hass, None)
await common.async_set_preset_mode(hass, PRESET_NONE)
state = hass.states.get(ENTITY)
assert 23 == state.attributes.get('temperature')
@@ -217,7 +217,7 @@ async def test_set_away_mode_twice_and_restore_prev_temp(hass, setup_comp_2):
await common.async_set_preset_mode(hass, PRESET_AWAY)
state = hass.states.get(ENTITY)
assert 16 == state.attributes.get('temperature')
await common.async_set_preset_mode(hass, None)
await common.async_set_preset_mode(hass, PRESET_NONE)
state = hass.states.get(ENTITY)
assert 23 == state.attributes.get('temperature')
+3 -3
View File
@@ -16,7 +16,7 @@ from homeassistant.components.climate.const import (
SUPPORT_FAN_MODE,
SUPPORT_SWING_MODE, SUPPORT_TARGET_TEMPERATURE, HVAC_MODE_AUTO,
HVAC_MODE_COOL, HVAC_MODE_HEAT, HVAC_MODE_DRY, HVAC_MODE_FAN_ONLY,
SUPPORT_TARGET_TEMPERATURE_RANGE)
SUPPORT_TARGET_TEMPERATURE_RANGE, PRESET_NONE)
from homeassistant.components.mqtt.discovery import async_start
from homeassistant.const import STATE_OFF, STATE_UNAVAILABLE
@@ -425,7 +425,7 @@ async def test_set_away_mode(hass, mqtt_mock):
state = hass.states.get(ENTITY_CLIMATE)
assert state.attributes.get('preset_mode') == 'away'
await common.async_set_preset_mode(hass, None, ENTITY_CLIMATE)
await common.async_set_preset_mode(hass, PRESET_NONE, ENTITY_CLIMATE)
mqtt_mock.async_publish.assert_called_once_with(
'away-mode-topic', 'AUS', 0, False)
state = hass.states.get(ENTITY_CLIMATE)
@@ -467,7 +467,7 @@ 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, None, ENTITY_CLIMATE)
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)