Skip to content

Call mqttClient.loop() during OTA download to prevent MQTT offline, and broadcast update percentage over MQTT#603

Merged
BrentIO merged 9 commits into
mainfrom
fix/602
Jun 21, 2026
Merged

Call mqttClient.loop() during OTA download to prevent MQTT offline, and broadcast update percentage over MQTT#603
BrentIO merged 9 commits into
mainfrom
fix/602

Conversation

@BrentIO

@BrentIO BrentIO commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds mqttClient.loop() inside both onProgress callbacks (auto OTA in setup_OtaFirmware() and forced OTA in otaFirmware_checkPending()) so MQTT keepalives fire during the blocking execOTA() download and the broker does not drop the connection
  • Fixes otaFirmware_checkPending() publishing in_progress: false immediately before calling execOTA() — changed to true so Home Assistant correctly shows the update as in-progress
  • Adds live update_percentage publishing during OTA download: globals _otaLatestVersion, _otaReleaseUrl, and _otaLastPublishedPercentage are set before each OTA begins (from onAvailable for the auto path, from _otaPendingDoc for the forced path); onProgress publishes a full state payload on each integer-percent change
  • Appends " (Forced)" to latest_version in forced OTA progress publishes so Home Assistant detects a version difference and renders the install progress bar even when installed and target versions are identical
  • Adds title field to each onProgress publish (e.g. "Flashing UI", "Flashing Firmware") so Home Assistant shows which partition is currently being flashed instead of the progress bar resetting silently between partitions
  • Updates AsyncAPI documentation: corrects update_percentage description (0–100, not percentage×100), documents the " (Forced)" suffix on latest_version, adds installed_version/latest_version/release_url/title to updateInProgressPayload, removes title/release_summary from updateAvailablePayload (controller does not publish them), and replaces sparse examples with realistic, complete payloads covering all scenarios

Test plan

  • Trigger a forced OTA update and verify MQTT remains online throughout the download
  • Verify Home Assistant shows in_progress: true as soon as the forced OTA begins
  • Verify update_percentage increments in the HA update entity during download
  • Verify title changes from "Flashing UI" to "Flashing Firmware" between partitions
  • Verify latest_version carries the (Forced) suffix in progress publishes for forced OTA
  • Verify auto OTA check path also stays online and shows progress during download

Fixes #602

🤖 Generated with Claude Code

Without this, the blocking execOTA() download prevents loop() from
running, causing MQTT to drop offline during the update.

Fixes #602

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
BrentIO and others added 2 commits June 20, 2026 20:12
The pre-execOTA publish in otaFirmware_checkPending() incorrectly set
in_progress to false. Home Assistant therefore never saw the update
state transition to in-progress during a forced OTA download.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tracks latest version and release URL in globals (set from onAvailable
for auto OTA and from _otaPendingDoc for forced OTA). onProgress
publishes a full state payload with update_percentage on each integer
percent change so HA shows live download progress.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@BrentIO BrentIO changed the title Call mqttClient.loop() during OTA download to prevent MQTT offline Call mqttClient.loop() during OTA download to prevent MQTT offline, and broadcast update percentage over MQTT Jun 21, 2026
BrentIO and others added 2 commits June 21, 2026 09:51
HA requires installed_version != latest_version to show an update as
actively installing. Forced OTA may use the same version string, so
appending (Forced) ensures the values always differ.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix update_percentage description: value is 0-100, not percentage*100
- Document (Forced) suffix on latest_version for forced OTA installs
- Add installed_version, latest_version, release_url to updateInProgressPayload
  to match the full state payload now published by onProgress callbacks

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
BrentIO and others added 4 commits June 21, 2026 10:10
- Add title field (e.g. "Flashing UI", "Flashing Firmware") to onProgress
  MQTT state publish so Home Assistant shows which partition is active
- Remove title/release_summary from updateAvailablePayload schema; controller
  does not publish those fields from onAvailable
- Add title field to updateInProgressPayload schema
- Replace message-level examples with realistic, complete payloads including
  forced OTA and per-partition progress scenarios

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Partition names app and ui are lowercase; title now matches exactly
what the OLED displays.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@BrentIO BrentIO merged commit d1a3856 into main Jun 21, 2026
9 checks passed
@BrentIO BrentIO deleted the fix/602 branch June 21, 2026 16:16
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.

MQTT drops offline during OTA download

1 participant