The rule is to break the failure which is in a current quantum state (hence everything is the fault).
How do you break this rule and opening the cats box? You do this by posting a message for help in a forum.
The problem is the timezone, actually I’ve tested it but in the wrong direction. I did turn on the timer just to see if works after night. I did set the time to 06:16, and the timezone I’m living in is Europe/Stockholm. The timer triggered one hour too early, in the logbook the switch was turned on at 05:16.
I did try it again, and the trigger is activated 1 hour too early.
So it seems even though I’ve the timezone setup correctly in configuration file, it still is wrong.
Update:
I did add a field showing the current time (this is the time I do compare with in the conditions when triggering the action). The strange thing is that this field is showing current local time correctly, even though the trigger is activated one hour too early:
- platform: template
sensors:
current_time:
friendly_name: Nuvarande tid
value_template: '{{ "%0.02d:%0.02d" | format(now().strftime("%-H") | int, now().strftime("%-M") | int) }}'
Update 2:
I solved the problem, though I’m not sure if this is a bug I have avoided in homeassistant.
What I did was to compare the values of. current_time with car_heat_time. It seems if compare the values from now() directly does not work (hence UTC is returned). If setting a value in homeassistant from now(), homeassistant will then, in a later state, convert this value to local time.
These two configuration files now works, but I’m unsure which ones is the most reliable approach.
Which is most reliable of setting trigger to:
poll every minute and then compare the times and button states
or
activate from a value_template comparison, and then check condition of button states.
The second method feels cleaner code-wise. config.yaml (3.6 KB)
Nice that you found your issue. Good catch with showing the current time as custom sensor. But weird I am also on the same non UTC timezone and I last time I checked, it worked for me…
On which version are you?
You do not need the extra switch actually. You can directly switch the automation rule itself on and off. So the additional switch is just duplicating this behaviour. Then the second option is even cleaner in the configuration file. It gets triggered just as often I think (every time the sensor for the time changes, so every minute).
Did you also try using the timestamp_custom function? Can you check what a sensor with the template
'{{ (now().strftime("%s") | int | timestamp_custom("%H:%M")) }}'
shows? If that is the correct time, then the automated rule should work. Otherwise it’s a bug…
By the way a good way to test and debug your rules quickly is using the template developers feature, left side second last icon.
There you can add your code to test and see what it would show. I also tested my rules this way.
And I still think that the timestamp_custom should just work :P. As you can see it shows 14:46, while it was 13:46 UTC time.
Tried running the command:
‘{{ (now().strftime("%s") | int | timestamp_custom("%H:%M")) }}’
in the template developers UI.
It was giving me a time of: 23:20
While the local time was: 22:20
UTC time was : 21:20
Going in via ssh to the server and typing ‘date’ in the terminal gave me an UTC time of: 21:20.
So there is something strange going on for sure. Maybe homeassistant is using two different timezones?
Edit:
Version of homeassistant I’m using is: 0.35.3
Version of python3 is: 3.4.2
Yeah that is indeed weird. That would mean that somewhere your timezone settings are messed up.
You can verify your timezone:
'{{ (now().strftime("%s") | int | timestamp_custom("%H:%M %z%Z")) }}'
'{{ (now().strftime("%s") | int | timestamp_local }}'
'{{ (now().strftime("%Z") ) }}'
But I guess these would show for you +0200 as your timezone. Which is incorrect. Did you try setting a different timezone, with the same time, i.e. Europe/Amsterdam?
And can you run the date command with showing the timezone on your server via ssh:
This is really weird indeed. So the timezone is set correctly, and the UTC time is correct on your server machine. But the time is still wrong…
But you say that:
now().strftime("%H:%M")
shows the correct time? So I assume that the Homeassistant internal UTC clock is off by one hour.
You can confirm my suspicion by running:
At least it’s consistent. Apparently, for some reason your homeassistant’s UTC time is off by one hour. This explains the issues you were having. And it’s worthwhile to fix it, since otherwise, as soon as you switch to summer time, your timers will not work anymore at the suspected times but one hour off… But I have no clue what it causing the time shift…
syntax error or is the alarm going off at the wrong time? Because the calculations on the left side should add 20 minutes to the current time to compare against the time on your input boolean not subtract it.
anyone managed to add a “snooze” and “off” function? I’m using mqtt buttons with Wemos D1 and Button Shield and also Amazon Dash buttons for various other automations around the house.
A snooze and off function would be easy with two buttons (one for snooze that stops the script for 5mins and then starts it again using a delay. And off is self explanatory) but really id like one button. Anyone have any thoughts about this?