Actionable Notifications via Alexa Media Player

Hey Everyone! It has been a while since I posted here, but I wanted to share something I’ve been working on for a little while now. I hope you enjoy it as much as much as I do.

Alexa Actions

Alexa Actions is a custom Alexa skill coupled with a Home Assistant setup and configuration guide to enable Actionable Notifications for your automations to your Alexa devices.

This provides the ability for your Alexa devices to make queries and await your response.

Example

Alexa: “I’ve noticed the front door has been unlocked for 5 mins, would you like me to lock it?”

You: “Yes”

The door locks

Getting Started

To get started, head over to the Alexa Actions GitHub Page.

18 Likes

Wow thank you. I wanted that for ages!!!

Yes this is awesome.

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.

1 Like

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 !

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

1 Like

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