-
Notifications
You must be signed in to change notification settings - Fork 363
feat: Add support for daylight saving time in genTime cluster
#1517
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
feat: Add support for daylight saving time in genTime cluster
#1517
Conversation
|
For ref, here's a code snippet of the handling from Silabs: |
…reschner/zigbee-herdsman into feature/support-dst-in-time-cluster
|
I've looked into the converters to see how other devices handle
It might be sensible to expose the timeService to the converters for this cases, as a lot of them just copied the previous code we now replace. Maybe we should implement a |
…reschner/zigbee-herdsman into feature/support-dst-in-time-cluster
It's an ignore converter to suppress the "No converter available.." message, but since it's not logged anyway for these clusters we can remove this. This converter does not prevent zigbee-herdsman from responding, it was purely there to suppress the log message (before |
Mighty nice cleanup! |
|
@Nerivec: Are there any open tasks for me to do that block a possible merge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive support for daylight saving time (DST) in the genTime cluster, replacing the previous basic time zone handling with a sophisticated system that can handle DST transitions for both Northern and Southern hemispheres. The implementation caches DST calculations for 24-hour periods to improve performance while ensuring accurate time information is provided to Zigbee devices.
Key changes:
- New
timeServicemodule that calculates allgenTimecluster attributes including DST start/end times and offsets - Updated controller to use the time service instead of inline time calculations
- Comprehensive test suite covering various timezone scenarios and DST edge cases
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/utils/timeService.ts | New module implementing DST-aware time cluster attribute calculation with caching |
| src/controller/model/device.ts | Refactored to use timeService for genTime read responses instead of inline calculations |
| src/index.ts | Exports the new getTimeClusterAttributes function from timeService |
| test/timeService.test.ts | Comprehensive test suite for the new time service functionality |
| test/controller.test.ts | Updated genTime read test to verify integration with timeService |
| package.json | Added @date-fns/tz dependency for timezone calculations |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
|
Thanks! |
Currently, there is no support for daylight saving time in zigbee-herdsman. Some devices ask the coordinator repeatedly this information if there is no answer or just the default value as answer (looking at you, Bosch!). To avoid that, there was the need for an
customReadResponsefunction, which isn't that great.This pull request changes that and includes support for daylight saving time. As the whole topic can be pretty complex, I've settled on the basics: daylight saving time is well-established in the timezone. This is important, as countries can leave or introduce daylight saving time (happened a lot over the past 10-20 years). In that case, I leave the default values, which should match the current behavior.
This is a follow-up to #1515.