Actionable Notifications via Alexa Media Player

This is great, I’m looking foward to using it for some of my notifications.

While trying it out with my setup (Raspberry Pi 3 B+ with remote access over Nabu Casa) I initially a problem where, after answering “Yes” or “No”, it would just respond with “Sorry, I had trouble doing what you asked. Please try again.”. This was easily fixed by tweaking the timeouts in the Lambda function.

If anyone else has the same issue simply find all all instances of timeout=urllib3.Timeout(connect=2.0, read=10.0) and change the timeout values until it works for you. I currently have it at timeout=urllib3.Timeout(connect=10.0, read=10.0) although, judging from the response times, I don’t think the connect timeout actually needs to be that high.

2 Likes

Nice catch, I’ll update the wiki on the github page.

Thanks for all of this! I’ve got most of it working except the very last step. I think there might be a typo in the example in the docs? I have a lock, so I’m using your example basically verbatim. I’ve changed the lock entity id, that’s it.

In the activate_alexa_actionable_notification script your example contain this line:

value: "{'text': '{{ text }}', 'event': '{{ event_id }}'}"

But this causes my Echo show to say something like ‘Sorry I had trouble doing what you asked, please try again’.

However I can make it work by changing that line to:

value: '{"text": "The front door has been unlocked for 5 mins, would you like me to lock it?", "event": "actionable_notification_lock_left_unlocked"}'

So it seems like it could be a formatting error in the example?

1 Like

I believe it’s a issue with too many quotation marks in the example. In the example the automation’s data_template has quotation marks, but in the script the input_text.set_value data_template also has quotation marks. I’ve got it working now by taking the quotation marks out of the automation’s data_template:

automation:
  - alias: Front door left unlocked for 5 mins
    trigger:
      platform: state
      entity_id: lock.assa_abloy_yale_conexis_l1_sd_l1000_ch_locked
      to: 'unlocked'
      for:
        minutes: 5
    action:
      - service: script.activate_alexa_actionable_notification_test
        data_template:
          text: The front door has been unlocked for 5 minutes, would you like me to lock it?
          event_id: actionable_notification_lock_left_unlocked
          alexa_device: media_player.kitchen_echo_show
script:
  activate_alexa_actionable_notification_test:
    description: 'Activate actionable door lock notification'
    fields:
      text:
        description: 'The text you would like alexa to speak.'
      event_id:
        description: 'Correlation ID for event responses'
      alexa_device: 
        description: 'Alexa device you want to trigger'
    sequence:
      - service: input_text.set_value
        data_template:
          entity_id: input_text.alexa_actionable_notification
          value: '{"text": "{{ text }}", "event": "{{ event_id }}" }'
      - service: media_player.play_media
        data_template:
          entity_id: media_player.kitchen_echo_show
          media_content_type: skill
          media_content_id: amzn1.ask.skill.12345678901234567890

Thanks for this. I’ve tried setting this up but the “Open Custom Actions” response is “Could not communicate with home assistant”

The account linking went fine. I’m using my nabu casa URL.

Any help would be appreciated

EDIT: Sorry, restart of HA and all works now

I have tried to setup this as described

I get stuck at getting to the Alexa app link account.

The app opens my Home Assistant URL and I see the page with the error

Error: invalid client or redirect url

I have valid certificate and I use Apache reverse proxy as described here

What is missing? I suspect it is the reverse proxy that creates the issue

1 Like

Update: I thought I would try and change the URLs to US even though I am in EU. And now I could link. Not sure why that worked

Strange, the EU one worked for me this morning.

There could be two reasons.
One is that that my Alexa integration and account is setup for US in the first place. So they may have to match. (I created this before Alexa came to Europe).
The other can be that something was cached. When things did not work I updated the Apache config for the reverse proxy to match the updates that had been done on the Home Assistant documentation page. It did not work right way but maybe the Amazon side or the app on my iPad had something cached.
I did the Apache updates first and the updates to the URLs on the skill to US half an hour later and then it worked right away. So I cannot say for sure which one made it work

Wow I love that. I would like to do the same with google assistant, do you think it is possible?

DRZZZ is making a live stream right now about that !

1 Like

Followed your directions. Working beautifully. Thanks for the exceptional contribution.

Anyone doing this with Node-RED yet? I can’t seem to pass the entity_id onto the script

Nevermind I have this working in Node-RED if anyone is interested I’ll post up an example

I’d be interested if you don’t mind.

Call Service Node placed after the trigger event in my case the garage door being left open

Then I listen to the response with an event node and can act on that response via a switch node

image

3 Likes

That’s a wonderful feature!

I live in Brazil which country/region should I choose when creating the Amazon Developer Account? Can it be Brazil or I have to choose US?

Replying myself in case anyone have the same question: use your real country,

Thank you!

1 Like

This is exactly what I’ve been dreaming about, but I’ve got one big problem: this is a google house. Is there ANY way to have google home do something similar? Can GH be forced to broadcast and listen/react to a response?

1 Like

I’m still working out a bed time routine but this is awesome.

- alias: Bed Time
  description: ''
  trigger:
  - at: '20:00:00'
    platform: time
  condition: []
  action:
  - data:
      alexa_device: media_player.kevin_s_echo_dot
      event_id: actionable_notification_bed_time
      text: <amazon:emotion name='disappointed' intensity='high'>It is 8:00 PM, would
        you like me to start getting ready for bed?</amazon:emotion>
    service: script.activate_alexa_actionable_notification
- alias: Bed Time - Yes
  description: ''
  trigger:
  - event_data:
      event_id: actionable_notification_bed_time
      event_response: ResponseYes
    event_type: alexa_actionable_notification
    platform: event
  condition: []
  action:
  - data: {}
    entity_id: light.living_room_light_s_zha_group_0x0004
    service: light.turn_off

@keatontaylor, if you would like to add these as examples on github I am cool with that.

@keatontaylor I’m currently on version 0.103.6 but does this require the latest version of home assistant?

I’ve skipped the acc linking as my duckdns url uses the the port number at the end. And I’ve also generated the long lived token from hass which I’ve pasted. Anything else I can do? Halp

I’m getting this in log:

Error while executing automation automation.test. Service not found for call_service at pos 1: Unable to find service input_text/set_value