Skip to content

feat: allow forcing the account timezone instead of trusting the API#444

Merged
nanomad merged 1 commit into
developfrom
feat/force-account-timezone
May 10, 2026
Merged

feat: allow forcing the account timezone instead of trusting the API#444
nanomad merged 1 commit into
developfrom
feat/force-account-timezone

Conversation

@nanomad
Copy link
Copy Markdown
Contributor

@nanomad nanomad commented May 10, 2026

Summary

  • Add --saic-user-timezone / SAIC_USER_TIMEZONE config option to override the account timezone reported by the SAIC API. Accepts an IANA name (Australia/Sydney, Europe/Rome) or the API's GMT±HH:MM form, validated at startup.
  • When the override is set, the gateway still queries the API and logs a WARNING if the current UTC offsets disagree (so DST mismatches surface, but Europe/Rome vs GMT+01:00 stays quiet outside of DST).
  • The override is primed into MqttGateway.__user_timezone at 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 fixed Etc/GMT-N), this is what actually fixes the reported issue.

Refs #438

Test plan

  • poetry run pytest tests/ — 274 passed
  • poetry run ruff check src tests — clean
  • poetry run mypy src tests — clean
  • New unit tests cover: parser validator (Australia/Sydney, GMT+10:00, invalid value), full argparse → Configuration flow, 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.
  • Manual verification by issue reporter (Timezone and DST handling #438) once a build is available.

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
@nanomad nanomad merged commit 2688f81 into develop May 10, 2026
6 checks passed
@nanomad nanomad deleted the feat/force-account-timezone branch May 10, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant