mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Climate 1.0 (#23899)
* Climate 1.0 / part 1/2/3 * fix flake * Lint * Update Google Assistant * ambiclimate to climate 1.0 (#24911) * Fix Alexa * Lint * Migrate zhong_hong * Migrate tuya * Migrate honeywell to new climate schema (#24257) * Update one * Fix model climate v2 * Cleanup p4 * Add comfort hold mode * Fix old code * Update homeassistant/components/climate/__init__.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/climate/const.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * First renaming * Rename operation to hvac for paulus * Rename hold mode to preset mode * Cleanup & update comments * Remove on/off * Fix supported feature count * Update services * Update demo * Fix tests & use current_hvac * Update comment * Fix tests & add typing * Add more typing * Update modes * Fix tests * Cleanup low/high with range * Update homematic part 1 * Finish homematic * Fix lint * fix hm mapping * Support simple devices * convert lcn * migrate oem * Fix xs1 * update hive * update mil * Update toon * migrate deconz * cleanup * update tesla * Fix lint * Fix vera * Migrate zwave * Migrate velbus * Cleanup humity feature * Cleanup * Migrate wink * migrate dyson * Fix current hvac * Renaming * Fix lint * Migrate tfiac * migrate tado * Fix PRESET can be None * apply PR#23913 from dev * remove EU component, etc. * remove EU component, etc. * ready to test now * de-linted * some tweaks * de-lint * better handling of edge cases * delint * fix set_mode typos * apply PR#23913 from dev * remove EU component, etc. * ready to test now * de-linted * some tweaks * de-lint * better handling of edge cases * delint * fix set_mode typos * delint, move debug code * away preset now working * code tidy-up * code tidy-up 2 * code tidy-up 3 * address issues #18932, #15063 * address issues #18932, #15063 - 2/2 * refactor MODE_AUTO to MODE_HEAT_COOL and use F not C * add low/high to set_temp * add low/high to set_temp 2 * add low/high to set_temp - delint * run HA scripts * port changes from PR #24402 * manual rebase * manual rebase 2 * delint * minor change * remove SUPPORT_HVAC_ACTION * Migrate radiotherm * Convert touchline * Migrate flexit * Migrate nuheat * Migrate maxcube * Fix names maxcube const * Migrate proliphix * Migrate heatmiser * Migrate fritzbox * Migrate opentherm_gw * Migrate venstar * Migrate daikin * Migrate modbus * Fix elif * Migrate Homematic IP Cloud to climate-1.0 (#24913) * hmip climate fix * Update hvac_mode and preset_mode * fix lint * Fix lint * Migrate generic_thermostat * Migrate incomfort to new climate schema (#24915) * initial commit * Update climate.py * Migrate eq3btsmart * Lint * cleanup PRESET_MANUAL * Migrate ecobee * No conditional features * KNX: Migrate climate component to new climate platform (#24931) * Migrate climate component * Remove unused code * Corrected line length * Lint * Lint * fix tests * Fix value * Migrate geniushub to new climate schema (#24191) * Update one * Fix model climate v2 * Cleanup p4 * Add comfort hold mode * Fix old code * Update homeassistant/components/climate/__init__.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/climate/const.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * First renaming * Rename operation to hvac for paulus * Rename hold mode to preset mode * Cleanup & update comments * Remove on/off * Fix supported feature count * Update services * Update demo * Fix tests & use current_hvac * Update comment * Fix tests & add typing * Add more typing * Update modes * Fix tests * Cleanup low/high with range * Update homematic part 1 * Finish homematic * Fix lint * fix hm mapping * Support simple devices * convert lcn * migrate oem * Fix xs1 * update hive * update mil * Update toon * migrate deconz * cleanup * update tesla * Fix lint * Fix vera * Migrate zwave * Migrate velbus * Cleanup humity feature * Cleanup * Migrate wink * migrate dyson * Fix current hvac * Renaming * Fix lint * Migrate tfiac * migrate tado * delinted * delinted * use latest client * clean up mappings * clean up mappings * add duration to set_temperature * add duration to set_temperature * manual rebase * tweak * fix regression * small fix * fix rebase mixup * address comments * finish refactor * fix regression * tweak type hints * delint * manual rebase * WIP: Fixes for honeywell migration to climate-1.0 (#24938) * add type hints * code tidy-up * Fixes for incomfort migration to climate-1.0 (#24936) * delint type hints * no async unless await * revert: no async unless await * revert: no async unless await 2 * delint * fix typo * Fix homekit_controller on climate-1.0 (#24948) * Fix tests on climate-1.0 branch * As part of climate-1.0, make state return the heating-cooling.current characteristic * Fixes from review * lint * Fix imports * Migrate stibel_eltron * Fix lint * Migrate coolmaster to climate 1.0 (#24967) * Migrate coolmaster to climate 1.0 * fix lint errors * More lint fixes * Fix demo to work with UI * Migrate spider * Demo update * Updated frontend to 20190705.0 * Fix boost mode (#24980) * Prepare Netatmo for climate 1.0 (#24973) * Migration Netatmo * Address comments * Update climate.py * Migrate ephember * Migrate Sensibo * Implemented review comments (#24942) * Migrate ESPHome * Migrate MQTT * Migrate Nest * Migrate melissa * Initial/partial migration of ST * Migrate ST * Remove Away mode (#24995) * Migrate evohome, cache access tokens (#24491) * add water_heater, add storage - initial commit * add water_heater, add storage - initial commit delint add missing code desiderata update honeywell client library & CODEOWNER add auth_tokens code, refactor & delint refactor for broker delint * Add Broker, Water Heater & Refactor add missing code desiderata * update honeywell client library & CODEOWNER add auth_tokens code, refactor & delint refactor for broker * bugfix - loc_idx may not be 0 more refactor - ensure pure async more refactoring appears all r/o attributes are working tweak precsion, DHW & delint remove unused code remove unused code 2 remove unused code, refactor _save_auth_tokens() * support RoundThermostat bugfix opmode, switch to util.dt, add until=1h revert breaking change * store at_expires as naive UTC remove debug code delint tidy up exception handling delint add water_heater, add storage - initial commit delint add missing code desiderata update honeywell client library & CODEOWNER add auth_tokens code, refactor & delint refactor for broker add water_heater, add storage - initial commit delint add missing code desiderata update honeywell client library & CODEOWNER add auth_tokens code, refactor & delint refactor for broker delint bugfix - loc_idx may not be 0 more refactor - ensure pure async more refactoring appears all r/o attributes are working tweak precsion, DHW & delint remove unused code remove unused code 2 remove unused code, refactor _save_auth_tokens() support RoundThermostat bugfix opmode, switch to util.dt, add until=1h revert breaking change store at_expires as naive UTC remove debug code delint tidy up exception handling delint * update CODEOWNERS * fix regression * fix requirements * migrate to climate-1.0 * tweaking * de-lint * TCS working? & delint * tweaking * TCS code finalised * remove available() logic * refactor _switchpoints() * tidy up switchpoint code * tweak * teaking device_state_attributes * some refactoring * move PRESET_CUSTOM back to evohome * move CONF_ACCESS_TOKEN_EXPIRES CONF_REFRESH_TOKEN back to evohome * refactor SP code and dt conversion * delinted * delinted * remove water_heater * fix regression * Migrate homekit * Cleanup away mode * Fix tests * add helpers * fix tests melissa * Fix nehueat * fix zwave * add more tests * fix deconz * Fix climate test emulate_hue * fix tests * fix dyson tests * fix demo with new layout * fix honeywell * Switch homekit_controller to use HVAC_MODE_HEAT_COOL instead of HVAC_MODE_AUTO (#25009) * Lint * PyLint * Pylint * fix fritzbox tests * Fix google * Fix all tests * Fix lint * Fix auto for homekit like controler * Fix lint * fix lint
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
"""The tests for the mqtt climate component."""
|
||||
import copy
|
||||
import json
|
||||
import pytest
|
||||
import unittest
|
||||
from unittest.mock import ANY
|
||||
|
||||
import pytest
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import mqtt
|
||||
@@ -12,11 +12,11 @@ from homeassistant.components.climate import (
|
||||
DEFAULT_MAX_TEMP, DEFAULT_MIN_TEMP)
|
||||
from homeassistant.components.climate.const import (
|
||||
DOMAIN as CLIMATE_DOMAIN,
|
||||
SUPPORT_AUX_HEAT, SUPPORT_AWAY_MODE,
|
||||
SUPPORT_FAN_MODE, SUPPORT_HOLD_MODE, SUPPORT_OPERATION_MODE,
|
||||
SUPPORT_SWING_MODE, SUPPORT_TARGET_TEMPERATURE, STATE_AUTO,
|
||||
STATE_COOL, STATE_HEAT, STATE_DRY, STATE_FAN_ONLY,
|
||||
SUPPORT_TARGET_TEMPERATURE_LOW, SUPPORT_TARGET_TEMPERATURE_HIGH)
|
||||
SUPPORT_AUX_HEAT, SUPPORT_PRESET_MODE,
|
||||
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)
|
||||
from homeassistant.components.mqtt.discovery import async_start
|
||||
from homeassistant.const import STATE_OFF, STATE_UNAVAILABLE
|
||||
|
||||
@@ -51,7 +51,7 @@ async def test_setup_params(hass, mqtt_mock):
|
||||
assert state.attributes.get('temperature') == 21
|
||||
assert state.attributes.get('fan_mode') == 'low'
|
||||
assert state.attributes.get('swing_mode') == 'off'
|
||||
assert state.attributes.get('operation_mode') == 'off'
|
||||
assert state.state == 'off'
|
||||
assert state.attributes.get('min_temp') == DEFAULT_MIN_TEMP
|
||||
assert state.attributes.get('max_temp') == DEFAULT_MAX_TEMP
|
||||
|
||||
@@ -61,24 +61,23 @@ async def test_supported_features(hass, mqtt_mock):
|
||||
assert await async_setup_component(hass, CLIMATE_DOMAIN, DEFAULT_CONFIG)
|
||||
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
support = (SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE |
|
||||
SUPPORT_SWING_MODE | SUPPORT_FAN_MODE | SUPPORT_AWAY_MODE |
|
||||
SUPPORT_HOLD_MODE | SUPPORT_AUX_HEAT |
|
||||
SUPPORT_TARGET_TEMPERATURE_LOW |
|
||||
SUPPORT_TARGET_TEMPERATURE_HIGH)
|
||||
support = (SUPPORT_TARGET_TEMPERATURE |
|
||||
SUPPORT_SWING_MODE | SUPPORT_FAN_MODE | SUPPORT_PRESET_MODE |
|
||||
SUPPORT_AUX_HEAT |
|
||||
SUPPORT_TARGET_TEMPERATURE_RANGE)
|
||||
|
||||
assert state.attributes.get("supported_features") == support
|
||||
|
||||
|
||||
async def test_get_operation_modes(hass, mqtt_mock):
|
||||
async def test_get_hvac_modes(hass, mqtt_mock):
|
||||
"""Test that the operation list returns the correct modes."""
|
||||
assert await async_setup_component(hass, CLIMATE_DOMAIN, DEFAULT_CONFIG)
|
||||
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
modes = state.attributes.get('operation_list')
|
||||
modes = state.attributes.get('hvac_modes')
|
||||
assert [
|
||||
STATE_AUTO, STATE_OFF, STATE_COOL,
|
||||
STATE_HEAT, STATE_DRY, STATE_FAN_ONLY
|
||||
HVAC_MODE_AUTO, STATE_OFF, HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT, HVAC_MODE_DRY, HVAC_MODE_FAN_ONLY
|
||||
] == modes
|
||||
|
||||
|
||||
@@ -90,15 +89,13 @@ async def test_set_operation_bad_attr_and_state(hass, mqtt_mock, caplog):
|
||||
assert await async_setup_component(hass, CLIMATE_DOMAIN, DEFAULT_CONFIG)
|
||||
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('operation_mode') == 'off'
|
||||
assert state.state == 'off'
|
||||
with pytest.raises(vol.Invalid) as excinfo:
|
||||
await common.async_set_operation_mode(hass, None, ENTITY_CLIMATE)
|
||||
assert ("string value is None for dictionary value @ "
|
||||
"data['operation_mode']")\
|
||||
await common.async_set_hvac_mode(hass, None, ENTITY_CLIMATE)
|
||||
assert ("value is not allowed for dictionary value @ "
|
||||
"data['hvac_mode']")\
|
||||
in str(excinfo.value)
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('operation_mode') == 'off'
|
||||
assert state.state == 'off'
|
||||
|
||||
|
||||
@@ -107,11 +104,10 @@ async def test_set_operation(hass, mqtt_mock):
|
||||
assert await async_setup_component(hass, CLIMATE_DOMAIN, DEFAULT_CONFIG)
|
||||
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('operation_mode') == 'off'
|
||||
assert state.state == 'off'
|
||||
await common.async_set_operation_mode(hass, 'cool', ENTITY_CLIMATE)
|
||||
await common.async_set_hvac_mode(hass, 'cool', ENTITY_CLIMATE)
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('operation_mode') == 'cool'
|
||||
assert state.state == 'cool'
|
||||
assert state.state == 'cool'
|
||||
mqtt_mock.async_publish.assert_called_once_with(
|
||||
'mode-topic', 'cool', 0, False)
|
||||
@@ -124,22 +120,18 @@ async def test_set_operation_pessimistic(hass, mqtt_mock):
|
||||
assert await async_setup_component(hass, CLIMATE_DOMAIN, config)
|
||||
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('operation_mode') is None
|
||||
assert state.state == 'unknown'
|
||||
|
||||
await common.async_set_operation_mode(hass, 'cool', ENTITY_CLIMATE)
|
||||
await common.async_set_hvac_mode(hass, 'cool', ENTITY_CLIMATE)
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('operation_mode') is None
|
||||
assert state.state == 'unknown'
|
||||
|
||||
async_fire_mqtt_message(hass, 'mode-state', 'cool')
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('operation_mode') == 'cool'
|
||||
assert state.state == 'cool'
|
||||
|
||||
async_fire_mqtt_message(hass, 'mode-state', 'bogus mode')
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('operation_mode') == 'cool'
|
||||
assert state.state == 'cool'
|
||||
|
||||
|
||||
@@ -150,21 +142,18 @@ async def test_set_operation_with_power_command(hass, mqtt_mock):
|
||||
assert await async_setup_component(hass, CLIMATE_DOMAIN, config)
|
||||
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('operation_mode') == 'off'
|
||||
assert state.state == 'off'
|
||||
await common.async_set_operation_mode(hass, 'on', ENTITY_CLIMATE)
|
||||
await common.async_set_hvac_mode(hass, 'cool', ENTITY_CLIMATE)
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('operation_mode') == 'on'
|
||||
assert state.state == 'on'
|
||||
assert state.state == 'cool'
|
||||
mqtt_mock.async_publish.assert_has_calls([
|
||||
unittest.mock.call('power-command', 'ON', 0, False),
|
||||
unittest.mock.call('mode-topic', 'on', 0, False)
|
||||
unittest.mock.call('mode-topic', 'cool', 0, False)
|
||||
])
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
|
||||
await common.async_set_operation_mode(hass, 'off', ENTITY_CLIMATE)
|
||||
await common.async_set_hvac_mode(hass, 'off', ENTITY_CLIMATE)
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('operation_mode') == 'off'
|
||||
assert state.state == 'off'
|
||||
mqtt_mock.async_publish.assert_has_calls([
|
||||
unittest.mock.call('power-command', 'OFF', 0, False),
|
||||
@@ -277,9 +266,9 @@ async def test_set_target_temperature(hass, mqtt_mock):
|
||||
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('temperature') == 21
|
||||
await common.async_set_operation_mode(hass, 'heat', ENTITY_CLIMATE)
|
||||
await common.async_set_hvac_mode(hass, 'heat', ENTITY_CLIMATE)
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('operation_mode') == 'heat'
|
||||
assert state.state == 'heat'
|
||||
mqtt_mock.async_publish.assert_called_once_with(
|
||||
'mode-topic', 'heat', 0, False)
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
@@ -293,10 +282,10 @@ async def test_set_target_temperature(hass, mqtt_mock):
|
||||
# also test directly supplying the operation mode to set_temperature
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
await common.async_set_temperature(hass, temperature=21,
|
||||
operation_mode='cool',
|
||||
hvac_mode='cool',
|
||||
entity_id=ENTITY_CLIMATE)
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('operation_mode') == 'cool'
|
||||
assert state.state == 'cool'
|
||||
assert state.attributes.get('temperature') == 21
|
||||
mqtt_mock.async_publish.assert_has_calls([
|
||||
unittest.mock.call('mode-topic', 'cool', 0, False),
|
||||
@@ -313,7 +302,7 @@ async def test_set_target_temperature_pessimistic(hass, mqtt_mock):
|
||||
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('temperature') is None
|
||||
await common.async_set_operation_mode(hass, 'heat', ENTITY_CLIMATE)
|
||||
await common.async_set_hvac_mode(hass, 'heat', ENTITY_CLIMATE)
|
||||
await common.async_set_temperature(hass, temperature=47,
|
||||
entity_id=ENTITY_CLIMATE)
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
@@ -400,23 +389,23 @@ async def test_set_away_mode_pessimistic(hass, mqtt_mock):
|
||||
assert await async_setup_component(hass, CLIMATE_DOMAIN, config)
|
||||
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('away_mode') == 'off'
|
||||
assert state.attributes.get('preset_mode') is None
|
||||
|
||||
await common.async_set_away_mode(hass, True, ENTITY_CLIMATE)
|
||||
await common.async_set_preset_mode(hass, "away", ENTITY_CLIMATE)
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('away_mode') == 'off'
|
||||
assert state.attributes.get('preset_mode') is None
|
||||
|
||||
async_fire_mqtt_message(hass, 'away-state', 'ON')
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('away_mode') == 'on'
|
||||
assert state.attributes.get('preset_mode') == 'away'
|
||||
|
||||
async_fire_mqtt_message(hass, 'away-state', 'OFF')
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('away_mode') == 'off'
|
||||
assert state.attributes.get('preset_mode') is None
|
||||
|
||||
async_fire_mqtt_message(hass, 'away-state', 'nonsense')
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('away_mode') == 'off'
|
||||
assert state.attributes.get('preset_mode') is None
|
||||
|
||||
|
||||
async def test_set_away_mode(hass, mqtt_mock):
|
||||
@@ -428,19 +417,19 @@ async def test_set_away_mode(hass, mqtt_mock):
|
||||
assert await async_setup_component(hass, CLIMATE_DOMAIN, config)
|
||||
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('away_mode') == 'off'
|
||||
await common.async_set_away_mode(hass, True, ENTITY_CLIMATE)
|
||||
assert state.attributes.get('preset_mode') is None
|
||||
await common.async_set_preset_mode(hass, "away", ENTITY_CLIMATE)
|
||||
mqtt_mock.async_publish.assert_called_once_with(
|
||||
'away-mode-topic', 'AN', 0, False)
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('away_mode') == 'on'
|
||||
assert state.attributes.get('preset_mode') == 'away'
|
||||
|
||||
await common.async_set_away_mode(hass, False, ENTITY_CLIMATE)
|
||||
await common.async_set_preset_mode(hass, None, ENTITY_CLIMATE)
|
||||
mqtt_mock.async_publish.assert_called_once_with(
|
||||
'away-mode-topic', 'AUS', 0, False)
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('away_mode') == 'off'
|
||||
assert state.attributes.get('preset_mode') is None
|
||||
|
||||
|
||||
async def test_set_hold_pessimistic(hass, mqtt_mock):
|
||||
@@ -452,17 +441,17 @@ async def test_set_hold_pessimistic(hass, mqtt_mock):
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('hold_mode') is None
|
||||
|
||||
await common.async_set_hold_mode(hass, 'on', ENTITY_CLIMATE)
|
||||
await common.async_set_preset_mode(hass, 'hold', ENTITY_CLIMATE)
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('hold_mode') is None
|
||||
|
||||
async_fire_mqtt_message(hass, 'hold-state', 'on')
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('hold_mode') == 'on'
|
||||
assert state.attributes.get('preset_mode') == 'on'
|
||||
|
||||
async_fire_mqtt_message(hass, 'hold-state', 'off')
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('hold_mode') == 'off'
|
||||
assert state.attributes.get('preset_mode') is None
|
||||
|
||||
|
||||
async def test_set_hold(hass, mqtt_mock):
|
||||
@@ -470,19 +459,19 @@ async def test_set_hold(hass, mqtt_mock):
|
||||
assert await async_setup_component(hass, CLIMATE_DOMAIN, DEFAULT_CONFIG)
|
||||
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('hold_mode') is None
|
||||
await common.async_set_hold_mode(hass, 'on', 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.assert_called_once_with(
|
||||
'hold-topic', 'on', 0, False)
|
||||
'hold-topic', 'hold-on', 0, False)
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('hold_mode') == 'on'
|
||||
assert state.attributes.get('preset_mode') == 'hold-on'
|
||||
|
||||
await common.async_set_hold_mode(hass, 'off', ENTITY_CLIMATE)
|
||||
await common.async_set_preset_mode(hass, None, ENTITY_CLIMATE)
|
||||
mqtt_mock.async_publish.assert_called_once_with(
|
||||
'hold-topic', 'off', 0, False)
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('hold_mode') == 'off'
|
||||
assert state.attributes.get('preset_mode') is None
|
||||
|
||||
|
||||
async def test_set_aux_pessimistic(hass, mqtt_mock):
|
||||
@@ -579,10 +568,9 @@ async def test_set_with_templates(hass, mqtt_mock, caplog):
|
||||
|
||||
# Operation Mode
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('operation_mode') is None
|
||||
async_fire_mqtt_message(hass, 'mode-state', '"cool"')
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('operation_mode') == 'cool'
|
||||
assert state.state == 'cool'
|
||||
|
||||
# Fan Mode
|
||||
assert state.attributes.get('fan_mode') is None
|
||||
@@ -611,27 +599,26 @@ async def test_set_with_templates(hass, mqtt_mock, caplog):
|
||||
assert state.attributes.get('temperature') == 1031
|
||||
|
||||
# Away Mode
|
||||
assert state.attributes.get('away_mode') == 'off'
|
||||
assert state.attributes.get('preset_mode') is None
|
||||
async_fire_mqtt_message(hass, 'away-state', '"ON"')
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('away_mode') == 'on'
|
||||
assert state.attributes.get('preset_mode') == 'away'
|
||||
|
||||
# Away Mode with JSON values
|
||||
async_fire_mqtt_message(hass, 'away-state', 'false')
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('away_mode') == 'off'
|
||||
assert state.attributes.get('preset_mode') is None
|
||||
|
||||
async_fire_mqtt_message(hass, 'away-state', 'true')
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('away_mode') == 'on'
|
||||
assert state.attributes.get('preset_mode') == 'away'
|
||||
|
||||
# Hold Mode
|
||||
assert state.attributes.get('hold_mode') is None
|
||||
async_fire_mqtt_message(hass, 'hold-state', """
|
||||
{ "attribute": "somemode" }
|
||||
""")
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get('hold_mode') == 'somemode'
|
||||
assert state.attributes.get('preset_mode') == 'somemode'
|
||||
|
||||
# Aux mode
|
||||
assert state.attributes.get('aux_heat') == 'off'
|
||||
|
||||
Reference in New Issue
Block a user