Hi!
Im trying to trigger automations from the Alexa alarm.
Today i have a manually set alarm from lovelace that works
trigger:
platform: template
value_template: '{{ states.sensor.time.state == states.sensor.alarm_time.state
}}'
in developer this changes to True but nothing happens, does any one know why?
trigger:
platform: template
value_template: '{{ now().strftime("%Y-%m-%d %H:%M:%S+02:00") == states.sensor.mathias_s_echo_next_alarm.state
}}'
VDRainer
(🍻)
October 1, 2019, 9:42am
2
Read the warning about template trigger in the docs.
Sorry, missed that part.
But my problem is the format off the sensor, can I reformat the time date sensor via template to look like the now template I’ve done?
Hi!
found a working solution
'{{ states.sensor.time.state == as_timestamp(states.sensor.mathias_s_echo_next_alarm.state) | timestamp_custom("%H:%M") }}'
Angelo82
(Angelo)
October 14, 2019, 6:55pm
5
H! Im looking just for thise solution! Tank you so much! But if i need to trigger 30 minutes before the allarm time… What i need to change into your code?
Angelo82
(Angelo)
October 14, 2019, 9:15pm
6
ok i do it!
thise is my automation test:
automation:
- alias: Sveglia CountDown
initial_state: 'on'
trigger:
- platform: template
value_template: >-
{{ ((as_timestamp(strptime(states("sensor.echo_camera_next_alarm"), "%H:%M, %Y-%m-%d")) - (as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d")))) / 60) | int == 30 }}
action:
- service: notify.telegram
data_template:
title: "Sveglia Alexa - {{ states('sensor.time') }}"
message: >-
SuonerĂ fra: {{ ((as_timestamp(strptime(states("sensor.echo_camera_next_alarm"), "%H:%M, %Y-%m-%d")) - (as_timestamp(strptime(states("sensor.time_date"), "%H:%M, %Y-%m-%d")))) / 60) | int }} minuti
alle: {{ as_timestamp(states.sensor.echo_camera_next_alarm.state) | timestamp_custom("%H:%M, %Y-%m-%d") }}```