Alexa Media Player timers as a trigger

Has anyone been able to replicate this with Node-Red? I would like to do it this way so i can easily dupllcate for different actions and events. However I am stuck at first hurdle of getting node-red to start action when alexa timer (or alarm) is reached?
I think i want the check to start when timer/alarm set. This outputs the payload with DateTime stamp I can use. However unsure which node i would use to say when time = value then do next action.
Appreciate any guidance as fairly new to Node-Red

Possibly not the best way but here is way I have achieved it. Its all running off the Time sensor and if there is a timer set one a specific device it will output in same minute on others that it is due. (i could not get the seconds to line up for exact notification on time complete)

[{"id":"d797401a.4ce6b8","type":"api-current-state","z":"3eb8c7f5.da2088","name":"timer","server":"9905c3e1.09ce1","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.living_room_next_timer","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":410,"y":720,"wires":[["850e7f9e.fc8448"]]},{"id":"850e7f9e.fc8448","type":"moment","z":"3eb8c7f5.da2088","name":"format","topic":"","input":"","inputType":"msg","inTz":"Europe/London","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-MM-DD, HH:mm","locale":"C","output":"","outputType":"msg","outTz":"Europe/London","x":510,"y":720,"wires":[["12617f44.29c299"]]},{"id":"1235b6c2.9b7eb9","type":"api-current-state","z":"3eb8c7f5.da2088","name":"echo timer set?","server":"9905c3e1.09ce1","version":1,"outputs":2,"halt_if":"unavailable","halt_if_type":"str","halt_if_compare":"is_not","override_topic":false,"entity_id":"sensor.living_room_next_timer","state_type":"str","state_location":"","override_payload":"global","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":263,"y":760,"wires":[["d797401a.4ce6b8","d58c8e70.cab97"],[]]},{"id":"12617f44.29c299","type":"join","z":"3eb8c7f5.da2088","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":650,"y":740,"wires":[["f0d77987.dad4c"]]},{"id":"975148ce.66537","type":"server-state-changed","z":"3eb8c7f5.da2088","name":"Now","server":"9905c3e1.09ce1","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.date_time","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":70,"y":840,"wires":[["1235b6c2.9b7eb9"]]},{"id":"d58c8e70.cab97","type":"moment","z":"3eb8c7f5.da2088","name":"format","topic":"","input":"","inputType":"msg","inTz":"Europe/London","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-MM-DD, HH:mm","locale":"C","output":"","outputType":"msg","outTz":"Europe/London","x":454,"y":780,"wires":[["12617f44.29c299"]]},{"id":"f0d77987.dad4c","type":"function","z":"3eb8c7f5.da2088","name":"Compare","func":"newmsg = {};\nif (msg.payload[0] == msg.payload[1]) {\n    newmsg.payload = \"True\";\n} else {\n    newmsg.payload = \"False\";\n}\n\nreturn newmsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":760,"y":740,"wires":[["b6403c94.cc11f8"]]},{"id":"b6403c94.cc11f8","type":"switch","z":"3eb8c7f5.da2088","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"True","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":870,"y":740,"wires":[["de978f6d.00c8a","aef46216.014828"]]},{"id":"de978f6d.00c8a","type":"api-call-service","z":"3eb8c7f5.da2088","name":"Bedroom Announce","server":"9905c3e1.09ce1","version":1,"debugenabled":false,"service_domain":"notify","service":"alexa_media_bedroom","entityId":"","data":"{\"data\":{\"type\":\"tts\"},\"target\":\"media_player.bedroom\",\"message\":\"Kitchen Timer is due. The Kitchen Timer is due\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":900,"y":680,"wires":[[]]},{"id":"aef46216.014828","type":"api-call-service","z":"3eb8c7f5.da2088","name":"Olivia Announce","server":"9905c3e1.09ce1","version":1,"debugenabled":false,"service_domain":"notify","service":"alexa_media_olivia","entityId":"","data":"{\"data\":{\"type\":\"tts\"},\"target\":\"media_player.olivia\",\"message\":\"Kitchen Timer is due. The Kitchen Timer is due\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":890,"y":800,"wires":[[]]},{"id":"9905c3e1.09ce1","type":"server","z":"","name":"Home Assistant"}]

hi all
i want to send the minute left on the next timer by notify, any one can help me how to do that?

For the life of me I cannot get this to work. Used your old setup for a long time now but this just wont work. The Alexa Timer triggers the automation and the script is triggered too but I thing both right at the moment that I set a new timer not when it goes off. But the other alexas just wont say anything.

I think it must have something to do with quotation marks. Esp since I have the scripts and automations on UI mode but cant see what.

Just sat down to write something like this and found I didn’t need to do anything beyond changing the names of the Echos. Thank you for this, works perfectly.

So I couldn’t get this to work, probably because I edit automations and scripts in the UI rather than use yaml and the UI always screwed it up.
So I used some of the code from this post and found a solution that is simpler for me and is UI based. In case anyone wants to also use the UI here is how I set it up:

  1. Create a new script in the UI.
  • Give it a name
  • choose Mode “restart”
  • In sequence choose “repeat”
  • as typ choose “while”
  • as while condition choose “template”
  • enter this as template value and replace YOUR_DEVICE:
{{ states('sensor.YOUR_DEVICE_next_timer') not in ['None', 'unknown', 'unavailable'] and as_timestamp(states('sensor.YOUR_DEVICE_next_timer')) < as_timestamp(now()) }}
  • as action add “call service”
  • as service choose “notify.alexa_media”
  • as service data enter this replacing your alexa devices to announce the end of the timer:
target:
  - media_player.DEVICE1
  - media_player.DEVICE2
data:
  type: announce
message: The Timer in the kitchen is up!
  • add another action and choose type “delay”
  • enter the value you want the announcement to repeat. I chose 10 seconds
  • save the script and remeber the name for the automation
  1. Go to Blueprints and import the Automation blueprint “Do something when Alexa timer expired” by entering this address:
    Do something when Alexa Timer has expired

  2. Once blueprint is imported create a new automation from it:

  • As Alexa Device chose your “sensor.YOUR_DEVICE_next_timer”
  • as action do “Call Service” and in service chose your script from step one.

That’s it. The announcement will now be repeated until the timer is cancled.
And in case people don’t know this yet: You can start and cancel Alexa Timers from other Alexas. So say you have this set up to announce a timer from the kitchen. You are in the living room and want to set up or cancle a timer that’s announced everywhere you can just say: “Alexa, start a 1 minute timer on Kitchen” or “Alexa stop the timer in the kitchen”

Hope this helps some people

1 Like