feat: allow forcing the account timezone instead of trusting the API#444
Merged
Conversation
The SAIC API has been observed to return wrong DST offsets (e.g. GMT+11 for an Australian account that is currently on AEST/+10), which caused scheduled charging cron jobs to fire an hour off. Forcing an IANA zone like Australia/Sydney lets the scheduler honour DST transitions natively. Refs #438
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--saic-user-timezone/SAIC_USER_TIMEZONEconfig option to override the account timezone reported by the SAIC API. Accepts an IANA name (Australia/Sydney,Europe/Rome) or the API'sGMT±HH:MMform, validated at startup.WARNINGif the current UTC offsets disagree (so DST mismatches surface, butEurope/RomevsGMT+01:00stays quiet outside of DST).MqttGateway.__user_timezoneat construction so vehicles created during initial discovery — and the scheduled-charging / battery-heating cron jobs they install — already see the forced zone. Because IANA zones are DST-aware (unlike the API's fixedEtc/GMT-N), this is what actually fixes the reported issue.Refs #438
Test plan
poetry run pytest tests/— 274 passedpoetry run ruff check src tests— cleanpoetry run mypy src tests— cleanAustralia/Sydney,GMT+10:00, invalid value), full argparse →Configurationflow, gateway override vs API mismatch logging, fallback when API errors, no-warn when offsets align, and that the forced zone is set on the gateway at construction time.