Skip to content

fix: compare message times in UTC and ignore messages without a time - #522

Open
nanomad wants to merge 1 commit into
developfrom
fix/message-times-utc
Open

nanomad wants to merge 1 commit into
developfrom
fix/message-times-utc

Conversation

@nanomad

@nanomad nanomad commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Includes the bump to saic-ismart-client-ng 0.15.0, which adds the message time helpers this uses. #523 (power tailgate) shares that commit.

The bug

  • messageTime is naive server local time (CET/CEST on EU servers), but ensure_datetime_aware labeled it UTC. Message times were off by 1–2 hours.
  • A message without a time got local now() from message_time. It then looked like the newest message and pushed last_message_ts forward. With TZ set in Docker, e.g. Australia/Sydney, that was about 10 hours in the future.

Changes

  • utils.message_time_utc() returns an aware UTC datetime or None. It uses createTime (a Unix timestamp) when present. Otherwise it reads messageTime in the server timezone and converts it to UTC.
  • New option --saic-message-timezone / SAIC_MESSAGE_TIMEZONE, default Europe/Rome. It takes an IANA name or GMT+HH:MM. The container's TZ doesn't affect message times.
  • MessageHandler skips messages without a time when picking the latest one and when deciding to stop paging. Reading and deleting messages work as before.
  • MessagePublisher publishes nothing for a message without a time.
  • ensure_datetime_aware is removed, since it has no callers left.

Notes

  • AU and TR servers also default to Europe/Rome. Their server timezone is unknown, so users there need to set SAIC_MESSAGE_TIMEZONE.
  • A vehicle start message (type 323) without a time is no longer picked as the latest message, so it now gets deleted like the others.
  • The CHANGELOG entry is in the 0.14.0 section, which is still at RC.

SAIC sends messageTime as naive server local time (CET/CEST on the EU
servers), but the gateway tagged it as UTC, so the last message time and
the new message check were off by one or two hours. Use createTime when
present, otherwise read messageTime in the server timezone, set with
--saic-message-timezone / SAIC_MESSAGE_TIMEZONE (default Europe/Rome).

Messages without a usable time are still read and deleted as before, but
no longer count as the newest message, move last_message_ts or get
published as the last message.
@nanomad
nanomad force-pushed the fix/message-times-utc branch from 1602a94 to 27950c6 Compare November 22, 2026 10:21
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