Trigger Automations When a Specific Echo Device's Alarm Goes Off

Tags: #<Tag:0x00007f739a8b6a90> #<Tag:0x00007f739a8b6928>

I struggled with how to make device specific alarm automations, for when we have company and my father gets up two hours before me (he is a 5 am sort of guy). I know others have mentioned having children, and wanting their lights to come on when just their echo went off.

Step 1)
Make sure you have the Alexa Media Player custom component:

Step 2)

Add time sensors to your configuration.yaml file

  - platform: time_date
      - 'time'
      - 'date'
      - 'date_time'
      - 'date_time_utc'
      - 'date_time_iso'
      - 'time_date'
      - 'time_utc'
      - 'beat'

Step 3)

Make an automation! Check your list of sensors and you will notice you have some new ones with the _next_alarm ending. For this example I will use sensor.master_bedroom_echo_show_next_alarm. Please swap it out for the device you want triggered. The rest should be copy and paste.

    platform: template
    value_template: >
      {% set alarm_time = as_timestamp(states('sensor.master_bedroom_echo_show_next_alarm')) %}
      {% set current_time = as_timestamp(states('sensor.date_time').replace(',', '')) %}
      {% set pre_time = 2 %}
      {{ current_time >= ( alarm_time - pre_time }}

This trigger will set off your automation 2 seconds before your echo specific alarm. It has to be before because once the alarm goes off it there will no longer be a _next_alarm time. If you need them to sync up add the following to your action.

  - delay: 00:00:02