core
core copied to clipboard
TOD (Times Of the Day) is not working correctly after daylight saving
The problem
TOD sensor is ignoring daylight saving time.
Sensor changed state at 10:30
, after CET->CEST (+1h). After HA reboot everything works correctly.
What is version of Home Assistant Core has the issue?
2021.3.3
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Container
Integration causing the issue
tod
Link to integration documentation on our website
https://www.home-assistant.io/integrations/tod/
Example YAML snippet
- platform: tod
name: day
after: '09:30'
before: '22:00'
Anything in the logs that might be useful for us?

tod documentation tod source (message by IssueLinks)
I am in CEST time zone and my sensor based on TOD turns on and off as expected. I cannot reproduce this on 2021.5.x @bkupidura you still have this issue? I am not a dev. I was just trying to see what other bugs besides https://github.com/home-assistant/core/issues/50315 that are open on TOD integration
Problem happens only after daylight saving (till reboot).
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
Pet the gitbot. Go to sleep again.
I experienced this bug this morning after DST change overnight. It seems like the tod sensors need to be reloaded after the DST change.
- platform: tod
name: Morning
after: "04:00"
before: "08:30"
Ignore the 09:30 turn off, that was me making a change. You can see the two scheduled times are off by an hour.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
Pinging the bot
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
Ping silly bot
I believe this is still an issue. Had a time of day sensor for 5am and another starting at 22:00 each day. They are tied to scenes. And I can see the 5am one triggered at 6am and the 2200 at 2300
Can confirm - still an issue
btw, I restarted home assistant, and mine seemed to come right.
Encountered this issue following this morning's UK Daylight Savings change.
configuration.yaml
binary_sensor:
- platform: tod
name: "tod_ha_night"
after: "22:00"
before: sunrise
before_offset: "-01:30"
Following clocks change binary_sensor.tod_ha_night state changed to 'on' at 21:00. Host OS and the HA Time & Date sensor both showed correct time, After a HA restart at 21:04 binary_sensor.tod_ha_night correctly showed 'off'.
Can confirm - still an issue, used HA restart as workaround to fix
(the system clock and HA time_date both showed 22:30)
I can confirm the issue too.
I think the issue happens because TodSensor internally tracks UTC time instead of local time. UTC is not affected by daylight saving time. https://github.com/home-assistant/core/blob/3a13ffcf1376bafff6a32df19b197083abf6e826/homeassistant/components/tod/binary_sensor.py
When we set up "after" and "before", we expect them to be our local times. TodSensor has to set up time triggers to be updated at certain times. In pseudocode, it is updated at "base_time + after" and at "base_time + before". The problem is, "base_time" is currently derived from "utcnow()" instead of "now()", and thus planned updates are oblivious of DST change.
I am not a Python programmer, but hope someone with proper skill can take a look at it.
Same issue here. Need HA restart to get it work again.
Gusss we should make an automation that on local daylight savings restart ha...
I also got the wrong starting times after switching daylight savings time. Sensor was defined as:
after: '2022-11-02T08:30:00+02:00'
before: '2022-11-02T18:00:00+02:00'
On editing the values and saving via backend, the new state is…
after: '2022-11-02T08:30:00+01:00'
before: '2022-11-02T18:00:00+01:00'
…and the time table is starting at the expected time again.
Obviously the time being stored with the time zone keeps it from changing to/from DST. The sensor starts at the correct time given the time string, but obviously it is supposed to be interpreted as local time without any time zone interpretation, like input_datetime
:
hour: 8
minute: 30
second: 0
Saving it without time zone…
after: '2022-11-02T08:30:00'
before: '2022-11-02T18:00:00'
…does also not work, because obviously it is interpreted as UTC and not as local time.
Daylight savings just hit in the US and I encountered this issue
Same. First thing I did this morning was restart HA. 😒
Anything? How time automation - something so basic - can be broken on home automation software?
Just ran into this issue myself. Hopefully that PR can be merged...
I confirm the issue. I have defined a binary_sensor as a helper with time boundaries:
Today, 26/march/2023 time changed at 02:00h to 03:00h, however, the binary_sensor was still working in the old time. Some automations did not trigger because the sleeptime binary_sensor was still set to on. It was 07:20h, however, the binary_sensor was still thinking it was 06:20h which is not correct.
I created a workaround automation that detects DST change and reboots Home Assistant:
automation:
- id: "on_dst_change"
alias: "On DST Change"
description: "Triggered when Daylight Saving Time changes are detected"
mode: single
trigger:
# This automation should be triggered ONLY by time.
# Otherwise there is a risk of initiating a reboot cycle
# that will last until the next day
- platform: time
at: "03:01:00"
condition:
condition: template
value_template: >
{% set c_time_utc = utcnow() %}
{% set y_time_utc = c_time_utc - timedelta(hours=24) %}
{% set c_time = c_time_utc | as_local %}
{% set y_time = y_time_utc | as_local %}
{{ c_time - y_time != timedelta(hours=24) }}
action:
- service: homeassistant.restart
Also seeing this issue again. I think I'll add a calendar reminder to manually reboot every 6 months, but thanks for posting that auto restart suggestion. (I just wouldn't trust myself to remember, and would end up debugging 'unexplained' restarts every 6 months 😅)
There's a fix for this issue (See #84931) . Just waiting for a review (@bdraco )
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
This remains an issue - proposed fix https://github.com/home-assistant/core/pull/84931 remains open
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.