-
-
Notifications
You must be signed in to change notification settings - Fork 28.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PR #17199 changed trigger.now from local to UTC breaking automations #20110
Comments
Any word on whether or not this will be fixed? |
@OttoWinter, since your PR changed the behavior of trigger.now, what are your thoughts on this? |
It is working fine for me... Have you seen this line? |
Ah you mean the trigger data. Yes then I guess this is true. (though nothing ever documented it being in local time, so changing to UTC is within the documented behavior) |
Did you see my example above? Time triggers are local time, so it makes sense that trigger.now.hour is also in local time. And it was. So although technically undocumented, it does change long standing behavior, which I believe was the right way for it to work, and it breaks existing automations. Can you restore the previous behavior by converting trigger.now back to local time (I believe in this call: |
This not only affects
Results in:
So you can see that two datetimes that represent the same moment in time (i.e., the same timestamp), where one is in UTC, and the other is in local time, will not result in the same weekday. So if trigger.now is in UTC, then any automation that uses |
@OttoWinter, not sure if you've seen my latest two comments. Based on this additional information, do you still think it should not be changed? |
I have spent days trying to figure out why my good morning scripts were broken and I never ever would have guessed that the time is in UTC. I believe that many more people are going to be making the same mistake and getting frustrated assuming that the time is supposed to be local time like it is with everything else. What about daylight savings changes? This would screw up my good morning workflow. |
@pnbruckner can you test the fix in #21544? |
@emontnemery I will, first thing tomorrow. But now that the time trigger has been split, don't you need to make the same change in automation/time_pattern.py? In any case, thanks for working on this! |
You're right of course. #21544 should now cover time pattern as well (and implementation is a bit different as requested by balloob). |
That makes sense, because that is where the problem was introduced (as I described above.) 😃 I tested both a time and time_pattern trigger, before and after the change. Before trigger is UTC, after it's local. I would say that fixes it. Thanks!! |
Home Assistant release with the issue:
0.84.6
Last working Home Assistant release (if known):
0.80
Operating environment (Hass.io/Docker/Windows/etc.):
Raspbian 9.6 (stretch) on pi
Component/platform:
https://www.home-assistant.io/docs/automation/templating/#time
Description of problem:
For a time trigger, trigger.now used to be expressed in local time. Since 0.81 (PR #17199) it is now in UTC. This breaks automations that use trigger.now.hour.
Problem-relevant
configuration.yaml
entries:Traceback (if applicable):
none
Additional information:
Previous code:
https://github.com/home-assistant/home-assistant/blob/3abdf217bb0f41d6f8164321e689bbc551b3ca6a/homeassistant/helpers/event.py#L344-L355
You can see that now passed to async_run_job would be converted to local time.
New code:
https://github.com/home-assistant/home-assistant/blob/f22557098074c8d0c581ff47b18eb0e9ca5012f8/homeassistant/helpers/event.py#L360-L374
You can see that now passed to async_run_job is not converted to local time anymore.
The text was updated successfully, but these errors were encountered: