Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix operation mode for Alexa thermostat #17972

Merged
merged 1 commit into from Oct 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 14 additions & 10 deletions homeassistant/components/alexa/smart_home.py
@@ -1,4 +1,5 @@
"""Support for alexa Smart Home Skill API."""
from collections import OrderedDict
import logging
import math
from datetime import datetime
Expand Down Expand Up @@ -37,16 +38,19 @@
TEMP_CELSIUS: 'CELSIUS',
}

API_THERMOSTAT_MODES = {
climate.STATE_HEAT: 'HEAT',
climate.STATE_COOL: 'COOL',
climate.STATE_AUTO: 'AUTO',
climate.STATE_ECO: 'ECO',
climate.STATE_OFF: 'OFF',
climate.STATE_IDLE: 'OFF',
climate.STATE_FAN_ONLY: 'OFF',
climate.STATE_DRY: 'OFF',
}
# Needs to be ordered dict for `async_api_set_thermostat_mode` which does a
# reverse mapping of this dict and we want to map the first occurrance of OFF
# back to HA state.
API_THERMOSTAT_MODES = OrderedDict([
(climate.STATE_HEAT, 'HEAT'),
(climate.STATE_COOL, 'COOL'),
(climate.STATE_AUTO, 'AUTO'),
(climate.STATE_ECO, 'ECO'),
(climate.STATE_OFF, 'OFF'),
(climate.STATE_IDLE, 'OFF'),
(climate.STATE_FAN_ONLY, 'OFF'),
(climate.STATE_DRY, 'OFF')
])

SMART_HOME_HTTP_ENDPOINT = '/api/alexa/smart_home'

Expand Down
8 changes: 8 additions & 0 deletions tests/components/alexa/test_smart_home.py
Expand Up @@ -902,6 +902,14 @@ async def test_thermostat(hass):
assert msg['event']['payload']['type'] == 'UNSUPPORTED_THERMOSTAT_MODE'
hass.config.units.temperature_unit = TEMP_CELSIUS

call, _ = await assert_request_calls_service(
'Alexa.ThermostatController', 'SetThermostatMode',
'climate#test_thermostat', 'climate.set_operation_mode',
hass,
payload={'thermostatMode': 'OFF'}
)
assert call.data['operation_mode'] == 'off'


@asyncio.coroutine
def test_exclude_filters(hass):
Expand Down