If you’re using the standard sensor.time, there is no point using it… just use now().
For time comparison based Template triggers it is best to use a “>=” instead of “==” so you aren’t limiting the trigger to having to hit the time value exactly.
@Didgeridrew, I wonder if using “==” has been why occasionally my alarm doesn’t sound. I think it’s more likely related to the Browser Mod I use to play the alarm sound, but I’ll try “>=”.
the “==” could be an issue but in this case the sensor.time (if it’s the built-in one) will update every minute so if you are comparing another entity that has minutes as well then it shouldn’t be a problem to use the “==”.
but either will work and using “>=” will be a bit safer.
For some reason the trigger suggestions are not working. Of course I first change the alarm time to 31 minutes in the future, then wait for the switch to trigger. There is nothing in the trace in regards to triggers. Here are the entire YAML’s.
alias: Towel Warmer - ON (alarm-based) (Duplicate)
description: Based on alarm1 time minus 30 minutes
trigger:
- platform: template
value_template: >
{{ as_timestamp((strptime(states('sensor.wake_time_1'), '%H:%M') -
timedelta(minutes = 30))|as_local)|timestamp_custom('%H:%M') }}
condition: []
action:
- type: turn_on
device_id: b31f670e26b07fb3708b9ab35649959b
entity_id: switch.towel_warmer_switch_1
domain: switch
mode: single
the template you have in the trigger will never be “true” (so the automation will never trigger) because the template only returns a time. It doesn’t compare that time to anything.
in your first post you compared it to the sensor.time.
you need to add the comparison back into the trigger template.