Trigger automation based on Alexa alarm (from a specific echo)?

I’d like to trigger automations if my daughter’s echo alarm goes off. I know I can use IFTTT to trigger based on any echo alarm going off, but since we have many echos and are all using different alarms, that won’t work for me. Anyone know how to trigger based on a specific echo?

Thanks!

Did you ever get any traction on this topic? Triggering automation based off of an alarm has always seemed to me the most basic and obvious routine for someone using any kind of home automation. Yet…pairing with Alexa devices there are very few customizable options. I had my morning routine perfect, Lights come on gradually, coffee turns on…and then my father visited and set his alarm hours before me and now my lights are waking me up way to early, and I had to use an input Boolean condition to override the master bedroom portion of my morning automation. Wish the ifttt webhook could send info on which Alexa device triggered the alarm.

Nope no progress on this one.

Ok, I solved it!

You need to have the ‘unofficial’ Alexa Media Player integration installed. Give it a search online and there is plenty of info on it. Once you have that then you can see your echo devices (and make them talk if you want), as well as having access to some nice sensors. This an example of one.
sensor.master_bedroom_echo_show_next_alarm

Below is how to use that as a echo specific trigger.

trigger:
  state: template
  value_template: >
    {% set alarm_time = as_timestamp(states(‘sensor.<insert echo name>_next_alarm')) | int %}
    {% set current_time = as_timestamp(states('sensor.date_time').replace(',', '')) | int %}
    {{ current_time >= ( alarm_time - 2 ) }}

This will trigger an automation 2 seconds before your alarm goes off at the specific echo.

Hi.
This works great for triggering an automation, but how have you overcome it continuing to trigger (as you’re just making sure the current time is on or after the alarm time, so it keeps triggering).

I used this post to build a node red flow. if anybody prefers node red, here it is

in the calculation you can trigger things before alarm by subtracting required amount from msg.delay. for instance, my master bedroom alarm, will open the curtains 30 minutes before the alarm and if it is cloudy it will turn on the lights 10 minutes before alarm.

[{"id":"2b3a8437.ab11ec","type":"group","z":"a5b701dc.0bcb6","style":{"stroke":"#2e333a","stroke-opacity":"1","fill":"#2e333a","fill-opacity":"0.75","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["79c85a8f.e31344","21d200dc.7c11","64f37e7a.6d1cd","19d300ba.cae61f","ccf5e163.de4c8","6c782e97.bf185","61e93bcd.b09bd4","49a19c89.177c64","f6c191bd.1b84","3f5e37a.276d9c8","b200308e.b6717","81f50c60.7f197","366449cb.e922c6"],"x":54,"y":1739,"w":792,"h":342},{"id":"79c85a8f.e31344","type":"server-state-changed","z":"a5b701dc.0bcb6","g":"2b3a8437.ab11ec","name":"","server":"505ea12e.03f8b","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.fire_tv_cube_next_timer","entityidfiltertype":"substring","outputinitially":true,"state_type":"str","haltifstate":"unavailable","halt_if_type":"str","halt_if_compare":"is_not","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":false,"x":260,"y":1820,"wires":[["64f37e7a.6d1cd"],["19d300ba.cae61f"]]},{"id":"21d200dc.7c11","type":"server-state-changed","z":"a5b701dc.0bcb6","g":"2b3a8437.ab11ec","name":"","server":"505ea12e.03f8b","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.fire_tv_cube_next_alarm","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"unavailable","halt_if_type":"str","halt_if_compare":"is_not","outputs":2,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":false,"x":260,"y":1920,"wires":[["6c782e97.bf185"],["61e93bcd.b09bd4"]]},{"id":"64f37e7a.6d1cd","type":"function","z":"a5b701dc.0bcb6","g":"2b3a8437.ab11ec","name":"Calc difference ms","func":"msg.delay = new Date(msg.payload) - new Date();\n//msg.delay = msg.delay + 5 * 60 *60 *1000 ;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":570,"y":1800,"wires":[["ccf5e163.de4c8"]],"info":"LocalDateTime dateTime = LocalDateTime.parse(msg.payload);"},{"id":"19d300ba.cae61f","type":"change","z":"a5b701dc.0bcb6","g":"2b3a8437.ab11ec","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":1840,"wires":[["ccf5e163.de4c8"]]},{"id":"ccf5e163.de4c8","type":"delay","z":"a5b701dc.0bcb6","g":"2b3a8437.ab11ec","name":"","pauseType":"delayv","timeout":"7","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":760,"y":1820,"wires":[[]]},{"id":"6c782e97.bf185","type":"function","z":"a5b701dc.0bcb6","g":"2b3a8437.ab11ec","name":"Calc difference ms","func":"msg.delay = new Date(msg.payload) - new Date();\n//msg.delay = msg.delay + 5 * 60 *60 *1000 ;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":570,"y":1900,"wires":[["49a19c89.177c64"]],"info":"LocalDateTime dateTime = LocalDateTime.parse(msg.payload);"},{"id":"61e93bcd.b09bd4","type":"change","z":"a5b701dc.0bcb6","g":"2b3a8437.ab11ec","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":1940,"wires":[["49a19c89.177c64"]]},{"id":"49a19c89.177c64","type":"delay","z":"a5b701dc.0bcb6","g":"2b3a8437.ab11ec","name":"","pauseType":"delayv","timeout":"7","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":760,"y":1920,"wires":[[]]},{"id":"f6c191bd.1b84","type":"server-state-changed","z":"a5b701dc.0bcb6","g":"2b3a8437.ab11ec","name":"","server":"505ea12e.03f8b","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.fire_tv_cube_next_reminder","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"unavailable","halt_if_type":"str","halt_if_compare":"is_not","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":false,"x":270,"y":2020,"wires":[["3f5e37a.276d9c8"],["b200308e.b6717"]]},{"id":"3f5e37a.276d9c8","type":"function","z":"a5b701dc.0bcb6","g":"2b3a8437.ab11ec","name":"Calc difference ms","func":"msg.delay = new Date(msg.payload) - new Date();\n//msg.delay = msg.delay + 5 * 60 *60 *1000 ;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":570,"y":2000,"wires":[["81f50c60.7f197"]],"info":"LocalDateTime dateTime = LocalDateTime.parse(msg.payload);"},{"id":"b200308e.b6717","type":"change","z":"a5b701dc.0bcb6","g":"2b3a8437.ab11ec","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":2040,"wires":[["81f50c60.7f197"]]},{"id":"81f50c60.7f197","type":"delay","z":"a5b701dc.0bcb6","g":"2b3a8437.ab11ec","name":"","pauseType":"delayv","timeout":"7","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":760,"y":2020,"wires":[[]]},{"id":"366449cb.e922c6","type":"comment","z":"a5b701dc.0bcb6","g":"2b3a8437.ab11ec","name":"Living Room","info":"","x":150,"y":1780,"wires":[]},{"id":"505ea12e.03f8b","type":"server","name":"your_server![Screenshot 2020-12-06 050204|690x306]","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]![Screenshot 2020-12-06 050204|690x306]

Hey… how do you set a trigger to use with the value of the remaining time? Can you post a full flow as an ex! thx

I do not understand the question !! the flow will resume at the alarm time

My bad, i’m reading a LOT of threads to figure out how i can do what i want and i’m getting a bit crazy, i’m trying to do the inverse, i want a way to start my sunrise flow before the alarm goes on! And i was trying to use your countdown to trigger the flow before the time set! How can i do it on nodered? I was trying to get time msg payload, but it isnt just the time value! (ex: 2020-12-20T07:00:00+01:00 )

put this in the function node. the 30 *60 *1000 represent half an hour converted to miliseconds … change the 30 to anything you want and whatever after the delay node will trigers before the alarm

msg.delay = new Date(msg.payload) - new Date() - 30 * 60 * 1000;
//msg.delay = msg.delay + 5 * 60 *60 *1000 ;
return msg;
1 Like