I’m at a loss here. I am trying to have the automation below execute. I have tested the notify function, I’ve tested the sliders, I’ve tested the value template, there has to be something painfully obvious that I am NOT seeing. I did try single quote around the template, double quote, no quote. (interestingly no quote just stops HAss from starting, no errors in logs just NOTHING) For formatting: http://hastebin.com/johukeriku.sm
automation:
alias: ‘Check Every 5 minutes for updated time.’
trigger:
platform: time
minutes: ‘/5’
seconds: 5
condition: template
value_template: “{{ now.time().strftime(”%-H") == states.input_slider.alarmhour.state and now.time().strftime("%-M") == states.input_slider.alarmminutes.state }}"
action:
service: notify.notify
data:
message: “timer”
title: “Test Fire 5 minutes & 5 Seconds”
Thank you, unfortunately it didn’t change anything. I hadn’t named the notify platform, but naming it and commenting out the condition and rename the rule to something more grep friendly, I see it pop up in the log at restart.
16-06-09 14:36:41 homeassistant.components.automation: Initialized rule 5_minute
However, with the condition in place it never initializes the rule.
Logs are set to default: debug in an attempt to figure out the problem. Since the automation consists of the sensor and value_template I dont see much point in limiting logging.
Nothing in the lots at the trigger time. Commenting out the conditions on the trigger gives me the initialized rule line in the logs as well as notifications every 5 minutes. Either the test is wrong (which I’ve verified is correct) or the condition template doesn’t like my syntax or something…
I have the same issue with a similare automation. When I test this template with developper tools, if it is 14:30 by example : {{ now.time().strftime("%-H") == 14 and now.time().strftime("%-M") == 30 }}
Tried a new value_template, no luck. Tried to go with ‘{{ states(“sensor.time”) == states(“sensor.alarm_time”) }}’ so compare time to the set time. I get a false now, I tried to throw it in an automation, since it only matches for 1 second technically. I still dont get anything.
The problem with now.time() is that its not actually 8:52. its. 08:52:36.662273 I had the same problem when I tried to states.sensor.time I got the name and all of the information. So when I use {{ states(“sensor.time”) }} I get a result of like 08:15 I don’t get the whole time. Not sure if its just showing me that or if its using that as its comparison.
I think you’re formatting wrong time.
On an automation of mine I have now.time().strftime("%H:%M") and it works perfectly, so maybe yours should be now.time().strftime("%H"), not now.time().strftime("%-H") (note the hyphen).
EDIT: If you want something that triggers at determined time, why not use the template for triggering, instead of being a condition? I have one for my wake up automation:
This is the sliders to set the time. The problem is that the hour slider is single digit and doesn’t force double digit. i.e. 09:30 vs 9:30. Does anyone know how to correct that?
input_slider:
alarmhour:
name: Hour
icon: mdi:timer
initial: 9
min: 0
max: 23
step: 1
alarmminutes:
name: Minutes
icon: mdi:timer
initial: 0
min: 0
max: 55
step: 5
Thats where I started, unfortunately I think the problem is the input slider, before noon all of the digits are returned as single digit. i.e. 9:30 vs 09:30. I was trying to use a template to add a leading digit or change it to a time value (assuming it adds the leading zero) but I cannot get that to work.
Well I changed from the input slider (since I cant pad the hour with a zero) and went to an input_selector, listed out the options in 1/2 hour increments and tested. SUCCESS! Note: I have to quote the options that were double digit hours, otherwise i got some interesting math.