core/homeassistant/components/cloud
Phil Frost e16793013a
Refactor Alexa API, fix thermostats (#17969)
* Refactor Alexa API to use objects for requests

This introduces _AlexaDirective to stand in for the previous model of passing
basic dict and list data structures to and from handlers. This gives a more
expressive platform for functionality common to most or all handlers.

I had two use cases in mind:

1) Most responses should include current properties. In the case of locks and
thermostats, the response must include the properties or Alexa will give the
user a vague error like "Hmm, $device is not responding." Locks currently work,
but thermostats do not. I wanted a way to automatically include properties in
all responses. This is implemented in a subsequent commit.

2) The previous model had a 1:1 mapping between Alexa endpoints and Home
Assistant entities. This works most of the time, but sometimes it's not so
great. For example, my Z-wave thermostat shows as three devices in Alexa: one
for the temperature sensor, one for the heat, and one for the AC. I'd like to
merge these into one device from Alexa's perspective. I believe this will be
facilitated with the `endpoint` attribute on `_AlexaDirective`.

* Include properties in all Alexa responses

The added _AlexaResponse class provides a richer vocabulary for handlers.

Among that vocabulary is .merge_context_properties(), which is invoked
automatically for any request directed at an endpoint. This adds all supported
properties to the response as recommended by the Alexa API docs, and in some
cases (locks, thermostats at least) the user will get an error "Hmm, $device is
not responding" if properties are not provided in the response.

* Fix setting temperature with Alexa thermostats

Fixes https://github.com/home-assistant/home-assistant/issues/16577
2018-10-29 22:16:35 -04:00
..
__init__.py Don't use keyset (#17984) 2018-10-29 21:25:17 +01:00
auth_api.py Upgrade flake8 to 3.6.0 (#17770) 2018-10-25 23:15:20 +03:00
const.py Add subscription info endpoint (#16727) 2018-09-20 14:53:13 +02:00
http_api.py Reconnect if sub info comes in that is valid again (#17651) 2018-10-21 12:16:24 +02:00
iot.py Refactor Alexa API, fix thermostats (#17969) 2018-10-29 22:16:35 -04:00