mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Fix alexa cards (#8708)
This commit is contained in:
parent
418a8bab11
commit
22088d192a
@ -171,7 +171,7 @@ class AlexaIntentsView(http.HomeAssistantView):
|
|||||||
|
|
||||||
if 'simple' in intent_response.card:
|
if 'simple' in intent_response.card:
|
||||||
alexa_response.add_card(
|
alexa_response.add_card(
|
||||||
'simple', intent_response.card['simple']['title'],
|
CardType.simple, intent_response.card['simple']['title'],
|
||||||
intent_response.card['simple']['content'])
|
intent_response.card['simple']['content'])
|
||||||
|
|
||||||
return self.json(alexa_response)
|
return self.json(alexa_response)
|
||||||
@ -208,8 +208,8 @@ class AlexaResponse(object):
|
|||||||
self.card = card
|
self.card = card
|
||||||
return
|
return
|
||||||
|
|
||||||
card["title"] = title.async_render(self.variables)
|
card["title"] = title
|
||||||
card["content"] = content.async_render(self.variables)
|
card["content"] = content
|
||||||
self.card = card
|
self.card = card
|
||||||
|
|
||||||
def add_speech(self, speech_type, text):
|
def add_speech(self, speech_type, text):
|
||||||
@ -218,9 +218,6 @@ class AlexaResponse(object):
|
|||||||
|
|
||||||
key = 'ssml' if speech_type == SpeechType.ssml else 'text'
|
key = 'ssml' if speech_type == SpeechType.ssml else 'text'
|
||||||
|
|
||||||
if isinstance(text, template.Template):
|
|
||||||
text = text.async_render(self.variables)
|
|
||||||
|
|
||||||
self.speech = {
|
self.speech = {
|
||||||
'type': speech_type.value,
|
'type': speech_type.value,
|
||||||
key: text
|
key: text
|
||||||
|
@ -86,7 +86,12 @@ def alexa_client(loop, hass, test_client):
|
|||||||
"CallServiceIntent": {
|
"CallServiceIntent": {
|
||||||
"speech": {
|
"speech": {
|
||||||
"type": "plain",
|
"type": "plain",
|
||||||
"text": "Service called",
|
"text": "Service called for {{ ZodiacSign }}",
|
||||||
|
},
|
||||||
|
"card": {
|
||||||
|
"type": "simple",
|
||||||
|
"title": "Card title for {{ ZodiacSign }}",
|
||||||
|
"content": "Card content: {{ ZodiacSign }}",
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
"service": "test.alexa",
|
"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("entity_id") == ["switch.test"]
|
||||||
assert call.data.get("hello") == "virgo"
|
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
|
@asyncio.coroutine
|
||||||
def test_intent_session_ended_request(alexa_client):
|
def test_intent_session_ended_request(alexa_client):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user