figured Id check the community for posts on the subject, but to my surprise there isnt a lot… so here goes, as this is my first iteration in efforts to have a count down initiated, in this case before the alarm is activated.
I originally only thought of the numeric count down, and later added the beep, whihc seemed a nice touch.
Falshing the lights would be a very obvious extra detail for the family members…
countdown:
mode: restart
sequence:
- variables:
count: >
{{states('input_number.countdown')|int}}
- repeat:
count: >
{{count}}
sequence:
- service: light.turn_on
target:
label_id: alarm_lamp
data:
flash: short
- service: media_player.play_media
target:
label_id: alarm_speler
data:
media_content_id: media-source://media_source/local/sounds/beep.mp3
media_content_type: music
- service: tts.cloud_say
data:
language: >
{{states('sensor.tts_language')}}
entity_id: >
{{label_entities('alarm_speler')}}
message: >
{{count - repeat.index + 1}}
- delay: 0.5 # had 1 here, but the delay seems to long in the sequence
- service: tts.cloud_say
data:
language: >
{{states('sensor.tts_language')}}
entity_id: >
{{label_entities('alarm_speler')}}
message: Alarm wordt ingeschakeld (Security system enabled)
however, this is not extremely robust in timing, and I already adjusted the delay.
Ive also tried to get the light flash in a parallel sequence, but it wasnt that obvious how to do that in a ‘for’ period of that length.
Maybe someone else has done a count down like this? Please share if you have thoughts or improvements.
Woukd have hoped for some core functionality, like the flash on the light service, but apparently we need to ‘create’ the sequence looping like this.