I noticed that the Alexa Media Player custom component provides sensors for the next timer, reminder and alarm on each device in version 2.3.0 (https://github.com/custom-components/alexa_media_player/wiki#notifications-alarmstimersreminders-versions--230) - I’ve been having a play with this to try to get a kind of “global timer” to announce on all the Echoes in my house. The documentation above suggests that the state of the next timer sensor can be used to trigger actions when the time passes, but I’m struggling to figure out the best way to do it.
I’ve found that testing if the next timer is in the past indicates whether the timer is currently sounding, but actually triggering on that as a condition is more difficult. I tried creating a binary template sensor for the timer sounding by comparing with sensor.time, but https://www.home-assistant.io/integrations/template/#working-without-entities says that will only check and trigger once per minute, which is a bit too much latency for a kitchen timer.
The best I have managed so far is to have an automation triggering every 10 seconds with a condition to check if the timer is going off:
- alias: "Kitchen Timer Announcement"
trigger:
platform: time_pattern
seconds: "/10"
condition:
condition: template
value_template: "{{ states('sensor.kitchen_echo_next_timer') != 'None' and as_timestamp(states('sensor.kitchen_echo_next_timer')) < as_timestamp(now()) }}"
action:
service: notify.alexa_media
data_template:
target: ["media_player.living_room_echo", "media_player.bedroom_echo"]
data:
type: "announce"
message: "The kitchen timer is going off"
This works (every ten seconds while the alarm is sounding!), but is there a better way to do this? What I’d like to be able to do is trigger on the next_timer being updated, and then automatically create some kind of one-shot automation that will run a script at the time in the state of the sensor to make the announcement. Is that possible with HA?