Use climate enums in homekit_controller (#70663)
This commit is contained in:
parent
e235926037
commit
62c8687a86
2 changed files with 75 additions and 84 deletions
|
@ -10,14 +10,11 @@ from aiohomekit.model.services import ServicesTypes
|
|||
|
||||
from homeassistant.components.climate.const import (
|
||||
DOMAIN,
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
SERVICE_SET_SWING_MODE,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
HVACMode,
|
||||
)
|
||||
|
||||
from tests.components.homekit_controller.common import setup_test_component
|
||||
|
@ -98,7 +95,7 @@ async def test_climate_change_thermostat_state(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT},
|
||||
blocking=True,
|
||||
)
|
||||
helper.async_assert_service_values(
|
||||
|
@ -111,7 +108,7 @@ async def test_climate_change_thermostat_state(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_COOL},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.COOL},
|
||||
blocking=True,
|
||||
)
|
||||
helper.async_assert_service_values(
|
||||
|
@ -124,7 +121,7 @@ async def test_climate_change_thermostat_state(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT_COOL},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT_COOL},
|
||||
blocking=True,
|
||||
)
|
||||
helper.async_assert_service_values(
|
||||
|
@ -137,7 +134,7 @@ async def test_climate_change_thermostat_state(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_OFF},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.OFF},
|
||||
blocking=True,
|
||||
)
|
||||
helper.async_assert_service_values(
|
||||
|
@ -155,7 +152,7 @@ async def test_climate_check_min_max_values_per_mode(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT},
|
||||
blocking=True,
|
||||
)
|
||||
climate_state = await helper.poll_and_get_state()
|
||||
|
@ -165,7 +162,7 @@ async def test_climate_check_min_max_values_per_mode(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_COOL},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.COOL},
|
||||
blocking=True,
|
||||
)
|
||||
climate_state = await helper.poll_and_get_state()
|
||||
|
@ -175,7 +172,7 @@ async def test_climate_check_min_max_values_per_mode(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT_COOL},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT_COOL},
|
||||
blocking=True,
|
||||
)
|
||||
climate_state = await helper.poll_and_get_state()
|
||||
|
@ -221,7 +218,7 @@ async def test_climate_change_thermostat_temperature_range(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT_COOL},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT_COOL},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
|
@ -230,7 +227,7 @@ async def test_climate_change_thermostat_temperature_range(hass, utcnow):
|
|||
SERVICE_SET_TEMPERATURE,
|
||||
{
|
||||
"entity_id": "climate.testdevice",
|
||||
"hvac_mode": HVAC_MODE_HEAT_COOL,
|
||||
"hvac_mode": HVACMode.HEAT_COOL,
|
||||
"target_temp_high": 25,
|
||||
"target_temp_low": 20,
|
||||
},
|
||||
|
@ -254,7 +251,7 @@ async def test_climate_change_thermostat_temperature_range_iphone(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT_COOL},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT_COOL},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
|
@ -263,7 +260,7 @@ async def test_climate_change_thermostat_temperature_range_iphone(hass, utcnow):
|
|||
SERVICE_SET_TEMPERATURE,
|
||||
{
|
||||
"entity_id": "climate.testdevice",
|
||||
"hvac_mode": HVAC_MODE_HEAT_COOL,
|
||||
"hvac_mode": HVACMode.HEAT_COOL,
|
||||
"temperature": 22,
|
||||
"target_temp_low": 20,
|
||||
"target_temp_high": 24,
|
||||
|
@ -287,7 +284,7 @@ async def test_climate_cannot_set_thermostat_temp_range_in_wrong_mode(hass, utcn
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
|
@ -344,7 +341,7 @@ async def test_climate_check_min_max_values_per_mode_sspa_device(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT},
|
||||
blocking=True,
|
||||
)
|
||||
climate_state = await helper.poll_and_get_state()
|
||||
|
@ -354,7 +351,7 @@ async def test_climate_check_min_max_values_per_mode_sspa_device(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_COOL},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.COOL},
|
||||
blocking=True,
|
||||
)
|
||||
climate_state = await helper.poll_and_get_state()
|
||||
|
@ -364,7 +361,7 @@ async def test_climate_check_min_max_values_per_mode_sspa_device(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT_COOL},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT_COOL},
|
||||
blocking=True,
|
||||
)
|
||||
climate_state = await helper.poll_and_get_state()
|
||||
|
@ -379,7 +376,7 @@ async def test_climate_set_thermostat_temp_on_sspa_device(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
|
@ -399,7 +396,7 @@ async def test_climate_set_thermostat_temp_on_sspa_device(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT_COOL},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT_COOL},
|
||||
blocking=True,
|
||||
)
|
||||
helper.async_assert_service_values(
|
||||
|
@ -436,7 +433,7 @@ async def test_climate_set_mode_via_temp(hass, utcnow):
|
|||
{
|
||||
"entity_id": "climate.testdevice",
|
||||
"temperature": 21,
|
||||
"hvac_mode": HVAC_MODE_HEAT,
|
||||
"hvac_mode": HVACMode.HEAT,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
@ -453,7 +450,7 @@ async def test_climate_set_mode_via_temp(hass, utcnow):
|
|||
SERVICE_SET_TEMPERATURE,
|
||||
{
|
||||
"entity_id": "climate.testdevice",
|
||||
"hvac_mode": HVAC_MODE_HEAT_COOL,
|
||||
"hvac_mode": HVACMode.HEAT_COOL,
|
||||
"temperature": 22,
|
||||
},
|
||||
blocking=True,
|
||||
|
@ -516,7 +513,7 @@ async def test_climate_read_thermostat_state(hass, utcnow):
|
|||
)
|
||||
|
||||
state = await helper.poll_and_get_state()
|
||||
assert state.state == HVAC_MODE_HEAT
|
||||
assert state.state == HVACMode.HEAT
|
||||
assert state.attributes["current_temperature"] == 19
|
||||
assert state.attributes["current_humidity"] == 50
|
||||
assert state.attributes["min_temp"] == 7
|
||||
|
@ -536,7 +533,7 @@ async def test_climate_read_thermostat_state(hass, utcnow):
|
|||
)
|
||||
|
||||
state = await helper.poll_and_get_state()
|
||||
assert state.state == HVAC_MODE_COOL
|
||||
assert state.state == HVACMode.COOL
|
||||
assert state.attributes["current_temperature"] == 21
|
||||
assert state.attributes["current_humidity"] == 45
|
||||
|
||||
|
@ -552,7 +549,7 @@ async def test_climate_read_thermostat_state(hass, utcnow):
|
|||
)
|
||||
|
||||
state = await helper.poll_and_get_state()
|
||||
assert state.state == HVAC_MODE_HEAT_COOL
|
||||
assert state.state == HVACMode.HEAT_COOL
|
||||
|
||||
|
||||
async def test_hvac_mode_vs_hvac_action(hass, utcnow):
|
||||
|
@ -661,7 +658,7 @@ async def test_heater_cooler_change_thermostat_state(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT},
|
||||
blocking=True,
|
||||
)
|
||||
helper.async_assert_service_values(
|
||||
|
@ -674,7 +671,7 @@ async def test_heater_cooler_change_thermostat_state(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_COOL},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.COOL},
|
||||
blocking=True,
|
||||
)
|
||||
helper.async_assert_service_values(
|
||||
|
@ -687,7 +684,7 @@ async def test_heater_cooler_change_thermostat_state(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT_COOL},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT_COOL},
|
||||
blocking=True,
|
||||
)
|
||||
helper.async_assert_service_values(
|
||||
|
@ -700,7 +697,7 @@ async def test_heater_cooler_change_thermostat_state(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_OFF},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.OFF},
|
||||
blocking=True,
|
||||
)
|
||||
helper.async_assert_service_values(
|
||||
|
@ -718,7 +715,7 @@ async def test_heater_cooler_change_thermostat_temperature(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.services.async_call(
|
||||
|
@ -737,7 +734,7 @@ async def test_heater_cooler_change_thermostat_temperature(hass, utcnow):
|
|||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_COOL},
|
||||
{"entity_id": "climate.testdevice", "hvac_mode": HVACMode.COOL},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.services.async_call(
|
||||
|
@ -771,7 +768,7 @@ async def test_heater_cooler_read_thermostat_state(hass, utcnow):
|
|||
)
|
||||
|
||||
state = await helper.poll_and_get_state()
|
||||
assert state.state == HVAC_MODE_HEAT
|
||||
assert state.state == HVACMode.HEAT
|
||||
assert state.attributes["current_temperature"] == 19
|
||||
assert state.attributes["min_temp"] == 7
|
||||
assert state.attributes["max_temp"] == 35
|
||||
|
@ -789,7 +786,7 @@ async def test_heater_cooler_read_thermostat_state(hass, utcnow):
|
|||
)
|
||||
|
||||
state = await helper.poll_and_get_state()
|
||||
assert state.state == HVAC_MODE_COOL
|
||||
assert state.state == HVACMode.COOL
|
||||
assert state.attributes["current_temperature"] == 21
|
||||
|
||||
# Simulate that we are in auto mode
|
||||
|
@ -805,7 +802,7 @@ async def test_heater_cooler_read_thermostat_state(hass, utcnow):
|
|||
)
|
||||
|
||||
state = await helper.poll_and_get_state()
|
||||
assert state.state == HVAC_MODE_HEAT_COOL
|
||||
assert state.state == HVACMode.HEAT_COOL
|
||||
|
||||
|
||||
async def test_heater_cooler_hvac_mode_vs_hvac_action(hass, utcnow):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue