Cleanup HVACAction and HVACMode in tests (#78813)
This commit is contained in:
parent
3cf26c4a5d
commit
f453726b18
11 changed files with 497 additions and 515 deletions
|
@ -3,7 +3,7 @@ import pytest
|
|||
import voluptuous_serialize
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.climate import DOMAIN, const, device_action
|
||||
from homeassistant.components.climate import DOMAIN, HVACMode, const, device_action
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.helpers import config_validation as cv, device_registry
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
|
@ -152,9 +152,9 @@ async def test_action(hass):
|
|||
"""Test for actions."""
|
||||
hass.states.async_set(
|
||||
"climate.entity",
|
||||
const.HVAC_MODE_COOL,
|
||||
HVACMode.COOL,
|
||||
{
|
||||
const.ATTR_HVAC_MODES: [const.HVAC_MODE_COOL, const.HVAC_MODE_OFF],
|
||||
const.ATTR_HVAC_MODES: [HVACMode.COOL, HVACMode.OFF],
|
||||
const.ATTR_PRESET_MODES: [const.PRESET_HOME, const.PRESET_AWAY],
|
||||
},
|
||||
)
|
||||
|
@ -174,7 +174,7 @@ async def test_action(hass):
|
|||
"device_id": "abcdefgh",
|
||||
"entity_id": "climate.entity",
|
||||
"type": "set_hvac_mode",
|
||||
"hvac_mode": const.HVAC_MODE_OFF,
|
||||
"hvac_mode": HVACMode.OFF,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -213,7 +213,7 @@ async def test_action(hass):
|
|||
[
|
||||
(
|
||||
False,
|
||||
{const.ATTR_HVAC_MODES: [const.HVAC_MODE_COOL, const.HVAC_MODE_OFF]},
|
||||
{const.ATTR_HVAC_MODES: [HVACMode.COOL, HVACMode.OFF]},
|
||||
{},
|
||||
"set_hvac_mode",
|
||||
[
|
||||
|
@ -242,7 +242,7 @@ async def test_action(hass):
|
|||
(
|
||||
True,
|
||||
{},
|
||||
{const.ATTR_HVAC_MODES: [const.HVAC_MODE_COOL, const.HVAC_MODE_OFF]},
|
||||
{const.ATTR_HVAC_MODES: [HVACMode.COOL, HVACMode.OFF]},
|
||||
"set_hvac_mode",
|
||||
[
|
||||
{
|
||||
|
@ -296,7 +296,7 @@ async def test_capabilities(
|
|||
if set_state:
|
||||
hass.states.async_set(
|
||||
f"{DOMAIN}.test_5678",
|
||||
const.HVAC_MODE_COOL,
|
||||
HVACMode.COOL,
|
||||
capabilities_state,
|
||||
)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import pytest
|
|||
import voluptuous_serialize
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.climate import DOMAIN, const, device_condition
|
||||
from homeassistant.components.climate import DOMAIN, HVACMode, const, device_condition
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.helpers import config_validation as cv, device_registry
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
|
@ -207,7 +207,7 @@ async def test_if_state(hass, calls):
|
|||
|
||||
hass.states.async_set(
|
||||
"climate.entity",
|
||||
const.HVAC_MODE_COOL,
|
||||
HVACMode.COOL,
|
||||
{
|
||||
const.ATTR_PRESET_MODE: const.PRESET_AWAY,
|
||||
},
|
||||
|
@ -220,7 +220,7 @@ async def test_if_state(hass, calls):
|
|||
|
||||
hass.states.async_set(
|
||||
"climate.entity",
|
||||
const.HVAC_MODE_AUTO,
|
||||
HVACMode.AUTO,
|
||||
{
|
||||
const.ATTR_PRESET_MODE: const.PRESET_AWAY,
|
||||
},
|
||||
|
@ -239,7 +239,7 @@ async def test_if_state(hass, calls):
|
|||
|
||||
hass.states.async_set(
|
||||
"climate.entity",
|
||||
const.HVAC_MODE_AUTO,
|
||||
HVACMode.AUTO,
|
||||
{
|
||||
const.ATTR_PRESET_MODE: const.PRESET_HOME,
|
||||
},
|
||||
|
@ -256,7 +256,7 @@ async def test_if_state(hass, calls):
|
|||
[
|
||||
(
|
||||
False,
|
||||
{const.ATTR_HVAC_MODES: [const.HVAC_MODE_COOL, const.HVAC_MODE_OFF]},
|
||||
{const.ATTR_HVAC_MODES: [HVACMode.COOL, HVACMode.OFF]},
|
||||
{},
|
||||
"is_hvac_mode",
|
||||
[
|
||||
|
@ -285,7 +285,7 @@ async def test_if_state(hass, calls):
|
|||
(
|
||||
True,
|
||||
{},
|
||||
{const.ATTR_HVAC_MODES: [const.HVAC_MODE_COOL, const.HVAC_MODE_OFF]},
|
||||
{const.ATTR_HVAC_MODES: [HVACMode.COOL, HVACMode.OFF]},
|
||||
"is_hvac_mode",
|
||||
[
|
||||
{
|
||||
|
@ -339,7 +339,7 @@ async def test_capabilities(
|
|||
if set_state:
|
||||
hass.states.async_set(
|
||||
f"{DOMAIN}.test_5678",
|
||||
const.HVAC_MODE_COOL,
|
||||
HVACMode.COOL,
|
||||
capabilities_state,
|
||||
)
|
||||
|
||||
|
|
|
@ -3,7 +3,13 @@ import pytest
|
|||
import voluptuous_serialize
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.climate import DOMAIN, const, device_trigger
|
||||
from homeassistant.components.climate import (
|
||||
DOMAIN,
|
||||
HVACAction,
|
||||
HVACMode,
|
||||
const,
|
||||
device_trigger,
|
||||
)
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.const import TEMP_CELSIUS
|
||||
from homeassistant.helpers import config_validation as cv, device_registry
|
||||
|
@ -52,9 +58,9 @@ async def test_get_triggers(hass, device_reg, entity_reg):
|
|||
entity_id = f"{DOMAIN}.test_5678"
|
||||
hass.states.async_set(
|
||||
entity_id,
|
||||
const.HVAC_MODE_COOL,
|
||||
HVACMode.COOL,
|
||||
{
|
||||
const.ATTR_HVAC_ACTION: const.HVACAction.IDLE,
|
||||
const.ATTR_HVAC_ACTION: HVACAction.IDLE,
|
||||
const.ATTR_CURRENT_HUMIDITY: 23,
|
||||
const.ATTR_CURRENT_TEMPERATURE: 18,
|
||||
},
|
||||
|
@ -114,9 +120,9 @@ async def test_get_triggers_hidden_auxiliary(
|
|||
entity_id = f"{DOMAIN}.test_5678"
|
||||
hass.states.async_set(
|
||||
entity_id,
|
||||
const.HVAC_MODE_COOL,
|
||||
HVACMode.COOL,
|
||||
{
|
||||
const.ATTR_HVAC_ACTION: const.CURRENT_HVAC_IDLE,
|
||||
const.ATTR_HVAC_ACTION: HVACAction.IDLE,
|
||||
const.ATTR_CURRENT_HUMIDITY: 23,
|
||||
const.ATTR_CURRENT_TEMPERATURE: 18,
|
||||
},
|
||||
|
@ -146,9 +152,9 @@ async def test_if_fires_on_state_change(hass, calls):
|
|||
"""Test for turn_on and turn_off triggers firing."""
|
||||
hass.states.async_set(
|
||||
"climate.entity",
|
||||
const.HVAC_MODE_COOL,
|
||||
HVACMode.COOL,
|
||||
{
|
||||
const.ATTR_HVAC_ACTION: const.HVACAction.IDLE,
|
||||
const.ATTR_HVAC_ACTION: HVACAction.IDLE,
|
||||
const.ATTR_CURRENT_HUMIDITY: 23,
|
||||
const.ATTR_CURRENT_TEMPERATURE: 18,
|
||||
},
|
||||
|
@ -166,7 +172,7 @@ async def test_if_fires_on_state_change(hass, calls):
|
|||
"device_id": "",
|
||||
"entity_id": "climate.entity",
|
||||
"type": "hvac_mode_changed",
|
||||
"to": const.HVAC_MODE_AUTO,
|
||||
"to": HVACMode.AUTO,
|
||||
},
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
|
@ -208,9 +214,9 @@ async def test_if_fires_on_state_change(hass, calls):
|
|||
# Fake that the HVAC mode is changing
|
||||
hass.states.async_set(
|
||||
"climate.entity",
|
||||
const.HVAC_MODE_AUTO,
|
||||
HVACMode.AUTO,
|
||||
{
|
||||
const.ATTR_HVAC_ACTION: const.HVACAction.COOLING,
|
||||
const.ATTR_HVAC_ACTION: HVACAction.COOLING,
|
||||
const.ATTR_CURRENT_HUMIDITY: 23,
|
||||
const.ATTR_CURRENT_TEMPERATURE: 18,
|
||||
},
|
||||
|
@ -222,9 +228,9 @@ async def test_if_fires_on_state_change(hass, calls):
|
|||
# Fake that the temperature is changing
|
||||
hass.states.async_set(
|
||||
"climate.entity",
|
||||
const.HVAC_MODE_AUTO,
|
||||
HVACMode.AUTO,
|
||||
{
|
||||
const.ATTR_HVAC_ACTION: const.HVACAction.COOLING,
|
||||
const.ATTR_HVAC_ACTION: HVACAction.COOLING,
|
||||
const.ATTR_CURRENT_HUMIDITY: 23,
|
||||
const.ATTR_CURRENT_TEMPERATURE: 23,
|
||||
},
|
||||
|
@ -236,9 +242,9 @@ async def test_if_fires_on_state_change(hass, calls):
|
|||
# Fake that the humidity is changing
|
||||
hass.states.async_set(
|
||||
"climate.entity",
|
||||
const.HVAC_MODE_AUTO,
|
||||
HVACMode.AUTO,
|
||||
{
|
||||
const.ATTR_HVAC_ACTION: const.HVACAction.COOLING,
|
||||
const.ATTR_HVAC_ACTION: HVACAction.COOLING,
|
||||
const.ATTR_CURRENT_HUMIDITY: 7,
|
||||
const.ATTR_CURRENT_TEMPERATURE: 23,
|
||||
},
|
||||
|
|
|
@ -7,10 +7,9 @@ import pytest
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.climate import (
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_OFF,
|
||||
SET_TEMPERATURE_SCHEMA,
|
||||
ClimateEntity,
|
||||
HVACMode,
|
||||
)
|
||||
|
||||
from tests.common import async_mock_service
|
||||
|
@ -50,20 +49,20 @@ class MockClimateEntity(ClimateEntity):
|
|||
"""Mock Climate device to use in tests."""
|
||||
|
||||
@property
|
||||
def hvac_mode(self) -> str:
|
||||
def hvac_mode(self) -> HVACMode:
|
||||
"""Return hvac operation ie. heat, cool mode.
|
||||
|
||||
Need to be one of HVAC_MODE_*.
|
||||
Need to be one of HVACMode.*.
|
||||
"""
|
||||
return HVAC_MODE_HEAT
|
||||
return HVACMode.HEAT
|
||||
|
||||
@property
|
||||
def hvac_modes(self) -> list[str]:
|
||||
def hvac_modes(self) -> list[HVACMode]:
|
||||
"""Return the list of available hvac operation modes.
|
||||
|
||||
Need to be a subset of HVAC_MODES.
|
||||
"""
|
||||
return [HVAC_MODE_OFF, HVAC_MODE_HEAT]
|
||||
return [HVACMode.OFF, HVACMode.HEAT]
|
||||
|
||||
def turn_on(self) -> None:
|
||||
"""Turn on."""
|
||||
|
|
|
@ -11,9 +11,6 @@ from homeassistant.components.climate.const import (
|
|||
ATTR_TARGET_TEMP_HIGH,
|
||||
ATTR_TARGET_TEMP_LOW,
|
||||
DOMAIN,
|
||||
HVAC_MODE_AUTO,
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_OFF,
|
||||
SERVICE_SET_AUX_HEAT,
|
||||
SERVICE_SET_FAN_MODE,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
|
@ -21,6 +18,7 @@ from homeassistant.components.climate.const import (
|
|||
SERVICE_SET_PRESET_MODE,
|
||||
SERVICE_SET_SWING_MODE,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
HVACMode,
|
||||
)
|
||||
from homeassistant.components.climate.reproduce_state import async_reproduce_states
|
||||
from homeassistant.const import ATTR_TEMPERATURE
|
||||
|
@ -32,7 +30,7 @@ ENTITY_1 = "climate.test1"
|
|||
ENTITY_2 = "climate.test2"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("state", [HVAC_MODE_AUTO, HVAC_MODE_HEAT, HVAC_MODE_OFF])
|
||||
@pytest.mark.parametrize("state", [HVACMode.AUTO, HVACMode.HEAT, HVACMode.OFF])
|
||||
async def test_with_hvac_mode(hass, state):
|
||||
"""Test that state different hvac states."""
|
||||
calls = async_mock_service(hass, DOMAIN, SERVICE_SET_HVAC_MODE)
|
||||
|
@ -50,7 +48,7 @@ async def test_multiple_state(hass):
|
|||
calls_1 = async_mock_service(hass, DOMAIN, SERVICE_SET_HVAC_MODE)
|
||||
|
||||
await async_reproduce_states(
|
||||
hass, [State(ENTITY_1, HVAC_MODE_HEAT), State(ENTITY_2, HVAC_MODE_AUTO)]
|
||||
hass, [State(ENTITY_1, HVACMode.HEAT), State(ENTITY_2, HVACMode.AUTO)]
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
@ -58,11 +56,11 @@ async def test_multiple_state(hass):
|
|||
assert len(calls_1) == 2
|
||||
# order is not guaranteed
|
||||
assert any(
|
||||
call.data == {"entity_id": ENTITY_1, "hvac_mode": HVAC_MODE_HEAT}
|
||||
call.data == {"entity_id": ENTITY_1, "hvac_mode": HVACMode.HEAT}
|
||||
for call in calls_1
|
||||
)
|
||||
assert any(
|
||||
call.data == {"entity_id": ENTITY_2, "hvac_mode": HVAC_MODE_AUTO}
|
||||
call.data == {"entity_id": ENTITY_2, "hvac_mode": HVACMode.AUTO}
|
||||
for call in calls_1
|
||||
)
|
||||
|
||||
|
@ -85,13 +83,13 @@ async def test_state_with_context(hass):
|
|||
context = Context()
|
||||
|
||||
await async_reproduce_states(
|
||||
hass, [State(ENTITY_1, HVAC_MODE_HEAT)], context=context
|
||||
hass, [State(ENTITY_1, HVACMode.HEAT)], context=context
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(calls) == 1
|
||||
assert calls[0].data == {"entity_id": ENTITY_1, "hvac_mode": HVAC_MODE_HEAT}
|
||||
assert calls[0].data == {"entity_id": ENTITY_1, "hvac_mode": HVACMode.HEAT}
|
||||
assert calls[0].context == context
|
||||
|
||||
|
||||
|
|
|
@ -829,7 +829,7 @@ async def test_put_light_state_climate_set_temperature(hass_hue, hue_client):
|
|||
assert len(hvac_result_json) == 2
|
||||
|
||||
hvac = hass_hue.states.get("climate.hvac")
|
||||
assert hvac.state == climate.const.HVAC_MODE_COOL
|
||||
assert hvac.state == climate.HVACMode.COOL
|
||||
assert hvac.attributes[climate.ATTR_TEMPERATURE] == temperature
|
||||
|
||||
# Make sure we can't change the ecobee temperature since it's not exposed
|
||||
|
|
|
@ -5,11 +5,7 @@ from unittest.mock import ANY, call, patch
|
|||
import pytest
|
||||
|
||||
from homeassistant.components import camera
|
||||
from homeassistant.components.climate.const import (
|
||||
ATTR_MAX_TEMP,
|
||||
ATTR_MIN_TEMP,
|
||||
HVAC_MODE_HEAT,
|
||||
)
|
||||
from homeassistant.components.climate import ATTR_MAX_TEMP, ATTR_MIN_TEMP, HVACMode
|
||||
from homeassistant.components.demo.binary_sensor import DemoBinarySensor
|
||||
from homeassistant.components.demo.cover import DemoCover
|
||||
from homeassistant.components.demo.light import LIGHT_EFFECT_LIST, DemoLight
|
||||
|
@ -807,7 +803,7 @@ async def test_raising_error_trait(hass):
|
|||
"""Test raising an error while executing a trait command."""
|
||||
hass.states.async_set(
|
||||
"climate.bla",
|
||||
HVAC_MODE_HEAT,
|
||||
HVACMode.HEAT,
|
||||
{ATTR_MIN_TEMP: 15, ATTR_MAX_TEMP: 30, ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS},
|
||||
)
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -12,7 +12,7 @@ from maxcube.thermostat import MaxThermostat
|
|||
from maxcube.wallthermostat import MaxWallThermostat
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.climate.const import (
|
||||
from homeassistant.components.climate import (
|
||||
ATTR_CURRENT_TEMPERATURE,
|
||||
ATTR_HVAC_ACTION,
|
||||
ATTR_HVAC_MODE,
|
||||
|
@ -23,14 +23,7 @@ from homeassistant.components.climate.const import (
|
|||
ATTR_PRESET_MODES,
|
||||
ATTR_TARGET_TEMP_HIGH,
|
||||
ATTR_TARGET_TEMP_LOW,
|
||||
CURRENT_HVAC_HEAT,
|
||||
CURRENT_HVAC_IDLE,
|
||||
CURRENT_HVAC_OFF,
|
||||
DOMAIN as CLIMATE_DOMAIN,
|
||||
HVAC_MODE_AUTO,
|
||||
HVAC_MODE_DRY,
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_OFF,
|
||||
PRESET_AWAY,
|
||||
PRESET_BOOST,
|
||||
PRESET_COMFORT,
|
||||
|
@ -40,6 +33,8 @@ from homeassistant.components.climate.const import (
|
|||
SERVICE_SET_PRESET_MODE,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
ClimateEntityFeature,
|
||||
HVACAction,
|
||||
HVACMode,
|
||||
)
|
||||
from homeassistant.components.maxcube.climate import (
|
||||
MAX_TEMPERATURE,
|
||||
|
@ -72,13 +67,13 @@ async def test_setup_thermostat(hass, cube: MaxCube):
|
|||
assert entity.unique_id == "AABBCCDD01"
|
||||
|
||||
state = hass.states.get(ENTITY_ID)
|
||||
assert state.state == HVAC_MODE_AUTO
|
||||
assert state.state == HVACMode.AUTO
|
||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "TestRoom TestThermostat"
|
||||
assert state.attributes.get(ATTR_HVAC_ACTION) == CURRENT_HVAC_HEAT
|
||||
assert state.attributes.get(ATTR_HVAC_ACTION) == HVACAction.HEATING
|
||||
assert state.attributes.get(ATTR_HVAC_MODES) == [
|
||||
HVAC_MODE_OFF,
|
||||
HVAC_MODE_AUTO,
|
||||
HVAC_MODE_HEAT,
|
||||
HVACMode.OFF,
|
||||
HVACMode.AUTO,
|
||||
HVACMode.HEAT,
|
||||
]
|
||||
assert state.attributes.get(ATTR_PRESET_MODES) == [
|
||||
PRESET_NONE,
|
||||
|
@ -108,9 +103,9 @@ async def test_setup_wallthermostat(hass, cube: MaxCube):
|
|||
assert entity.unique_id == "AABBCCDD02"
|
||||
|
||||
state = hass.states.get(WALL_ENTITY_ID)
|
||||
assert state.state == HVAC_MODE_OFF
|
||||
assert state.state == HVACMode.OFF
|
||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "TestRoom TestWallThermostat"
|
||||
assert state.attributes.get(ATTR_HVAC_ACTION) == CURRENT_HVAC_HEAT
|
||||
assert state.attributes.get(ATTR_HVAC_ACTION) == HVACAction.HEATING
|
||||
assert state.attributes.get(ATTR_PRESET_MODE) == PRESET_NONE
|
||||
assert state.attributes.get(ATTR_MAX_TEMP) == 29.0
|
||||
assert state.attributes.get(ATTR_MIN_TEMP) == 5.0
|
||||
|
@ -125,7 +120,7 @@ async def test_thermostat_set_hvac_mode_off(
|
|||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_HVAC_MODE: HVAC_MODE_OFF},
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_HVAC_MODE: HVACMode.OFF},
|
||||
blocking=True,
|
||||
)
|
||||
cube.set_temperature_mode.assert_called_once_with(
|
||||
|
@ -140,13 +135,13 @@ async def test_thermostat_set_hvac_mode_off(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(ENTITY_ID)
|
||||
assert state.state == HVAC_MODE_OFF
|
||||
assert state.state == HVACMode.OFF
|
||||
assert state.attributes.get(ATTR_TEMPERATURE) is None
|
||||
assert state.attributes.get(ATTR_HVAC_ACTION) == CURRENT_HVAC_OFF
|
||||
assert state.attributes.get(ATTR_HVAC_ACTION) == HVACAction.OFF
|
||||
assert state.attributes.get(VALVE_POSITION) == 0
|
||||
|
||||
wall_state = hass.states.get(WALL_ENTITY_ID)
|
||||
assert wall_state.attributes.get(ATTR_HVAC_ACTION) == CURRENT_HVAC_OFF
|
||||
assert wall_state.attributes.get(ATTR_HVAC_ACTION) == HVACAction.OFF
|
||||
|
||||
|
||||
async def test_thermostat_set_hvac_mode_heat(
|
||||
|
@ -156,7 +151,7 @@ async def test_thermostat_set_hvac_mode_heat(
|
|||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_HVAC_MODE: HVAC_MODE_HEAT},
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_HVAC_MODE: HVACMode.HEAT},
|
||||
blocking=True,
|
||||
)
|
||||
cube.set_temperature_mode.assert_called_once_with(
|
||||
|
@ -169,7 +164,7 @@ async def test_thermostat_set_hvac_mode_heat(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(ENTITY_ID)
|
||||
assert state.state == HVAC_MODE_HEAT
|
||||
assert state.state == HVACMode.HEAT
|
||||
|
||||
|
||||
async def test_thermostat_set_invalid_hvac_mode(
|
||||
|
@ -180,7 +175,7 @@ async def test_thermostat_set_invalid_hvac_mode(
|
|||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_HVAC_MODE: HVAC_MODE_DRY},
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_HVAC_MODE: HVACMode.DRY},
|
||||
blocking=True,
|
||||
)
|
||||
cube.set_temperature_mode.assert_not_called()
|
||||
|
@ -204,9 +199,9 @@ async def test_thermostat_set_temperature(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(ENTITY_ID)
|
||||
assert state.state == HVAC_MODE_AUTO
|
||||
assert state.state == HVACMode.AUTO
|
||||
assert state.attributes.get(ATTR_TEMPERATURE) == 10.0
|
||||
assert state.attributes.get(ATTR_HVAC_ACTION) == CURRENT_HVAC_IDLE
|
||||
assert state.attributes.get(ATTR_HVAC_ACTION) == HVACAction.IDLE
|
||||
|
||||
|
||||
async def test_thermostat_set_no_temperature(
|
||||
|
@ -246,7 +241,7 @@ async def test_thermostat_set_preset_on(hass, cube: MaxCube, thermostat: MaxTher
|
|||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(ENTITY_ID)
|
||||
assert state.state == HVAC_MODE_HEAT
|
||||
assert state.state == HVACMode.HEAT
|
||||
assert state.attributes.get(ATTR_TEMPERATURE) is None
|
||||
assert state.attributes.get(ATTR_PRESET_MODE) == PRESET_ON
|
||||
|
||||
|
@ -271,7 +266,7 @@ async def test_thermostat_set_preset_comfort(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(ENTITY_ID)
|
||||
assert state.state == HVAC_MODE_HEAT
|
||||
assert state.state == HVACMode.HEAT
|
||||
assert state.attributes.get(ATTR_TEMPERATURE) == thermostat.comfort_temperature
|
||||
assert state.attributes.get(ATTR_PRESET_MODE) == PRESET_COMFORT
|
||||
|
||||
|
@ -296,7 +291,7 @@ async def test_thermostat_set_preset_eco(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(ENTITY_ID)
|
||||
assert state.state == HVAC_MODE_HEAT
|
||||
assert state.state == HVACMode.HEAT
|
||||
assert state.attributes.get(ATTR_TEMPERATURE) == thermostat.eco_temperature
|
||||
assert state.attributes.get(ATTR_PRESET_MODE) == PRESET_ECO
|
||||
|
||||
|
@ -321,7 +316,7 @@ async def test_thermostat_set_preset_away(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(ENTITY_ID)
|
||||
assert state.state == HVAC_MODE_HEAT
|
||||
assert state.state == HVACMode.HEAT
|
||||
assert state.attributes.get(ATTR_TEMPERATURE) == thermostat.eco_temperature
|
||||
assert state.attributes.get(ATTR_PRESET_MODE) == PRESET_AWAY
|
||||
|
||||
|
@ -346,7 +341,7 @@ async def test_thermostat_set_preset_boost(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(ENTITY_ID)
|
||||
assert state.state == HVAC_MODE_AUTO
|
||||
assert state.state == HVACMode.AUTO
|
||||
assert state.attributes.get(ATTR_TEMPERATURE) == thermostat.eco_temperature
|
||||
assert state.attributes.get(ATTR_PRESET_MODE) == PRESET_BOOST
|
||||
|
||||
|
@ -387,7 +382,7 @@ async def test_wallthermostat_set_hvac_mode_heat(
|
|||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: WALL_ENTITY_ID, ATTR_HVAC_MODE: HVAC_MODE_HEAT},
|
||||
{ATTR_ENTITY_ID: WALL_ENTITY_ID, ATTR_HVAC_MODE: HVACMode.HEAT},
|
||||
blocking=True,
|
||||
)
|
||||
cube.set_temperature_mode.assert_called_once_with(
|
||||
|
@ -399,7 +394,7 @@ async def test_wallthermostat_set_hvac_mode_heat(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(WALL_ENTITY_ID)
|
||||
assert state.state == HVAC_MODE_HEAT
|
||||
assert state.state == HVACMode.HEAT
|
||||
assert state.attributes.get(ATTR_TEMPERATURE) == MIN_TEMPERATURE
|
||||
|
||||
|
||||
|
@ -410,7 +405,7 @@ async def test_wallthermostat_set_hvac_mode_auto(
|
|||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: WALL_ENTITY_ID, ATTR_HVAC_MODE: HVAC_MODE_AUTO},
|
||||
{ATTR_ENTITY_ID: WALL_ENTITY_ID, ATTR_HVAC_MODE: HVACMode.AUTO},
|
||||
blocking=True,
|
||||
)
|
||||
cube.set_temperature_mode.assert_called_once_with(
|
||||
|
@ -423,5 +418,5 @@ async def test_wallthermostat_set_hvac_mode_auto(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(WALL_ENTITY_ID)
|
||||
assert state.state == HVAC_MODE_AUTO
|
||||
assert state.state == HVACMode.AUTO
|
||||
assert state.attributes.get(ATTR_TEMPERATURE) == 23.0
|
||||
|
|
|
@ -14,7 +14,7 @@ from google_nest_sdm.auth import AbstractAuth
|
|||
from google_nest_sdm.event import EventMessage
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.climate.const import (
|
||||
from homeassistant.components.climate import (
|
||||
ATTR_CURRENT_TEMPERATURE,
|
||||
ATTR_FAN_MODE,
|
||||
ATTR_FAN_MODES,
|
||||
|
@ -24,22 +24,15 @@ from homeassistant.components.climate.const import (
|
|||
ATTR_PRESET_MODES,
|
||||
ATTR_TARGET_TEMP_HIGH,
|
||||
ATTR_TARGET_TEMP_LOW,
|
||||
CURRENT_HVAC_COOL,
|
||||
CURRENT_HVAC_HEAT,
|
||||
CURRENT_HVAC_IDLE,
|
||||
CURRENT_HVAC_OFF,
|
||||
FAN_LOW,
|
||||
FAN_OFF,
|
||||
FAN_ON,
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_DRY,
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
PRESET_ECO,
|
||||
PRESET_NONE,
|
||||
PRESET_SLEEP,
|
||||
ClimateEntityFeature,
|
||||
HVACAction,
|
||||
HVACMode,
|
||||
)
|
||||
from homeassistant.const import ATTR_SUPPORTED_FEATURES, ATTR_TEMPERATURE
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -136,14 +129,14 @@ async def test_thermostat_off(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_OFF
|
||||
assert thermostat.state == HVACMode.OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.OFF
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 16.2
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
HVACMode.HEAT,
|
||||
HVACMode.COOL,
|
||||
HVACMode.HEAT_COOL,
|
||||
HVACMode.OFF,
|
||||
}
|
||||
assert thermostat.attributes[ATTR_TEMPERATURE] is None
|
||||
assert thermostat.attributes[ATTR_TARGET_TEMP_LOW] is None
|
||||
|
@ -180,14 +173,14 @@ async def test_thermostat_heat(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_HEAT
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_HEAT
|
||||
assert thermostat.state == HVACMode.HEAT
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.HEATING
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 16.2
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
HVACMode.HEAT,
|
||||
HVACMode.COOL,
|
||||
HVACMode.HEAT_COOL,
|
||||
HVACMode.OFF,
|
||||
}
|
||||
assert thermostat.attributes[ATTR_TEMPERATURE] == 22.0
|
||||
assert thermostat.attributes[ATTR_TARGET_TEMP_LOW] is None
|
||||
|
@ -222,14 +215,14 @@ async def test_thermostat_cool(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_COOL
|
||||
assert thermostat.state == HVACMode.COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.COOLING
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 29.9
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
HVACMode.HEAT,
|
||||
HVACMode.COOL,
|
||||
HVACMode.HEAT_COOL,
|
||||
HVACMode.OFF,
|
||||
}
|
||||
assert thermostat.attributes[ATTR_TEMPERATURE] == 28.0
|
||||
assert thermostat.attributes[ATTR_TARGET_TEMP_LOW] is None
|
||||
|
@ -265,14 +258,14 @@ async def test_thermostat_heatcool(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_HEAT_COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_COOL
|
||||
assert thermostat.state == HVACMode.HEAT_COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.COOLING
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 29.9
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
HVACMode.HEAT,
|
||||
HVACMode.COOL,
|
||||
HVACMode.HEAT_COOL,
|
||||
HVACMode.OFF,
|
||||
}
|
||||
assert thermostat.attributes[ATTR_TARGET_TEMP_LOW] == 22.0
|
||||
assert thermostat.attributes[ATTR_TARGET_TEMP_HIGH] == 28.0
|
||||
|
@ -314,14 +307,14 @@ async def test_thermostat_eco_off(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_HEAT_COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_COOL
|
||||
assert thermostat.state == HVACMode.HEAT_COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.COOLING
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 29.9
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
HVACMode.HEAT,
|
||||
HVACMode.COOL,
|
||||
HVACMode.HEAT_COOL,
|
||||
HVACMode.OFF,
|
||||
}
|
||||
assert thermostat.attributes[ATTR_TARGET_TEMP_LOW] == 22.0
|
||||
assert thermostat.attributes[ATTR_TARGET_TEMP_HIGH] == 28.0
|
||||
|
@ -363,14 +356,14 @@ async def test_thermostat_eco_on(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_HEAT_COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_COOL
|
||||
assert thermostat.state == HVACMode.HEAT_COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.COOLING
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 29.9
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
HVACMode.HEAT,
|
||||
HVACMode.COOL,
|
||||
HVACMode.HEAT_COOL,
|
||||
HVACMode.OFF,
|
||||
}
|
||||
assert thermostat.attributes[ATTR_TARGET_TEMP_LOW] == 21.0
|
||||
assert thermostat.attributes[ATTR_TARGET_TEMP_HIGH] == 29.0
|
||||
|
@ -409,12 +402,12 @@ async def test_thermostat_eco_heat_only(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_HEAT
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
|
||||
assert thermostat.state == HVACMode.HEAT
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 29.9
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_OFF,
|
||||
HVACMode.HEAT,
|
||||
HVACMode.OFF,
|
||||
}
|
||||
assert thermostat.attributes[ATTR_TEMPERATURE] == 21.0
|
||||
assert ATTR_TARGET_TEMP_LOW not in thermostat.attributes
|
||||
|
@ -445,10 +438,10 @@ async def test_thermostat_set_hvac_mode(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_OFF
|
||||
assert thermostat.state == HVACMode.OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.OFF
|
||||
|
||||
await common.async_set_hvac_mode(hass, HVAC_MODE_HEAT)
|
||||
await common.async_set_hvac_mode(hass, HVACMode.HEAT)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert auth.method == "post"
|
||||
|
@ -461,8 +454,8 @@ async def test_thermostat_set_hvac_mode(
|
|||
# Local state does not reflect the update
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_OFF
|
||||
assert thermostat.state == HVACMode.OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.OFF
|
||||
|
||||
# Simulate pubsub message when mode changes
|
||||
await create_event(
|
||||
|
@ -476,8 +469,8 @@ async def test_thermostat_set_hvac_mode(
|
|||
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_HEAT
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
|
||||
assert thermostat.state == HVACMode.HEAT
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE
|
||||
|
||||
# Simulate pubsub message when the thermostat starts heating
|
||||
await create_event(
|
||||
|
@ -490,8 +483,8 @@ async def test_thermostat_set_hvac_mode(
|
|||
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_HEAT
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_HEAT
|
||||
assert thermostat.state == HVACMode.HEAT
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.HEATING
|
||||
|
||||
|
||||
async def test_thermostat_invalid_hvac_mode(
|
||||
|
@ -515,14 +508,14 @@ async def test_thermostat_invalid_hvac_mode(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_OFF
|
||||
assert thermostat.state == HVACMode.OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.OFF
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
await common.async_set_hvac_mode(hass, HVAC_MODE_DRY)
|
||||
await common.async_set_hvac_mode(hass, HVACMode.DRY)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert thermostat.state == HVAC_MODE_OFF
|
||||
assert thermostat.state == HVACMode.OFF
|
||||
assert auth.method is None # No communication with API
|
||||
|
||||
|
||||
|
@ -554,8 +547,8 @@ async def test_thermostat_set_eco_preset(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_OFF
|
||||
assert thermostat.state == HVACMode.OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.OFF
|
||||
assert thermostat.attributes[ATTR_PRESET_MODE] == PRESET_NONE
|
||||
|
||||
# Turn on eco mode
|
||||
|
@ -572,8 +565,8 @@ async def test_thermostat_set_eco_preset(
|
|||
# Local state does not reflect the update
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_OFF
|
||||
assert thermostat.state == HVACMode.OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.OFF
|
||||
assert thermostat.attributes[ATTR_PRESET_MODE] == PRESET_NONE
|
||||
|
||||
# Simulate pubsub message when mode changes
|
||||
|
@ -590,8 +583,8 @@ async def test_thermostat_set_eco_preset(
|
|||
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_OFF
|
||||
assert thermostat.state == HVACMode.OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.OFF
|
||||
assert thermostat.attributes[ATTR_PRESET_MODE] == PRESET_ECO
|
||||
|
||||
# Turn off eco mode
|
||||
|
@ -630,7 +623,7 @@ async def test_thermostat_set_cool(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_COOL
|
||||
assert thermostat.state == HVACMode.COOL
|
||||
|
||||
await common.async_set_temperature(hass, temperature=24.0)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -667,7 +660,7 @@ async def test_thermostat_set_heat(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_HEAT
|
||||
assert thermostat.state == HVACMode.HEAT
|
||||
|
||||
await common.async_set_temperature(hass, temperature=20.0)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -704,9 +697,9 @@ async def test_thermostat_set_temperature_hvac_mode(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_OFF
|
||||
assert thermostat.state == HVACMode.OFF
|
||||
|
||||
await common.async_set_temperature(hass, temperature=24.0, hvac_mode=HVAC_MODE_COOL)
|
||||
await common.async_set_temperature(hass, temperature=24.0, hvac_mode=HVACMode.COOL)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert auth.method == "post"
|
||||
|
@ -716,7 +709,7 @@ async def test_thermostat_set_temperature_hvac_mode(
|
|||
"params": {"coolCelsius": 24.0},
|
||||
}
|
||||
|
||||
await common.async_set_temperature(hass, temperature=26.0, hvac_mode=HVAC_MODE_HEAT)
|
||||
await common.async_set_temperature(hass, temperature=26.0, hvac_mode=HVACMode.HEAT)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert auth.method == "post"
|
||||
|
@ -727,7 +720,7 @@ async def test_thermostat_set_temperature_hvac_mode(
|
|||
}
|
||||
|
||||
await common.async_set_temperature(
|
||||
hass, target_temp_low=20.0, target_temp_high=24.0, hvac_mode=HVAC_MODE_HEAT_COOL
|
||||
hass, target_temp_low=20.0, target_temp_high=24.0, hvac_mode=HVACMode.HEAT_COOL
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
@ -764,7 +757,7 @@ async def test_thermostat_set_heat_cool(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_HEAT_COOL
|
||||
assert thermostat.state == HVACMode.HEAT_COOL
|
||||
|
||||
await common.async_set_temperature(
|
||||
hass, target_temp_low=20.0, target_temp_high=24.0
|
||||
|
@ -806,14 +799,14 @@ async def test_thermostat_fan_off(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
|
||||
assert thermostat.state == HVACMode.COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 16.2
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
HVACMode.HEAT,
|
||||
HVACMode.COOL,
|
||||
HVACMode.HEAT_COOL,
|
||||
HVACMode.OFF,
|
||||
}
|
||||
assert thermostat.attributes[ATTR_FAN_MODE] == FAN_OFF
|
||||
assert thermostat.attributes[ATTR_FAN_MODES] == [FAN_ON, FAN_OFF]
|
||||
|
@ -853,14 +846,14 @@ async def test_thermostat_fan_on(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
|
||||
assert thermostat.state == HVACMode.COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 16.2
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
HVACMode.HEAT,
|
||||
HVACMode.COOL,
|
||||
HVACMode.HEAT_COOL,
|
||||
HVACMode.OFF,
|
||||
}
|
||||
assert thermostat.attributes[ATTR_FAN_MODE] == FAN_ON
|
||||
assert thermostat.attributes[ATTR_FAN_MODES] == [FAN_ON, FAN_OFF]
|
||||
|
@ -897,13 +890,13 @@ async def test_thermostat_cool_with_fan(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
|
||||
assert thermostat.state == HVACMode.COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
HVACMode.HEAT,
|
||||
HVACMode.COOL,
|
||||
HVACMode.HEAT_COOL,
|
||||
HVACMode.OFF,
|
||||
}
|
||||
assert thermostat.attributes[ATTR_FAN_MODE] == FAN_ON
|
||||
assert thermostat.attributes[ATTR_FAN_MODES] == [FAN_ON, FAN_OFF]
|
||||
|
@ -941,7 +934,7 @@ async def test_thermostat_set_fan(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_HEAT
|
||||
assert thermostat.state == HVACMode.HEAT
|
||||
assert thermostat.attributes[ATTR_FAN_MODE] == FAN_ON
|
||||
assert thermostat.attributes[ATTR_FAN_MODES] == [FAN_ON, FAN_OFF]
|
||||
assert thermostat.attributes[ATTR_SUPPORTED_FEATURES] == (
|
||||
|
@ -1003,7 +996,7 @@ async def test_thermostat_set_fan_when_off(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_OFF
|
||||
assert thermostat.state == HVACMode.OFF
|
||||
assert thermostat.attributes[ATTR_FAN_MODE] == FAN_ON
|
||||
assert thermostat.attributes[ATTR_FAN_MODES] == [FAN_ON, FAN_OFF]
|
||||
assert thermostat.attributes[ATTR_SUPPORTED_FEATURES] == (
|
||||
|
@ -1041,14 +1034,14 @@ async def test_thermostat_fan_empty(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_OFF
|
||||
assert thermostat.state == HVACMode.OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.OFF
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 16.2
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
HVACMode.HEAT,
|
||||
HVACMode.COOL,
|
||||
HVACMode.HEAT_COOL,
|
||||
HVACMode.OFF,
|
||||
}
|
||||
assert ATTR_FAN_MODE not in thermostat.attributes
|
||||
assert ATTR_FAN_MODES not in thermostat.attributes
|
||||
|
@ -1092,14 +1085,14 @@ async def test_thermostat_invalid_fan_mode(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
|
||||
assert thermostat.state == HVACMode.COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 16.2
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
HVACMode.HEAT,
|
||||
HVACMode.COOL,
|
||||
HVACMode.HEAT_COOL,
|
||||
HVACMode.OFF,
|
||||
}
|
||||
assert thermostat.attributes[ATTR_FAN_MODE] == FAN_ON
|
||||
assert thermostat.attributes[ATTR_FAN_MODES] == [FAN_ON, FAN_OFF]
|
||||
|
@ -1138,7 +1131,7 @@ async def test_thermostat_target_temp(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_HEAT
|
||||
assert thermostat.state == HVACMode.HEAT
|
||||
assert thermostat.attributes[ATTR_TEMPERATURE] == 23.0
|
||||
assert thermostat.attributes[ATTR_TARGET_TEMP_LOW] is None
|
||||
assert thermostat.attributes[ATTR_TARGET_TEMP_HIGH] is None
|
||||
|
@ -1159,7 +1152,7 @@ async def test_thermostat_target_temp(
|
|||
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_HEAT_COOL
|
||||
assert thermostat.state == HVACMode.HEAT_COOL
|
||||
assert thermostat.attributes[ATTR_TARGET_TEMP_LOW] == 22.0
|
||||
assert thermostat.attributes[ATTR_TARGET_TEMP_HIGH] == 28.0
|
||||
assert thermostat.attributes[ATTR_TEMPERATURE] is None
|
||||
|
@ -1181,8 +1174,8 @@ async def test_thermostat_missing_mode_traits(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_OFF
|
||||
assert thermostat.state == HVACMode.OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.OFF
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] is None
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == set()
|
||||
assert ATTR_TEMPERATURE not in thermostat.attributes
|
||||
|
@ -1222,14 +1215,14 @@ async def test_thermostat_missing_temperature_trait(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_HEAT
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
|
||||
assert thermostat.state == HVACMode.HEAT
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] is None
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
HVACMode.HEAT,
|
||||
HVACMode.COOL,
|
||||
HVACMode.HEAT_COOL,
|
||||
HVACMode.OFF,
|
||||
}
|
||||
assert thermostat.attributes[ATTR_TEMPERATURE] is None
|
||||
assert thermostat.attributes[ATTR_TARGET_TEMP_LOW] is None
|
||||
|
@ -1260,7 +1253,7 @@ async def test_thermostat_unexpected_hvac_status(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_OFF
|
||||
assert thermostat.state == HVACMode.OFF
|
||||
assert ATTR_HVAC_ACTION not in thermostat.attributes
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] is None
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == set()
|
||||
|
@ -1273,9 +1266,9 @@ async def test_thermostat_unexpected_hvac_status(
|
|||
assert ATTR_FAN_MODES not in thermostat.attributes
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
await common.async_set_hvac_mode(hass, HVAC_MODE_DRY)
|
||||
await common.async_set_hvac_mode(hass, HVACMode.DRY)
|
||||
await hass.async_block_till_done()
|
||||
assert thermostat.state == HVAC_MODE_OFF
|
||||
assert thermostat.state == HVACMode.OFF
|
||||
|
||||
|
||||
async def test_thermostat_missing_set_point(
|
||||
|
@ -1298,14 +1291,14 @@ async def test_thermostat_missing_set_point(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_HEAT_COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
|
||||
assert thermostat.state == HVACMode.HEAT_COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] is None
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
HVACMode.HEAT,
|
||||
HVACMode.COOL,
|
||||
HVACMode.HEAT_COOL,
|
||||
HVACMode.OFF,
|
||||
}
|
||||
assert thermostat.attributes[ATTR_TEMPERATURE] is None
|
||||
assert thermostat.attributes[ATTR_TARGET_TEMP_LOW] is None
|
||||
|
@ -1336,14 +1329,14 @@ async def test_thermostat_unexepected_hvac_mode(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_OFF
|
||||
assert thermostat.state == HVACMode.OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.OFF
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] is None
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
HVACMode.HEAT,
|
||||
HVACMode.COOL,
|
||||
HVACMode.HEAT_COOL,
|
||||
HVACMode.OFF,
|
||||
}
|
||||
assert thermostat.attributes[ATTR_TEMPERATURE] is None
|
||||
assert thermostat.attributes[ATTR_TARGET_TEMP_LOW] is None
|
||||
|
@ -1377,7 +1370,7 @@ async def test_thermostat_invalid_set_preset_mode(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_OFF
|
||||
assert thermostat.state == HVACMode.OFF
|
||||
assert thermostat.attributes[ATTR_PRESET_MODE] == PRESET_NONE
|
||||
assert thermostat.attributes[ATTR_PRESET_MODES] == [PRESET_ECO, PRESET_NONE]
|
||||
|
||||
|
@ -1425,18 +1418,18 @@ async def test_thermostat_hvac_mode_failure(
|
|||
assert len(hass.states.async_all()) == 1
|
||||
thermostat = hass.states.get("climate.my_thermostat")
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVAC_MODE_COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
|
||||
assert thermostat.state == HVACMode.COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE
|
||||
|
||||
auth.responses = [aiohttp.web.Response(status=HTTPStatus.BAD_REQUEST)]
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await common.async_set_hvac_mode(hass, HVAC_MODE_HEAT)
|
||||
await common.async_set_hvac_mode(hass, HVACMode.HEAT)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
auth.responses = [aiohttp.web.Response(status=HTTPStatus.BAD_REQUEST)]
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await common.async_set_temperature(
|
||||
hass, hvac_mode=HVAC_MODE_HEAT, temperature=25.0
|
||||
hass, hvac_mode=HVACMode.HEAT, temperature=25.0
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
|
|
@ -22,14 +22,12 @@ from homeassistant.components import (
|
|||
sensor,
|
||||
switch,
|
||||
)
|
||||
from homeassistant.components.climate.const import (
|
||||
from homeassistant.components.climate import (
|
||||
ATTR_CURRENT_TEMPERATURE,
|
||||
ATTR_HUMIDITY,
|
||||
ATTR_HVAC_ACTION,
|
||||
ATTR_TARGET_TEMP_HIGH,
|
||||
ATTR_TARGET_TEMP_LOW,
|
||||
CURRENT_HVAC_COOL,
|
||||
CURRENT_HVAC_HEAT,
|
||||
)
|
||||
from homeassistant.components.humidifier import ATTR_AVAILABLE_MODES
|
||||
from homeassistant.components.sensor import SensorDeviceClass
|
||||
|
@ -520,7 +518,10 @@ async def test_renaming_entity_name(
|
|||
ATTR_FRIENDLY_NAME: "HeatPump Renamed",
|
||||
}
|
||||
set_state_with_entry(
|
||||
hass, data["climate_1"], CURRENT_HVAC_HEAT, data["climate_1_attributes"]
|
||||
hass,
|
||||
data["climate_1"],
|
||||
climate.HVACAction.HEATING,
|
||||
data["climate_1_attributes"],
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
@ -971,9 +972,11 @@ async def climate_fixture(hass, registry):
|
|||
climate_1_attributes = {
|
||||
ATTR_TEMPERATURE: 20,
|
||||
ATTR_CURRENT_TEMPERATURE: 25,
|
||||
ATTR_HVAC_ACTION: CURRENT_HVAC_HEAT,
|
||||
ATTR_HVAC_ACTION: climate.HVACAction.HEATING,
|
||||
}
|
||||
set_state_with_entry(hass, climate_1, CURRENT_HVAC_HEAT, climate_1_attributes)
|
||||
set_state_with_entry(
|
||||
hass, climate_1, climate.HVACAction.HEATING, climate_1_attributes
|
||||
)
|
||||
data["climate_1"] = climate_1
|
||||
data["climate_1_attributes"] = climate_1_attributes
|
||||
|
||||
|
@ -990,9 +993,11 @@ async def climate_fixture(hass, registry):
|
|||
ATTR_CURRENT_TEMPERATURE: 22,
|
||||
ATTR_TARGET_TEMP_LOW: 21,
|
||||
ATTR_TARGET_TEMP_HIGH: 24,
|
||||
ATTR_HVAC_ACTION: CURRENT_HVAC_COOL,
|
||||
ATTR_HVAC_ACTION: climate.HVACAction.COOLING,
|
||||
}
|
||||
set_state_with_entry(hass, climate_2, CURRENT_HVAC_HEAT, climate_2_attributes)
|
||||
set_state_with_entry(
|
||||
hass, climate_2, climate.HVACAction.HEATING, climate_2_attributes
|
||||
)
|
||||
data["climate_2"] = climate_2
|
||||
data["climate_2_attributes"] = climate_2_attributes
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue