mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Allow climate operation mode fan_only as custom mode in Alexa (#76148)
* Add support for FAN_ONLY mode * Tests for fan_only as custom mode
This commit is contained in:
parent
22eba6ce1b
commit
e6e5b98bc7
@ -73,11 +73,14 @@ API_THERMOSTAT_MODES = OrderedDict(
|
||||
(climate.HVACMode.HEAT_COOL, "AUTO"),
|
||||
(climate.HVACMode.AUTO, "AUTO"),
|
||||
(climate.HVACMode.OFF, "OFF"),
|
||||
(climate.HVACMode.FAN_ONLY, "OFF"),
|
||||
(climate.HVACMode.FAN_ONLY, "CUSTOM"),
|
||||
(climate.HVACMode.DRY, "CUSTOM"),
|
||||
]
|
||||
)
|
||||
API_THERMOSTAT_MODES_CUSTOM = {climate.HVACMode.DRY: "DEHUMIDIFY"}
|
||||
API_THERMOSTAT_MODES_CUSTOM = {
|
||||
climate.HVACMode.DRY: "DEHUMIDIFY",
|
||||
climate.HVACMode.FAN_ONLY: "FAN",
|
||||
}
|
||||
API_THERMOSTAT_PRESETS = {climate.PRESET_ECO: "ECO"}
|
||||
|
||||
# AlexaModeController does not like a single mode for the fan preset, we add PRESET_MODE_NA if a fan has only one preset_mode
|
||||
|
@ -590,7 +590,7 @@ async def test_report_climate_state(hass):
|
||||
{"value": 34.0, "scale": "CELSIUS"},
|
||||
)
|
||||
|
||||
for off_modes in (climate.HVAC_MODE_OFF, climate.HVAC_MODE_FAN_ONLY):
|
||||
for off_modes in [climate.HVAC_MODE_OFF]:
|
||||
hass.states.async_set(
|
||||
"climate.downstairs",
|
||||
off_modes,
|
||||
@ -626,6 +626,23 @@ async def test_report_climate_state(hass):
|
||||
"Alexa.TemperatureSensor", "temperature", {"value": 34.0, "scale": "CELSIUS"}
|
||||
)
|
||||
|
||||
# assert fan_only is reported as CUSTOM
|
||||
hass.states.async_set(
|
||||
"climate.downstairs",
|
||||
"fan_only",
|
||||
{
|
||||
"friendly_name": "Climate Downstairs",
|
||||
"supported_features": 91,
|
||||
climate.ATTR_CURRENT_TEMPERATURE: 31,
|
||||
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
|
||||
},
|
||||
)
|
||||
properties = await reported_properties(hass, "climate.downstairs")
|
||||
properties.assert_equal("Alexa.ThermostatController", "thermostatMode", "CUSTOM")
|
||||
properties.assert_equal(
|
||||
"Alexa.TemperatureSensor", "temperature", {"value": 31.0, "scale": "CELSIUS"}
|
||||
)
|
||||
|
||||
hass.states.async_set(
|
||||
"climate.heat",
|
||||
"heat",
|
||||
|
@ -2030,7 +2030,7 @@ async def test_thermostat(hass):
|
||||
"current_temperature": 75.0,
|
||||
"friendly_name": "Test Thermostat",
|
||||
"supported_features": 1 | 2 | 4 | 128,
|
||||
"hvac_modes": ["off", "heat", "cool", "auto", "dry"],
|
||||
"hvac_modes": ["off", "heat", "cool", "auto", "dry", "fan_only"],
|
||||
"preset_mode": None,
|
||||
"preset_modes": ["eco"],
|
||||
"min_temp": 50,
|
||||
@ -2220,7 +2220,7 @@ async def test_thermostat(hass):
|
||||
properties = ReportedProperties(msg["context"]["properties"])
|
||||
properties.assert_equal("Alexa.ThermostatController", "thermostatMode", "HEAT")
|
||||
|
||||
# Assert we can call custom modes
|
||||
# Assert we can call custom modes for dry and fan_only
|
||||
call, msg = await assert_request_calls_service(
|
||||
"Alexa.ThermostatController",
|
||||
"SetThermostatMode",
|
||||
@ -2233,6 +2233,18 @@ async def test_thermostat(hass):
|
||||
properties = ReportedProperties(msg["context"]["properties"])
|
||||
properties.assert_equal("Alexa.ThermostatController", "thermostatMode", "CUSTOM")
|
||||
|
||||
call, msg = await assert_request_calls_service(
|
||||
"Alexa.ThermostatController",
|
||||
"SetThermostatMode",
|
||||
"climate#test_thermostat",
|
||||
"climate.set_hvac_mode",
|
||||
hass,
|
||||
payload={"thermostatMode": {"value": "CUSTOM", "customName": "FAN"}},
|
||||
)
|
||||
assert call.data["hvac_mode"] == "fan_only"
|
||||
properties = ReportedProperties(msg["context"]["properties"])
|
||||
properties.assert_equal("Alexa.ThermostatController", "thermostatMode", "CUSTOM")
|
||||
|
||||
# assert unsupported custom mode
|
||||
msg = await assert_request_fails(
|
||||
"Alexa.ThermostatController",
|
||||
|
Loading…
x
Reference in New Issue
Block a user