Alexa Actionable Notifications To Multiple Alexa Devices?

Hi, Just added the Alexa Actions to my HA which works great. Home · keatontaylor/alexa-actions Wiki (github.com).
Can anyone tell me if it is possible to target multiple Alexa devices when the notification is announced? I’m thinking that you may be down one end of the house and not hear the actionable notification.

thanks

Yes - you just set the entity_id attribute inside the data attribute to the entity ID of your Alexa Media device.

I can’t remember where I got the following script - but I KNOW for a fact I saw it on @DrZzs Youtube, so starting credit is there and from him to - wherever.

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.living_room_echo_dot
sequence:
  - service: input_text.set_value
    data:
      entity_id: input_text.alexa_actionable_notification
      value: '{"text": "{{ text }}", "event": "{{ event_id }}"}'
  - service: media_player.play_media
    data:
      entity_id: '{{ alexa_device }}'
      media_content_type: skill
      media_content_id: amzn1.ask.skill.---redacted-use-your-own-skill-id-here---

Ok do you mean that you comma separate the entity ids or do you repeat the whole “service/data” part? thanks

Wait, simultaneously? Sorry missed that part. If its supported it would be a delimited list, not multiple data entries. I seem to remember there was a reason I didn’t do it though - I can’t remember if it was an issue with multiple devices not firing together or the net effect (due to the staggering of announcements) was… Off putting and hard to follow. I’ve run into both issues but don’t remember the context.

I solved this problem a different way… Instead of ‘broadcasting’ to multiple devices - I use the last called device feature of Alexa Media Player to target the announcements to where people actually are. (pretty active Alexa household so the devices are well used)

Yes it ‘misses’ sometimes but it’s better than 85% for me and therefore good enough for this use.

I tried to get that working a while back and never figured it out.

I even asked in the AMP thread and no one had any ideas.

So I gave up.

I would be interested to know how to do it if you figure it out tho.

Do you mean this?

notify:
  - platform: alexa_media
    name: Alexa Media
  - platform: group
    name: All Echos
    services:
      - service: alexa_media
        data:
          target: media_player.echo_dot_room1
          data:
            type: announce
      - service: alexa_media
        data:
          target: media_player.echo_dot_room2
          data:
            type: announce
      - service: alexa_media
        data:
          target: media_player.echo_dot_room3
          data:
            type: announce

And then call the service…

  - service: notify.all_echos
    data:
      message: Your message goes here
1 Like

Hi no I am talking about Alexa custom notifications not just regular ones

So figured it out … kind off. You can just create a helper group of media devices and then refer to the entity id of the group.
That results in the announcement on 1 echo and then once you have fully answered Alexa and said yes or no the announcement happens on the next Alexa device in the group.

1 Like

Would you mind sharing an example of your find?

Sorry not at home but basically just go to Helpers, create a media player group of the players that you wish to include. Then in your notification use the entity I’d of the group instead of an individual media player entity I’d.

It repeats only if you answers.
For me, it’s more useful if it repeats the actionable notification if nobody answers and until someone does it.
I created a script the does exactly that:

alias: Repeat actionable notifications until response
sequence:
  - alias: >-
      Repeat the actionable notification on every speaker in the group until
      there's a response or the group members end
    repeat:
      for_each: "{{expand(speakers_group)|map(attribute='entity_id') | list }}"
      sequence:
        - service: "{{service}}"
          data:
            text: "{{text}}"
            event_id: "{{event_id}}"
            alexa_device: "{{repeat.item}}"
          enabled: true
        - wait_for_trigger:
            - platform: event
              event_type: alexa_actionable_notification
              event_data:
                event_id: "{{event_id}}"
                event_response_type: ResponseNone
          timeout:
            hours: 0
            minutes: 0
            seconds: 20
            milliseconds: 0
          continue_on_timeout: false
          enabled: true
        - service: notify.alexa_media
          data:
            data:
              type: tts
            target: media_player.2_salone_echo_4_1
            message: "{{repeat.item}}"
          enabled: false
mode: single

The script should be called with the following data.

text: what alexa should ask
event_id: the common event_id you’d use for identify the actionable notification
speakers_group: the group of speakers you’d like to receive the notification. For example, “group.all_my_home_speakers”
service: script.activate_alexa_actionable_notification

1 Like

@malorezzanzo64 Could you please provide some more insight on your script. I’m trying to use it but i’m not sure I understand how to use it. I assume it’s an automation and not a script. Even so, I would appreciate some help in adopting it.

I have Alexa Actionable Notification working from the Wiki site instruction, but I could use some help with multiple device.

Thanks in advance

@caple no, it’s a script. It has to be called with the parameters I listed (text, event_id, speakers_group). Now I edited a bit, but I remember it was working. Be careful speakers_group works only with old groups (the ones starting with group), not new media groups (the ones starting with media_player).

Hi and thanks for the script. I use it every morning for an automation that asks in each room if i want to open the garage. Sometimes it stops after hitting the third echo device, sometimes it works for all of them… it’s really random and i did not figure it out. It stops because of timeout error. Do you know why? I tried to enable “Continue on timeout” but nothing changed.
I don’t know how to create a group of media players starting with group, mine starts with media_player:

sequence:
  - alias: >-
      Repeat the actionable notification on every speaker in the group until
      there's a response or the group members end
    repeat:
      for_each: "{{expand(speakers_group)|map(attribute='entity_id') | list }}"
      sequence:
        - service: "{{service}}"
          data:
            text: "{{text}}"
            event_id: "{{event_id}}"
            alexa_device: "{{repeat.item}}"
          enabled: true
        - wait_for_trigger:
            - platform: event
              event_type: alexa_actionable_notification
              event_data:
                event_id: "{{event_id}}"
                event_response_type: ResponseNone
          timeout:
            hours: 0
            minutes: 0
            seconds: 30
            milliseconds: 0
          continue_on_timeout: false
          enabled: true

Here is also a trace of the running script:

{
  "trace": {
    "last_step": "sequence/0/repeat/sequence/1",
    "run_id": "f55f3ce2756abd5e7194d6f095b8ad87",
    "state": "stopped",
    "script_execution": "aborted",
    "timestamp": {
      "start": "2024-03-05T06:30:00.261947+00:00",
      "finish": "2024-03-05T06:31:04.656560+00:00"
    },
    "domain": "script",
    "item_id": "multiple_alexa_actionable_notification",
    "trace": {
      "sequence/0": [
        {
          "path": "sequence/0",
          "timestamp": "2024-03-05T06:30:00.269282+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "script.multiple_alexa_actionable_notification",
              "state": "off",
              "attributes": {
                "last_triggered": "2024-03-04T06:50:39.509226+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "multiple_alexa_actionable_notification"
              },
              "last_changed": "2024-03-04T06:51:39.777010+00:00",
              "last_updated": "2024-03-04T06:51:39.777010+00:00",
              "context": {
                "id": "01HR43PYW1PVSK3DA5SFJYQ0QF",
                "parent_id": null,
                "user_id": null
              }
            },
            "text": "Sono le 7:30, apro il garage?",
            "event_id": "alexa_garage_mattina",
            "speakers_group": "media_player.all_home_alexa",
            "service": "script.activate_alexa_actionable_notification",
            "context": {
              "id": "01HR6MW0ST8TRSVD7JTFYVT08H",
              "parent_id": null,
              "user_id": null
            },
            "repeat": {
              "first": false,
              "index": 3,
              "last": false,
              "item": "media_player.echo_bagno"
            },
            "wait": {
              "remaining": 0,
              "trigger": null
            }
          },
          "error": "TimeoutError"
        }
      ],
      "sequence/0/repeat/sequence/0": [
        {
          "path": "sequence/0/repeat/sequence/0",
          "timestamp": "2024-03-05T06:30:00.274345+00:00",
          "child_id": {
            "domain": "script",
            "item_id": "activate_alexa_actionable_notification",
            "run_id": "1cb7f01d88a5cac0bd1e27e5547febf1"
          },
          "changed_variables": {
            "repeat": {
              "first": true,
              "index": 1,
              "last": false,
              "item": "media_player.echo_cameretta"
            }
          },
          "result": {
            "params": {
              "domain": "script",
              "service": "activate_alexa_actionable_notification",
              "service_data": {
                "text": "Sono le 7:30, apro il garage?",
                "event_id": "alexa_garage_mattina",
                "alexa_device": "media_player.echo_cameretta"
              },
              "target": {}
            },
            "running_script": true
          }
        },
        {
          "path": "sequence/0/repeat/sequence/0",
          "timestamp": "2024-03-05T06:30:17.593786+00:00",
          "child_id": {
            "domain": "script",
            "item_id": "activate_alexa_actionable_notification",
            "run_id": "8d815c925f7bff5c6f62ba0d5d66e948"
          },
          "changed_variables": {
            "repeat": {
              "first": false,
              "index": 2,
              "last": false,
              "item": "media_player.echo_soggiorno"
            },
            "wait": {
              "remaining": 12.72329361597076,
              "trigger": {
                "id": "0",
                "idx": "0",
                "alias": null,
                "platform": "event",
                "event": {
                  "event_type": "alexa_actionable_notification",
                  "data": {
                    "event_id": "alexa_garage_mattina",
                    "event_response": "ResponseNone",
                    "event_response_type": "ResponseNone"
                  },
                  "origin": "REMOTE",
                  "time_fired": "2024-03-05T06:30:17.587024+00:00",
                  "context": {
                    "id": "01HR6MWHQJKHXGQ31719Q26HW2",
                    "parent_id": null,
                    "user_id": "f6062591ef294ac2a45b617348075650"
                  }
                },
                "description": "event 'alexa_actionable_notification'"
              }
            }
          },
          "result": {
            "params": {
              "domain": "script",
              "service": "activate_alexa_actionable_notification",
              "service_data": {
                "text": "Sono le 7:30, apro il garage?",
                "event_id": "alexa_garage_mattina",
                "alexa_device": "media_player.echo_soggiorno"
              },
              "target": {}
            },
            "running_script": true
          }
        },
        {
          "path": "sequence/0/repeat/sequence/0",
          "timestamp": "2024-03-05T06:30:34.575665+00:00",
          "child_id": {
            "domain": "script",
            "item_id": "activate_alexa_actionable_notification",
            "run_id": "b10bc4f9838f64e2046894fbc601c475"
          },
          "changed_variables": {
            "repeat": {
              "first": false,
              "index": 3,
              "last": false,
              "item": "media_player.echo_bagno"
            },
            "wait": {
              "remaining": 13.054631958017126,
              "trigger": {
                "id": "0",
                "idx": "0",
                "alias": null,
                "platform": "event",
                "event": {
                  "event_type": "alexa_actionable_notification",
                  "data": {
                    "event_id": "alexa_garage_mattina",
                    "event_response": "ResponseNone",
                    "event_response_type": "ResponseNone"
                  },
                  "origin": "REMOTE",
                  "time_fired": "2024-03-05T06:30:34.546636+00:00",
                  "context": {
                    "id": "01HR6MX29J8W21YDQKFR9FAV8K",
                    "parent_id": null,
                    "user_id": "f6062591ef294ac2a45b617348075650"
                  }
                },
                "description": "event 'alexa_actionable_notification'"
              }
            }
          },
          "result": {
            "params": {
              "domain": "script",
              "service": "activate_alexa_actionable_notification",
              "service_data": {
                "text": "Sono le 7:30, apro il garage?",
                "event_id": "alexa_garage_mattina",
                "alexa_device": "media_player.echo_bagno"
              },
              "target": {}
            },
            "running_script": true
          }
        }
      ],
      "sequence/0/repeat/sequence/1": [
        {
          "path": "sequence/0/repeat/sequence/1",
          "timestamp": "2024-03-05T06:30:00.311923+00:00",
          "changed_variables": {
            "wait": {
              "remaining": 12.72329361597076,
              "trigger": {
                "id": "0",
                "idx": "0",
                "alias": null,
                "platform": "event",
                "event": {
                  "event_type": "alexa_actionable_notification",
                  "data": {
                    "event_id": "alexa_garage_mattina",
                    "event_response": "ResponseNone",
                    "event_response_type": "ResponseNone"
                  },
                  "origin": "REMOTE",
                  "time_fired": "2024-03-05T06:30:17.587024+00:00",
                  "context": {
                    "id": "01HR6MWHQJKHXGQ31719Q26HW2",
                    "parent_id": null,
                    "user_id": "f6062591ef294ac2a45b617348075650"
                  }
                },
                "description": "event 'alexa_actionable_notification'"
              }
            }
          },
          "result": {
            "wait": {
              "remaining": 12.72329361597076,
              "trigger": {
                "id": "0",
                "idx": "0",
                "alias": null,
                "platform": "event",
                "event": {
                  "event_type": "alexa_actionable_notification",
                  "data": {
                    "event_id": "alexa_garage_mattina",
                    "event_response": "ResponseNone",
                    "event_response_type": "ResponseNone"
                  },
                  "origin": "REMOTE",
                  "time_fired": "2024-03-05T06:30:17.587024+00:00",
                  "context": {
                    "id": "01HR6MWHQJKHXGQ31719Q26HW2",
                    "parent_id": null,
                    "user_id": "f6062591ef294ac2a45b617348075650"
                  }
                },
                "description": "event 'alexa_actionable_notification'"
              }
            }
          }
        },
        {
          "path": "sequence/0/repeat/sequence/1",
          "timestamp": "2024-03-05T06:30:17.624237+00:00",
          "changed_variables": {
            "wait": {
              "remaining": 13.054631958017126,
              "trigger": {
                "id": "0",
                "idx": "0",
                "alias": null,
                "platform": "event",
                "event": {
                  "event_type": "alexa_actionable_notification",
                  "data": {
                    "event_id": "alexa_garage_mattina",
                    "event_response": "ResponseNone",
                    "event_response_type": "ResponseNone"
                  },
                  "origin": "REMOTE",
                  "time_fired": "2024-03-05T06:30:34.546636+00:00",
                  "context": {
                    "id": "01HR6MX29J8W21YDQKFR9FAV8K",
                    "parent_id": null,
                    "user_id": "f6062591ef294ac2a45b617348075650"
                  }
                },
                "description": "event 'alexa_actionable_notification'"
              }
            }
          },
          "result": {
            "wait": {
              "remaining": 13.054631958017126,
              "trigger": {
                "id": "0",
                "idx": "0",
                "alias": null,
                "platform": "event",
                "event": {
                  "event_type": "alexa_actionable_notification",
                  "data": {
                    "event_id": "alexa_garage_mattina",
                    "event_response": "ResponseNone",
                    "event_response_type": "ResponseNone"
                  },
                  "origin": "REMOTE",
                  "time_fired": "2024-03-05T06:30:34.546636+00:00",
                  "context": {
                    "id": "01HR6MX29J8W21YDQKFR9FAV8K",
                    "parent_id": null,
                    "user_id": "f6062591ef294ac2a45b617348075650"
                  }
                },
                "description": "event 'alexa_actionable_notification'"
              }
            }
          }
        },
        {
          "path": "sequence/0/repeat/sequence/1",
          "timestamp": "2024-03-05T06:30:34.642253+00:00",
          "changed_variables": {
            "wait": {
              "remaining": 0,
              "trigger": null
            }
          },
          "error": "TimeoutError",
          "result": {
            "wait": {
              "remaining": 0,
              "trigger": null
            },
            "timeout": true
          }
        }
      ]
    },
    "config": {
      "sequence": [
        {
          "alias": "Repeat the actionable notification on every speaker in the group until there's a response or the group members end",
          "repeat": {
            "for_each": "{{expand(speakers_group)|map(attribute='entity_id') | list }}",
            "sequence": [
              {
                "service": "{{service}}",
                "data": {
                  "text": "{{text}}",
                  "event_id": "{{event_id}}",
                  "alexa_device": "{{repeat.item}}"
                },
                "enabled": true
              },
              {
                "wait_for_trigger": [
                  {
                    "platform": "event",
                    "event_type": "alexa_actionable_notification",
                    "event_data": {
                      "event_id": "{{event_id}}",
                      "event_response_type": "ResponseNone"
                    }
                  }
                ],
                "timeout": {
                  "hours": 0,
                  "minutes": 0,
                  "seconds": 30,
                  "milliseconds": 0
                },
                "continue_on_timeout": false,
                "enabled": true
              }
            ]
          }
        }
      ]
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01HR6MW0ST8TRSVD7JTFYVT08H",
      "parent_id": null,
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "when": 1709620200.262314,
      "state": "on",
      "entity_id": "script.multiple_alexa_actionable_notification"
    },
    {
      "name": "activate_alexa_actionable_notification",
      "message": "started",
      "entity_id": "script.activate_alexa_actionable_notification",
      "context_id": "01HR6MW0ST8TRSVD7JTFYVT08H",
      "when": 1709620200.279609,
      "domain": "script",
      "context_state": "on",
      "context_entity_id": "script.multiple_alexa_actionable_notification"
    },
    {
      "when": 1709620200.280045,
      "state": "on",
      "entity_id": "script.activate_alexa_actionable_notification",
      "context_state": "on",
      "context_entity_id": "script.multiple_alexa_actionable_notification"
    },
    {
      "when": 1709620200.297533,
      "state": "{\"text\": \"Sono le 7:30, apro il garage?\", \"event\": \"alexa_garage_mattina\"}",
      "entity_id": "input_text.alexa_actionable_notification",
      "context_state": "on",
      "context_entity_id": "script.multiple_alexa_actionable_notification"
    },
    {
      "when": 1709620200.310114,
      "state": "off",
      "entity_id": "script.activate_alexa_actionable_notification",
      "context_state": "on",
      "context_entity_id": "script.multiple_alexa_actionable_notification"
    },
    {
      "name": "activate_alexa_actionable_notification",
      "message": "started",
      "entity_id": "script.activate_alexa_actionable_notification",
      "context_id": "01HR6MW0ST8TRSVD7JTFYVT08H",
      "when": 1709620217.598736,
      "domain": "script",
      "context_state": "on",
      "context_entity_id": "script.multiple_alexa_actionable_notification"
    },
    {
      "when": 1709620217.599196,
      "state": "on",
      "entity_id": "script.activate_alexa_actionable_notification",
      "context_state": "on",
      "context_entity_id": "script.multiple_alexa_actionable_notification"
    },
    {
      "when": 1709620217.622849,
      "state": "off",
      "entity_id": "script.activate_alexa_actionable_notification",
      "context_state": "on",
      "context_entity_id": "script.multiple_alexa_actionable_notification"
    },
    {
      "name": "activate_alexa_actionable_notification",
      "message": "started",
      "entity_id": "script.activate_alexa_actionable_notification",
      "context_id": "01HR6MW0ST8TRSVD7JTFYVT08H",
      "when": 1709620234.583457,
      "domain": "script",
      "context_state": "on",
      "context_entity_id": "script.multiple_alexa_actionable_notification"
    },
    {
      "when": 1709620234.58393,
      "state": "on",
      "entity_id": "script.activate_alexa_actionable_notification",
      "context_state": "on",
      "context_entity_id": "script.multiple_alexa_actionable_notification"
    },
    {
      "when": 1709620234.620691,
      "state": "off",
      "entity_id": "script.activate_alexa_actionable_notification",
      "context_state": "on",
      "context_entity_id": "script.multiple_alexa_actionable_notification"
    }
  ]
}

So apparently there might be a bug with the ResponeNone on the echo show devices? Alexa Actionable Notifications - ResponseNone Event Not Firing - #3 by tmi
This might explain why it stops after the third echo that is the echo show one. @malorezzanzo64 any suggestion on how to edit the script to have a workaround?

@sciorty Hi and sorry for the late response. I don’t think the problem is ResponseNone not firing because in that case it should trigger the timeout. I think the problem could be in the group starting with media_player. One of the difference between groups starting with group (the old style groups) and the groups starting with media_player (or light, sensor…) is that the expand function can be used only on the former. Instead of:

for_each: "{{expand(speakers_group)|map(attribute='entity_id') | list }}"

Try to use a simple list of speakers like that:

for_each:
  - media_player.kitchen_echo
  - media_player.hall_echo

Still nothing, I put the echo show device as second in the list, the script stopped there and did not proceed with the remaining two.
Instead, putting it as last in the list is a workaround