Skip to content

Make the Template Substitution Contract Consistent - #163

Merged
ptr727 merged 7 commits into
developfrom
wifi-reboot-timeout
Sep 21, 2026
Merged

ptr727 merged 7 commits into
developfrom
wifi-reboot-timeout

Conversation

@ptr727

@ptr727 ptr727 commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner

What

Every template now declares in its own header exactly the substitutions it needs and the ones it exposes, and the WiFi and API reboot timeouts are overridable wherever a template sets one.

  • wifi_reboot_timeout joins api_reboot_timeout as a per-device knob, on wifi.yaml and on the three templates that carry their own wifi: block.
  • api_reboot_timeout reaches the two vendor templates that extend a vendor api: block, where it previously resolved nowhere and a bench override silently did nothing.
  • Six utility templates declared device_name required and never interpolated it. api.yaml documented its own knob nowhere. rgb_led_pin was undocumented on four board templates although the devkitc notes tell an adopter to override it.
  • OPERATIONS.md gains the container invocation that compiles a checkout the way CI does, which the running instance cannot do for a directory it does not mount, and the convention the headers follow.
  • OPERATIONS.md and README.md drop the host paths and the home directory that described one machine rather than this repository.

Why

A bench unit with no network reachable reboots every 15 minutes, and only the API half of that pair was overridable. Extending the knob exposed that the documentation and the templates disagreed in both directions, so the sweep covers the contract rather than the one substitution.

Behavior

No deployed device's resolved configuration changes. Apollo sets reboot_timeout: 0s in its upstream Core.yaml and the including side wins on a scalar, so the PLT-1B template defaults its substitution to 0s rather than to the fleet's 15min. Verified by dumping the resolved config for a deployed plant sensor and a deployed CeilSense before and after.

Verification

  • All 24 test/ configs validate.
  • test/sonoff-s31.yaml, test/apollo-plt-1b.yaml, and test/smarthome-ceilsense.yaml compile, the last two after the api: change.
  • A bench PLT-1B resolves api.reboot_timeout=30s from a device-level override while the default stays 0s, and both newly parameterized templates resolve wifi.reboot_timeout=0s from an override with the default at 15min.
  • A four-way audit of all 38 templates reports no contract defect: nothing declared but unused, nothing used but undeclared, nothing documented but undefined, nothing defined but undocumented, resolved transitively through local !include.

Notes

The comments label is on this pull request because the diff adds comment lines in config, which the prose gate otherwise refuses.

One thing is deliberately left alone and needs a decision: OPERATIONS.md documents aht_variant as an exposed PLT-1B override, and the template has never defined it.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added configurable API and WiFi reboot timeouts, including support for disabling timeouts on bench devices.
    • Documented board-specific RGB LED pin options and additional template substitutions.
  • Documentation

    • Expanded setup and compilation guidance, including container-based build instructions.
    • Replaced environment-specific paths with portable placeholders.
    • Clarified required, optional, and internal substitutions, secrets, template usage, and CI validation steps.

A bench unit with no network reachable reboots every 15 minutes, and only
the API side of that pair was overridable per device. The WiFi template now
exposes the same knob the API template does.

OPERATIONS.md gains the container invocation CI uses to compile a config,
which the running instance cannot do for a directory it does not mount, and
drops the host paths and home directory that described one machine rather
than this repository.
Every template now declares in its own header exactly what it needs and
what it exposes, so a consumer reads one file to know the contract.

The WiFi reboot timeout reaches the two templates that carry their own
wifi: block and never read the substitution, so a bench override on a
PLT-1B or a CeilSense takes effect rather than silently doing nothing.
Six utility templates declared device_name required and never
interpolated it. The API template documented its knob nowhere.

The compile recipe grows a guard that keeps a real secrets.yaml from
being overwritten, names an absolute mount path, and states where
secrets.yaml belongs and what CI checks beyond the compile.
The PLT-1B and CeilSense templates extend a vendor api: block rather than
including api.yaml, so api_reboot_timeout resolved nowhere in those trees
and a bench override silently left the API rebooting every 15 minutes.

rgb_led_pin is an override a consumer reaches for, the v1.0 devkitc board
being the documented case, so the four board templates declare it rather
than leaving it as undocumented plumbing.

The compile recipe keeps its cache between runs, since the build tree
lives there and a fresh directory makes every run a cold build.
Apollo sets reboot_timeout 0s in its upstream Core.yaml, and the including
side wins on a scalar, so a 15min default here would have moved five
deployed plant sensors onto a 15 minute reboot loop whenever Home
Assistant is unreachable. The substitution defaults to 0s instead, which
leaves behavior where it is and still exposes the knob.

The vendor-bridging substitutions are named as machinery in each header
that carries them, the bench-unit remedy names the block each timeout
reaches rather than claiming the whole tree, and the compile recipe
creates its own cache directory.
The README catalog gains the ProS3D pin the template exposes, the
bench-unit remedy names the templates that read the two timeouts rather
than the block shape, and the CI bullet says a utility include joins the
exemption list rather than gaining an example device.

The Apollo comment names the substitution it warns about, since sitting
above two lines made it read as covering the WiFi default below it.
common.yaml lists the encryption key api.yaml needs.
The previous wording dropped both names, leaving a reader told to override
something the bullet never identifies. The README bundle list also gains the
two includes common.yaml composes but never named.
Copilot AI lite review requested due to automatic review settings September 21, 2026 00:55
@ptr727 ptr727 added the comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses label Sep 21, 2026
@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Warning

Review limit reached

Next included review available in 53 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 0ade6e55-8c43-4252-9e07-e14552192d19

📥 Commits

Reviewing files that changed from the base of the PR and between dea7549 and 400ea72.

📒 Files selected for processing (1)
  • OPERATIONS.md

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 2a7ce081-6e36-4670-81bf-d5531596cd53

📥 Commits

Reviewing files that changed from the base of the PR and between a9d46c7 and dea7549.

📒 Files selected for processing (18)
  • OPERATIONS.md
  • README.md
  • templates/adafruit-esp32-s3-feather.yaml
  • templates/api.yaml
  • templates/apollo-plt-1b.yaml
  • templates/basic.yaml
  • templates/common.yaml
  • templates/debug.yaml
  • templates/esp32-s3-devkitc.yaml
  • templates/ethernet-sensor.yaml
  • templates/konnected-blaq.yaml
  • templates/norvi-enet-ae06-r.yaml
  • templates/rgb-led-status.yaml
  • templates/smarthome-ceilsense.yaml
  • templates/temperature.yaml
  • templates/unexpectedmaker-pros3d.yaml
  • templates/waveshare-esp32-s3-eth.yaml
  • templates/wifi.yaml
💤 Files with no reviewable changes (5)
  • templates/rgb-led-status.yaml
  • templates/debug.yaml
  • templates/basic.yaml
  • templates/ethernet-sensor.yaml
  • templates/temperature.yaml

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


📝 Walkthrough

Walkthrough

The pull request updates template substitution documentation, makes selected API and WiFi reboot timeouts configurable, documents board-specific substitutions, and replaces host-specific operation paths with portable instructions.

Changes

Template substitution contracts

Layer / File(s) Summary
Substitution declarations and board documentation
OPERATIONS.md, README.md, templates/*.yaml
Template headers now document required, optional, and machinery substitutions. Obsolete device_name declarations are removed. Board-specific rgb_led_pin, templates_dir, secrets, and package substitutions are documented.

Configurable reboot timeouts

Layer / File(s) Summary
Configurable reboot timeouts
README.md, OPERATIONS.md, templates/api.yaml, templates/apollo-plt-1b.yaml, templates/smarthome-ceilsense.yaml, templates/wifi.yaml
API and WiFi reboot timeouts use substitutions in the affected templates. Defaults and bench-unit overrides are documented.

Path-independent operation and CI documentation

Layer / File(s) Summary
Path-independent operation and CI documentation
OPERATIONS.md, README.md
Host-specific paths are replaced with generic paths. The documentation adds a containerized compile procedure, cache guidance, secret-file handling, ownership details, and CI validation notes.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: standardizing substitution contracts across templates and documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
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 unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The functional template changes appear consistent and low-risk, with only a minor documentation grammar fix suggested.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

This PR standardizes the “template substitution contract” across the ESPHome template catalog by making reboot timeouts consistently overridable and aligning template headers + documentation with actual substitution usage/definitions.

Changes:

  • Add wifi_reboot_timeout as an overridable substitution in wifi.yaml and in templates that define their own wifi: block.
  • Ensure api_reboot_timeout is honored in templates that extend a vendor-provided api: block.
  • Update template headers and repository docs (README.md, OPERATIONS.md) to reflect the true required/optional substitution surfaces and remove stale claims.
File Description
templates/​wifi.yaml Parameterize WiFi reboot_timeout via wifi_reboot_timeout substitution.
templates/​waveshare-esp32-s3-eth.yaml Document rgb_led_pin as an optional substitution (and clarify its use).
templates/​unexpectedmaker-pros3d.yaml Document rgb_led_pin as an optional substitution (and clarify its use).
templates/​temperature.yaml Remove stale “required substitution” header claim (device_name).
templates/​smarthome-ceilsense.yaml Add api_reboot_timeout + wifi_reboot_timeout substitutions and wire them into api:/wifi: blocks.
templates/​rgb-led-status.yaml Remove stale “required substitution” header claim (device_name).
templates/​norvi-enet-ae06-r.yaml Document templates_dir as an optional substitution in header.
templates/​konnected-blaq.yaml Document wifi_reboot_timeout as an optional substitution in header.
templates/​ethernet-sensor.yaml Remove stale “required substitution” header claim (device_name).
templates/​esp32-s3-devkitc.yaml Document rgb_led_pin as an optional substitution in header.
templates/​debug.yaml Remove stale “required substitution” header claim (device_name).
templates/​common.yaml Update required secrets header to include api_encryption_key.
templates/​basic.yaml Remove stale “required substitution” header claim (device_name).
templates/​apollo-plt-1b.yaml Add api_reboot_timeout + wifi_reboot_timeout substitutions and wire them into api:/wifi: blocks.
templates/​api.yaml Document and define api_reboot_timeout as an optional substitution.
templates/​adafruit-esp32-s3-feather.yaml Document rgb_led_pin as an optional substitution (and clarify its use).
README.md Update utility template catalog notes (notably wifi_reboot_timeout and expanded common.yaml composition) and generalize host paths.
OPERATIONS.md Document substitution-header conventions and add a “compile like CI” container invocation; generalize host paths.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread OPERATIONS.md Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The substitution/header contract and documentation updates are consistent with the templates’ actual definitions/usages, and the reboot timeout knobs are correctly wired through with safe defaults.

Review effort: Lite
Findings: None

Resolved since last review (1)

@ptr727
ptr727 merged commit bc57b43 into develop Sep 21, 2026
34 checks passed
@ptr727
ptr727 deleted the wifi-reboot-timeout branch September 21, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants