fix: emit timezone-aware UTC timestamps in MQTT payloads - #64
Merged
Merged
Conversation
Change `datetime.now().isoformat()` to `datetime.now(timezone.utc).isoformat()` in message_parser.py and mqtt_publish.py so all MQTT payloads carry an explicit UTC offset (+00:00). Before: "2026-06-05T12:00:00.123456" (naive, no timezone) After: "2026-06-05T12:00:00.123456+00:00" (timezone-aware UTC) ## Ecosystem alignment This matches the existing dominant format across the MeshCore MQTT ecosystem: | Producer | Timestamp format | |-----------------------------|-------------------| | pyMC_Repeater (status/raw) | +00:00 ISO | | meshcore-ha (status/packet) | +00:00 ISO (PR #259) | | meshcoretomqtt (this) | +00:00 ISO | | meshcore-packet-capture | naive ISO (separate tool for Companion radios) | ## Consumer compatibility - **LetsMesh.net** (primary consumer, closed-source): timestamp field is pass-through metadata; +00:00 has been running in production for months with no issues. The actual MeshCore packet timestamp is decoded from the `raw` hex payload by meshcore-decoder, not from this field. - **CoreScope** (self-hosted analyzer, v3.8.3+): Go `time.Parse(time.RFC3339)` accepts both `Z` and `+00:00` as zone-aware. Fix removes the "Naive observer clock" warning introduced in CoreScope PR #1480. - **meshcore-ha** (Home Assistant integration, PR #259): switched to `datetime.now(timezone.utc).isoformat()` producing +00:00; test accepts both +00:00 and Z. ## Verification - 329 tests passed, 28 skipped (no regressions) - LSP diagnostics clean on both changed files - Python ast.parse validates both files - `datetime.now(timezone.utc).isoformat()` produces format verified with assert: `"+00:00" in aware_timestamp`
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.
Change
datetime.now().isoformat()todatetime.now(timezone.utc).isoformat()in message_parser.py and mqtt_publish.py so all MQTT payloads carry an explicit UTC offset (+00:00). Fix removes the "Naive observer clock" warning introduced in CoreScope PR Kpa-clawbot/CoreScope#1480.Before: "2026-06-05T12:00:00.123456" (naive, no timezone)
After: "2026-06-05T12:00:00.123456+00:00" (timezone-aware UTC)
Ecosystem alignment
This aligns the format across the MeshCore MQTT ecosystem: