Skip to content

fix: defer HA-triggered OTA execOTA() out of MQTT callback to main loop#687

Merged
BrentIO merged 2 commits into
mainfrom
fix/686
Jun 21, 2026
Merged

fix: defer HA-triggered OTA execOTA() out of MQTT callback to main loop#687
BrentIO merged 2 commits into
mainfrom
fix/686

Conversation

@BrentIO

@BrentIO BrentIO commented Jun 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • otaFirmware.execOTA() was being called directly inside the MQTT message handler, blocking for the entire firmware download while still inside the MQTT receive callback. Calling mqttClient.loop() re-entrantly from within a callback it fired caused MQTT to disconnect.
  • Applies the same deferred-execution pattern already used for forced updates: sets _otaNonForcedPendingRequest = true in the MQTT callback and executes execOTA() from the main loop after MQTT processing is complete.

Closes #686

Test plan

  • Click "Update" on the firmware entity in Home Assistant.
  • Confirm MQTT stays connected throughout the download and flash (progress percentages continue to publish).
  • Confirm device reboots into new firmware on success.

🤖 Generated with Claude Code

BrentIO and others added 2 commits June 21, 2026 16:47
Calling execOTA() directly inside the MQTT message handler blocked while
downloading firmware, causing MQTT to disconnect. Mirrors the forced-update
pattern: set _otaNonForcedPendingRequest in the callback and execute from
the main loop after MQTT processing is complete.

Closes #686

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Both forced and HA-triggered updates now share _otaPendingRequest.
otaFirmware_checkPending() dispatches on _otaPendingDoc.size() == 0
to distinguish the two paths rather than needing a second flag.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@BrentIO BrentIO merged commit cfa4777 into main Jun 21, 2026
2 checks passed
@BrentIO BrentIO deleted the fix/686 branch June 21, 2026 21:09
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: MQTT disconnects during HA-triggered (non-forced) OTA update

1 participant