Report correct thermostat mode to Alexa (#18053)

We were erroneously reporting the _previous_ mode. So if the thermostat was off
and the user asks, "Alexa, set the thermostat to heat", the thermostat would be
set to heat but Alexa would respond, "The thermostat is off."

Bug caught by @Thunderbird2086 at
https://github.com/home-assistant/home-assistant/pull/17969#issuecomment-434654345
This commit is contained in:
Phil Frost 2018-10-31 11:09:13 -04:00 committed by Pascal Vizeli
parent b763c0f902
commit 93706fa568
2 changed files with 29 additions and 4 deletions

View file

@ -1839,11 +1839,17 @@ async def async_api_set_thermostat_mode(hass, config, directive, context):
climate.ATTR_OPERATION_MODE: ha_mode,
}
response = directive.response()
await hass.services.async_call(
entity.domain, climate.SERVICE_SET_OPERATION_MODE, data,
blocking=False, context=context)
response.add_context_property({
'name': 'thermostatMode',
'namespace': 'Alexa.ThermostatController',
'value': mode,
})
return directive.response()
return response
@HANDLERS.register(('Alexa', 'ReportState'))