Alexa Actionable Automations

I’ve got the basics working as follows with 2 automations. How do I get it to repeat the questions until the response is “Yes”?

alias: Alexa Actionable 1 - Bins out
description: ''
trigger:
  - platform: time
    at: '16:02:00'
condition:
  - condition: time
    weekday:
      - mon
action:
  - service: script.activate_alexa_actionable_notification
    data:
      text: Have the bins been put out?
      event_id: actionable_notification_bins_out
      alexa_device: media_player.studyecho
mode: single
alias: Alexa Actionable Response 1 - Bins out
description: ''
trigger:
  - platform: event
    event_type: alexa_actionable_notification
    event_data:
      event_id: actionable_notification_bins_out
      event_response_type: ResponseYes
condition: []
action:
  - service: notify.mobile_app_bobs_iphone
    data:
      message: This is an Alexa actionable notification
      title: Alexa actionable notification
mode: single

I’m not sure what the second automation is doing but I would do your task like this personally:

automation:
- alias: Alexa Actionable 1 - Bins out
  description: ''
  trigger:
  - platform: time_pattern
    # Triggers every hour at 2 minutes past whole
    minutes: 2
  condition:
  - condition: time
    after: '16:00:00'
    before: '23:59:59'
    weekday:
      - mon
  - condition: state
    entity_id: binary_sensor.bins_need_taking_out
    state: 'on'
  action:
  - service: script.activate_alexa_actionable_notification
    data:
      text: Have the bins been put out?
      event_id: actionable_notification_bins_out
      alexa_device: media_player.studyecho
  mode: single

template:
- trigger:
  - platform: time
    at: '00:00:01'
  - id: yes
    platform: event
    event_type: alexa_actionable_notification
    event_data:
      event_id: actionable_notification_bins_out
      event_response_type: ResponseYes
  binary_sensor:
    name: Bins need taking out
    state: >-
      {{ 'off' if trigger.id == 'yes' or now().weekday() != 0 else 'on' }}

The binary sensor will turn on at midnight on Monday. It turns off at midnight on every other day or when a yes is received from alexa for actionable_notification_bins_out. The automation sends the alexa notification once an hour at 2 minutes after the hour between 16 and midnight until the binary sensor turns off.

Thanks Mike, I’ve pasted the code into an Automation and I’m getting “Message malformed: extra keys not allowed @ data[‘Automation’]”? Also how do I change it to repeating say every 30 mins?

Appreciate your help.

That’s not an automation. The first part under automation is an automation, the second thing is a template binary sensor. You can put the whole thing in your configuration.yaml as a package if you want. Otherwise you have to put the automation with automations and add the template to your configuration.yaml separately.

Change the automation trigger to this:

  - platform: time_pattern
    # Triggers every half hour
    minutes: /30

Thanks, I did try that first, but got the enclosed. Apologies if I’m being dense…

. I assume I don’t need the “template:”.

Oh got it. Ok let’s try this:

template:
- trigger:
  - platform: time
    at: '00:00:01'
  - id: 'yes'
    platform: event
    event_type: alexa_actionable_notification
    event_data:
      event_id: actionable_notification_bins_out
      event_response_type: ResponseYes
  binary_sensor:
  - name: Bins need taking out
    state: >-
      {{ 'off' if trigger.id == 'yes' or now().weekday() != 0 else 'on' }}

The first error in your screenshot is correct. I kind of forgot yes gets interpreted as a boolean in yaml so that’s my bad.

The second error isn’t actually an error although I get why its doing that. In HA many places that accept an array also accept a single item because HA makes it into an array. So although schema validation there is telling you binary_sensor is supposed to have a list of dictionaries if you just give it a single dictionary HA makes it work. But I tweaked it to make the validator happy.

You probably do? Where are you pasting this? If you’re trying to put it in your configuration.yaml file then yes you need that. If you’re putting it in a file called template.yaml and then putting template: !include template.yaml in your configuration.yaml then no you don’t. But I can’t see your config so I’m not sure.

It’s all working :slight_smile: Thank you for you help :slight_smile:

Please can you let me know how to reference multiple echos?

I don’t really know, I don’t have an alexa. What does your script do?

It’s ok, I’ve sorted it. Thanks for all your help.

1 Like