Alexa: Expose intent variables to service calls

This commit is contained in:
Paulus Schoutsen 2016-04-21 12:27:23 -07:00
parent 4acb121689
commit c4913a87e4
2 changed files with 10 additions and 4 deletions

View File

@ -91,7 +91,7 @@ def _handle_alexa(handler, path_match, data):
card['content'])
if action is not None:
call_from_config(handler.server.hass, action, True)
call_from_config(handler.server.hass, action, True, response.variables)
handler.write_json(response.as_dict())

View File

@ -71,8 +71,8 @@ def setUpModule(): # pylint: disable=invalid-name
},
'action': {
'service': 'test.alexa',
'data': {
'hello': 1
'data_template': {
'hello': '{{ ZodiacSign }}'
},
'entity_id': 'switch.test',
}
@ -278,6 +278,12 @@ class TestAlexa(unittest.TestCase):
'timestamp': '2015-05-13T12:34:56Z',
'intent': {
'name': 'CallServiceIntent',
'slots': {
'ZodiacSign': {
'name': 'ZodiacSign',
'value': 'virgo',
}
}
}
}
}
@ -289,7 +295,7 @@ class TestAlexa(unittest.TestCase):
self.assertEqual('test', call.domain)
self.assertEqual('alexa', call.service)
self.assertEqual(['switch.test'], call.data.get('entity_id'))
self.assertEqual(1, call.data.get('hello'))
self.assertEqual('virgo', call.data.get('hello'))
def test_session_ended_request(self):
"""Test the request for ending the session."""