Fix alexa cards (#8708)

This commit is contained in:
Paulus Schoutsen 2017-07-29 21:52:26 -07:00 committed by GitHub
parent 418a8bab11
commit 22088d192a
2 changed files with 16 additions and 7 deletions

View File

@ -171,7 +171,7 @@ class AlexaIntentsView(http.HomeAssistantView):
if 'simple' in intent_response.card:
alexa_response.add_card(
'simple', intent_response.card['simple']['title'],
CardType.simple, intent_response.card['simple']['title'],
intent_response.card['simple']['content'])
return self.json(alexa_response)
@ -208,8 +208,8 @@ class AlexaResponse(object):
self.card = card
return
card["title"] = title.async_render(self.variables)
card["content"] = content.async_render(self.variables)
card["title"] = title
card["content"] = content
self.card = card
def add_speech(self, speech_type, text):
@ -218,9 +218,6 @@ class AlexaResponse(object):
key = 'ssml' if speech_type == SpeechType.ssml else 'text'
if isinstance(text, template.Template):
text = text.async_render(self.variables)
self.speech = {
'type': speech_type.value,
key: text

View File

@ -86,7 +86,12 @@ def alexa_client(loop, hass, test_client):
"CallServiceIntent": {
"speech": {
"type": "plain",
"text": "Service called",
"text": "Service called for {{ ZodiacSign }}",
},
"card": {
"type": "simple",
"title": "Card title for {{ ZodiacSign }}",
"content": "Card content: {{ ZodiacSign }}",
},
"action": {
"service": "test.alexa",
@ -319,6 +324,13 @@ def test_intent_request_calling_service(alexa_client):
assert call.data.get("entity_id") == ["switch.test"]
assert call.data.get("hello") == "virgo"
data = yield from req.json()
assert data['response']['card']['title'] == 'Card title for virgo'
assert data['response']['card']['content'] == 'Card content: virgo'
assert data['response']['outputSpeech']['type'] == 'PlainText'
assert data['response']['outputSpeech']['text'] == \
'Service called for virgo'
@asyncio.coroutine
def test_intent_session_ended_request(alexa_client):