Improved Alexa ThermostatController thermostatMode handling (#28176)
* Update ThermostatController to map directives to supported modes and add support for CUSTOM mode. * Removed erroneous config value from test. * Removed unnecessary use of a comprehension by dumbing down comment so pylint could comprehend. * Removed erroneous import variable caused by removing erroneous config value from test. * Removed unnecessary use of a comprehension. * Reverted Removal or erroneous import variable and erroneous config value from test. Apparently need for additional tests outside this component. Whoops.
This commit is contained in:
parent
f4341c1546
commit
d44bfa8e88
5 changed files with 105 additions and 11 deletions
|
@ -1267,7 +1267,7 @@ async def test_thermostat(hass):
|
|||
"current_temperature": 75.0,
|
||||
"friendly_name": "Test Thermostat",
|
||||
"supported_features": 1 | 2 | 4 | 128,
|
||||
"hvac_modes": ["heat", "cool", "auto", "off"],
|
||||
"hvac_modes": ["off", "heat", "cool", "auto", "dry"],
|
||||
"preset_mode": None,
|
||||
"preset_modes": ["eco"],
|
||||
"min_temp": 50,
|
||||
|
@ -1280,7 +1280,7 @@ async def test_thermostat(hass):
|
|||
assert appliance["displayCategories"][0] == "THERMOSTAT"
|
||||
assert appliance["friendlyName"] == "Test Thermostat"
|
||||
|
||||
assert_endpoint_capabilities(
|
||||
capabilities = assert_endpoint_capabilities(
|
||||
appliance,
|
||||
"Alexa.PowerController",
|
||||
"Alexa.ThermostatController",
|
||||
|
@ -1299,6 +1299,15 @@ async def test_thermostat(hass):
|
|||
"Alexa.TemperatureSensor", "temperature", {"value": 75.0, "scale": "FAHRENHEIT"}
|
||||
)
|
||||
|
||||
thermostat_capability = get_capability(capabilities, "Alexa.ThermostatController")
|
||||
assert thermostat_capability is not None
|
||||
configuration = thermostat_capability["configuration"]
|
||||
assert configuration["supportsScheduling"] is False
|
||||
|
||||
supported_modes = ["OFF", "HEAT", "COOL", "AUTO", "ECO", "CUSTOM"]
|
||||
for mode in supported_modes:
|
||||
assert mode in configuration["supportedModes"]
|
||||
|
||||
call, msg = await assert_request_calls_service(
|
||||
"Alexa.ThermostatController",
|
||||
"SetTargetTemperature",
|
||||
|
@ -1447,6 +1456,30 @@ async def test_thermostat(hass):
|
|||
properties = ReportedProperties(msg["context"]["properties"])
|
||||
properties.assert_equal("Alexa.ThermostatController", "thermostatMode", "HEAT")
|
||||
|
||||
# Assert we can call custom modes
|
||||
call, msg = await assert_request_calls_service(
|
||||
"Alexa.ThermostatController",
|
||||
"SetThermostatMode",
|
||||
"climate#test_thermostat",
|
||||
"climate.set_hvac_mode",
|
||||
hass,
|
||||
payload={"thermostatMode": {"value": "CUSTOM", "customName": "DEHUMIDIFY"}},
|
||||
)
|
||||
assert call.data["hvac_mode"] == "dry"
|
||||
properties = ReportedProperties(msg["context"]["properties"])
|
||||
properties.assert_equal("Alexa.ThermostatController", "thermostatMode", "CUSTOM")
|
||||
|
||||
# assert unsupported custom mode
|
||||
msg = await assert_request_fails(
|
||||
"Alexa.ThermostatController",
|
||||
"SetThermostatMode",
|
||||
"climate#test_thermostat",
|
||||
"climate.set_hvac_mode",
|
||||
hass,
|
||||
payload={"thermostatMode": {"value": "CUSTOM", "customName": "INVALID"}},
|
||||
)
|
||||
assert msg["event"]["payload"]["type"] == "UNSUPPORTED_THERMOSTAT_MODE"
|
||||
|
||||
msg = await assert_request_fails(
|
||||
"Alexa.ThermostatController",
|
||||
"SetThermostatMode",
|
||||
|
@ -1456,7 +1489,6 @@ async def test_thermostat(hass):
|
|||
payload={"thermostatMode": {"value": "INVALID"}},
|
||||
)
|
||||
assert msg["event"]["payload"]["type"] == "UNSUPPORTED_THERMOSTAT_MODE"
|
||||
hass.config.units.temperature_unit = TEMP_CELSIUS
|
||||
|
||||
call, _ = await assert_request_calls_service(
|
||||
"Alexa.ThermostatController",
|
||||
|
@ -1479,6 +1511,9 @@ async def test_thermostat(hass):
|
|||
)
|
||||
assert call.data["preset_mode"] == "eco"
|
||||
|
||||
# Reset config temperature_unit back to CELSIUS, required for additional tests outside this component.
|
||||
hass.config.units.temperature_unit = TEMP_CELSIUS
|
||||
|
||||
|
||||
async def test_exclude_filters(hass):
|
||||
"""Test exclusion filters."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue