Skip to content

fix: use utc timestamps for mqtt#259

Open
Athemis wants to merge 3 commits into
meshcore-dev:mainfrom
Athemis:fix/mqtt-utc-timestamps
Open

fix: use utc timestamps for mqtt#259
Athemis wants to merge 3 commits into
meshcore-dev:mainfrom
Athemis:fix/mqtt-utc-timestamps

Conversation

@Athemis
Copy link
Copy Markdown

@Athemis Athemis commented Jun 4, 2026

Summary

  • Emit UTC-aware MQTT timestamps for status, raw event, and normalized packet payloads
  • Add regression tests for MQTT timestamp formatting
  • Update documentation

Why

CoreScope reports and clamps MQTT observer timestamps when they are emitted as zone-less local-time values. Using UTC offset-aware ISO 8601 timestamps prevents consumers from interpreting local time as UTC and applying false clock-skew corrections.

Testing

  • pytest tests/test_mqtt_timestamps.py -v
  • npm run build in docs

Fixes #258

@Athemis Athemis changed the title Fix/mqtt utc timestamps fix: use utc timestamps for mqtt Jun 4, 2026
maxious added a commit to maxious/meshcore-packet-capture that referenced this pull request Jun 5, 2026
Change `datetime.now().isoformat()` to `datetime.now(timezone.utc).isoformat()`
in packet_capture.py (3 call sites: LWT, publish_status, format_packet_data)
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 format already used by:
- meshcoretomqtt (Cisien/meshcoretomqtt)
- pyMC_Repeater (status/raw path)
- meshcore-ha (Home Assistant integration, PR meshcore-dev/meshcore-ha#259)

## Consumer compatibility

- **LetsMesh.net** (primary consumer): timestamp field is pass-through metadata;
  the actual MeshCore packet timestamp is decoded from the `raw` hex payload.
- **CoreScope** (self-hosted analyzer, v3.8.3+): Go `time.Parse(time.RFC3339)`
  accepts both `Z` and `+00:00` as zone-aware. Removes "Naive observer clock"
  warning from CoreScope PR Kpa-clawbot/CoreScope#1480.
- **Home Assistant / Node-RED**: ISO 8601 with explicit offset is correctly
  parsed regardless of host timezone.
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.

fix: use UTC-aware timestamps in mqtt_uploader.py

1 participant