Skip to content

Add device name for Home Assistant and OTA onStart() callback - #8

Merged
JanPetterMG merged 7 commits into
mainfrom
feat/name-and-ota-oe
Aug 26, 2026
Merged

Add device name for Home Assistant and OTA onStart() callback#8
JanPetterMG merged 7 commits into
mainfrom
feat/name-and-ota-oe

Conversation

@JanPetterMG

Copy link
Copy Markdown
Contributor

Introduce a device name for display in Home Assistant and implement an onStart() callback for OTA updates, which disables UART and manages the OE pin state.

@JanPetterMG JanPetterMG added enhancement New feature or request esp labels Aug 26, 2026
@JanPetterMG JanPetterMG added this to the v1.0.0 milestone Aug 26, 2026
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 87f9e8b5-1e63-4ee2-89be-18148b55370d

📥 Commits

Reviewing files that changed from the base of the PR and between 31ceb12 and f42e40a.

📒 Files selected for processing (1)
  • src/esp/DeviceService.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/esp/DeviceService.cpp

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Summary by CodeRabbit

  • New Features

    • Added configurable device naming for Home Assistant, defaulting to “Bekant.”
    • Device hostname is now set automatically when connecting to Wi-Fi.
    • OTA updates now manage the device output state safely during startup.
  • Bug Fixes

    • Devices enter safe mode and restore the configured output state when an OTA update begins.
    • Invalid or fragmented MQTT messages are safely ignored to prevent unintended processing.

Walkthrough

ESP32 initialization now sets the Wi-Fi hostname and uses a separate NAME value for Home Assistant discovery. OTA startup invokes a callback that enters safe mode and restores the configured output-enable state. MQTT documentation now describes ignored payloads.

Changes

ESP32 DeviceService updates

Layer / File(s) Summary
Device identity configuration
include/esp/secrets.h, src/esp/DeviceService.cpp
The ESP32 defines NAME as "Bekant", sets HOSTNAME before Wi-Fi connection, and reports NAME in Home Assistant discovery.
OTA startup and MQTT message handling
include/esp/DeviceService.h, src/esp/DeviceService.cpp
DeviceService declares, registers, and implements the OTA onStart callback. The callback enters safe mode and reapplies device.oe to PIN_OE when available. The onMessage documentation states that fragmented and invalid JSON payloads are ignored.

Sequence Diagram(s)

sequenceDiagram
  participant ArduinoOTA
  participant DeviceService
  participant OutputEnableHardware
  ArduinoOTA->>DeviceService: invoke onStart()
  DeviceService->>DeviceService: invoke safeMode()
  DeviceService->>OutputEnableHardware: apply device.oe to PIN_OE
Loading

Merge Risk: 🟡 Moderate · up to f42e4

During OTA startup, builds that define PIN_OE may apply the opposite output-enable state from the configured value, causing incorrect hardware behavior while updating. The issue requires owner follow-up before this change is merge-ready.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the two main changes: the Home Assistant device name and the OTA onStart() callback.
Description check ✅ Passed The description directly matches the changeset. It identifies the Home Assistant device name and the OTA onStart() callback, including UART and OE pin handling.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feat/name-and-ota-oe

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@JanPetterMG
JanPetterMG marked this pull request as ready for review August 26, 2026 20:29
Copilot AI lite review requested due to automatic review settings August 26, 2026 20:29
@chatgpt-codex-connector

This comment was marked as off-topic.

This comment was marked as off-topic.

@JanPetterMG

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@JanPetterMG

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c38b1a36-5ce7-4c3e-bd9b-d71df63ef097

📥 Commits

Reviewing files that changed from the base of the PR and between c188a89 and 31ceb12.

📒 Files selected for processing (3)
  • include/esp/DeviceService.h
  • include/esp/secrets.h
  • src/esp/DeviceService.cpp

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

📜 Review details
🔇 Additional comments (3)
include/esp/DeviceService.h (1)

54-54: LGTM!

include/esp/secrets.h (1)

45-49: LGTM!

src/esp/DeviceService.cpp (1)

52-52: LGTM!

Also applies to: 61-61, 179-179

Comment thread src/esp/DeviceService.cpp
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #9

Docstrings generation was requested by @JanPetterMG.

* #8 (comment)

The following files were modified:

* `include/esp/DeviceService.h`
* `src/esp/DeviceService.cpp`
@JanPetterMG
JanPetterMG added this pull request to the merge queue Aug 26, 2026
Merged via the queue into main with commit 6d79ac4 Aug 26, 2026
14 checks passed
@JanPetterMG
JanPetterMG deleted the feat/name-and-ota-oe branch August 26, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request esp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants