Have been following the Mark Watt Tech YT install of actionable notifications for the second time (had it all working then switched to Nabu Casa and trying to just change the external login didn’t work)
Seem to have completed most of it, but when I try to call service: service:script.activate_alexa_actionable_notification data
I get an error message:
`Failed to call service script.activate_alexa_actionable_notification. Error rendering data template: Result is not a Dictionary’
Can anyone point me at what I need to look at to fix this ?
The script is as follows, with the media_content changed to protect the guilty.
I do realize that the YT video is now a couple of years old, so may be out of date.
If I ask Alexa to “open hello world”, that seems to work, so I think the Alexa skill is linked ok.
alias: activate_alexa_actionable_notification
description: Activates an actionable notification on a specific echo device
fields:
text:
description: The text you would like alexa to speak.
example: What would you like the thermostat set to?
event_id:
description: Correlation ID for event responses
example: ask_for_temperature
alexa_device:
description: Alexa device you want to trigger
example: media_player.master_bedroom_echo_dot
suppress_confirmation:
description: Set true if you want to suppress 'okay' confirmation
example: "true"
sequence:
- service: input_text.set_value
data_template:
entity_id: input_text.alexa_actionable_notification
value: >-
{"text": "{{ text }}", "event": "{{ event_id }}",
"suppress_confirmation": "{{ suppress_confirmation }}"}
- service: media_player.play_media
data_template:
entity_id: "{{ alexa_device }}"
media_content_type: skill
media_content_id: amzn1.ask.skill.abc
mode: single
Yes, it’s a drop-in replacement for the original service call. The original one included the out-dated data_template variable and has some incorrect use of quotation marks… so none of the field variables being passed to the script would have valid values.
Hi Drew (or anyone else)
Still appears to be a problem with the script. I of course could have messed up the replacement above, but now getting the following error in the Dev Tools if I call the service: Failed to call service script.activate_alexa_actionable_notification. Error rendering data template: TypeError: Type is not JSON serializable: LoggingUndefined
The full script, as I have it now is:
alias: activate_alexa_actionable_notification
description: Activates an actionable notification on a specific echo device
fields:
text:
description: The text you would like alexa to speak.
example: What would you like the thermostat set to?
event_id:
description: Correlation ID for event responses
example: ask_for_temperature
alexa_device:
description: Alexa device you want to trigger
example: media_player.master_bedroom_echo_dot
suppress_confirmation:
description: Set true if you want to suppress 'okay' confirmation
example: "true"
sequence:
- service: input_text.set_value
data:
value: >-
{{ {"text": text , "event": event_id, "suppress_confirmation":
suppress_confirmation } | to_json }}
target:
entity_id: input_text.alexa_actionable_notification
- service: media_player.play_media
data_template:
entity_id: "{{ alexa_device }}"
media_content_type: skill
media_content_id: amzn1.ask.skill.4a0c2e10-b8d6-460b-8918-66c6a04cc727
mode: single
I find it a little confusing that it would take a json formatted string, but the followinf seems to be accepted…
alias: activate_alexa_actionable_notification
description: Activates an actionable notification on a specific echo device
fields::
text:
name: Text
description: The text you would like alexa to speak.
example: What would you like the thermostat set to?
required: true
selector:
text:
event_id:
name: Event ID
description: Correlation ID for event responses
example: ask_for_temperature
required: true
selector:
text:
alexa_device:
name: Alexa Device
description: Alexa device you want to trigger
example: media_player.master_bedroom_echo_dot
selector:
entity:
filter:
- domain: media_player
integration: alexa_media
suppress_confirmation:
name: Suppress Confirmation
description: Set true if you want to suppress 'okay' confirmation
default: true
selector:
boolean:
sequence:
- service: input_text.set_value
data:
value: >
{{ {"text": text|string , "event": event|string, "suppress_confirmation": suppress_confirmation | string | lower } }}
target:
entity_id: input_text.alexa_actionable_notification
- service: media_player.play_media
data:
entity_id: "{{ alexa_device }}"
media_content_type: skill
media_content_id: amzn1.ask.skill.example
mode: single
Drew
I am continually in awe of this community, with how it tries to help people like me who really are in over their heads. Thank you so much for taking the time to try to fix this for me.
It appears as though you have cracked it - at least I am not getting any errors showing in the config or any notifications when I restart HA.
Unfortunately there is still an issue - any testing just gets an error response - in the Alexa app, the latest one says the Lambda application returned a failed response.
So I think I have to try to rebuild the skill again - maybe this time I will try to follow the instructions from the developer, rather than maybe what I did last time, which could have been a bit of a mix and match with this and a YT video that is now 2 years old.
Maybe one day I will learn.
The logging action isn’t working properly because you have quotes around your templates in a multiline string that is already using the > block scalar indicator.
The input text action looks fine, just be aware that states have a 255 character limit, so if the json string rendered by the template exceeds that the action will fail.
The media action also looks fine, assuming you are using a real Skill ID.