Skip to content

fix: deduplicate pollingPhase MQTT publishes#436

Merged
nanomad merged 2 commits intoSAIC-iSmart-API:developfrom
nanomad:fix/deduplicate-polling-phase-publish
Mar 15, 2026
Merged

fix: deduplicate pollingPhase MQTT publishes#436
nanomad merged 2 commits intoSAIC-iSmart-API:developfrom
nanomad:fix/deduplicate-polling-phase-publish

Conversation

@nanomad
Copy link
Contributor

@nanomad nanomad commented Mar 15, 2026

Summary

  • __publish_polling_phase() was called on every polling cycle via should_refresh(), publishing to MQTT even when the phase hadn't changed
  • Added deduplication by tracking the current phase and skipping redundant publishes, matching the existing pattern in set_refresh_mode()
  • Added publish_count tracking to the test mock publisher and a test asserting the phase is only published once when unchanged

Test plan

  • Existing test_vehicle_state.py tests pass (phase is still published on transitions)
  • New test_polling_phase_not_republished_when_unchanged confirms deduplication works
  • mypy and ruff pass

🤖 Generated with Claude Code

nanomad and others added 2 commits March 15, 2026 19:51
__publish_polling_phase() was called on every polling cycle via
should_refresh(), publishing the phase to MQTT even when unchanged.
Track the current phase and skip redundant publishes, matching the
existing deduplication pattern in set_refresh_mode().

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Verifies that the deduplication correctly re-publishes a phase after
an intervening different phase (OFF -> FORCE -> OFF publishes 3 times).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nanomad nanomad merged commit 854f641 into SAIC-iSmart-API:develop Mar 15, 2026
3 checks passed
@nanomad nanomad deleted the fix/deduplicate-polling-phase-publish branch March 15, 2026 18:55
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