Fix DST handling in TOD (#29042)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Jean-Marie White 2023-11-11 02:25:44 +13:00 committed by GitHub
parent 43a5a980f8
commit f4be3bfc7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -98,3 +98,34 @@ binary_sensor:
``` ```
In the above example, the next day `sunrise` is calculated as a time range end. In the above example, the next day `sunrise` is calculated as a time range end.
## Daylight Savings Time Handling
The ToD sensor handles the following cases where the sensor interval:
- does not exist at all
- stops at a non-existent time
- starts at a non-existent time.
To help understand all 3 cases, actual examples are provided below.
### Case 1: Sensor Interval Does Not Exist
Let's make the following assumptions:
- Daylight Savings starts at 2am
- On the DST day, the ToD sensor interval is from non-existent 2:30am to non-existent 2:40am.
In this case, the ToD sensor will not trigger since the 2:30am-2:40am interval does not exist on the day when time jumps from 2am to 3am. However, on the following day, the sensor resumed operating normally.
### Case 2: Sensor End Time Does Not Exist
- Daylight Savings starts at 2am
- On the DST day, the ToD sensor interval is from 1:50am to non-existent 2:10am.
In this case, the ToD sensor will last 10 minutes starting at 1:50am and stop at 3am (the 2am-3am time is jumped over and does not exist).
### Case 3: Sensor Start Time Does Not Exist
- Daylight Savings starts at 2am
- On the DST day, the ToD sensor interval is from non-existent 2:50am to 3:10am.
In this case, the ToD sensor will last 10 minutes, starting at 3:00am and stopping at 3:10am (the 2am-3am time is jumped over and does not exist).