Skip to content

Promote develop to main: Template Substitution Contract - #164

Merged
ptr727 merged 4 commits into
mainfrom
develop
Sep 21, 2026
Merged

ptr727 merged 4 commits into
mainfrom
develop

Conversation

@ptr727

@ptr727 ptr727 commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner

What

Promotes #163, #165, #166, and #167 to main, which make the template substitution contract consistent across the catalog and the compile recipe portable.

  • wifi_reboot_timeout joins api_reboot_timeout as a per-device knob, and both now resolve on every template that sets a reboot timeout.
  • Each template header declares exactly what it needs, what it exposes, and what is machinery, and OPERATIONS.md states that convention.
  • OPERATIONS.md gains the container invocation that compiles a checkout the way CI does.
  • OPERATIONS.md and README.md drop the host paths and the home directory that described one machine rather than this repository.

Behavior

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

Verification

Carried from the feature pull request, where all 24 test/ configs validate, three example devices compile, and a four-way audit of all 38 templates reports no contract defect.

Notes

#165 closes the finding this promotion's first review raised. OPERATIONS.md documented aht_variant as an exposed PLT-1B override that no template has ever defined, and the list now names the four the template actually exposes. It also corrects an SCD41 attributed to the PLT-1B, a sensor that board does not carry.

#166 closes the two findings this promotion's second review raised. The compile recipe generated secrets.yaml with sed -i, which BSD sed on macOS reads differently, and now writes through a temp file with no -i form and fails closed on every error. The adopter clone instruction named develop against every other @main instruction, and now defaults to main.

#167 closes the finding this promotion's third review raised. The recipe carried on into docker run after a failed secrets step, and now skips the compile with a non-zero status instead.

#165 merged over a pull request review digest that could not read two Copilot summary shapes, on the maintainer's explicit approval. Its content was clean on the head it merged, and the reader is tracked in ptr727/ProjectTemplate#1701.

🤖 Generated with Claude Code

* Add wifi_reboot_timeout and Document CI-Parity Compiles

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.

* Make the Template Substitution Contract Consistent

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.

* Expose the API Reboot Timeout on the Vendor Templates

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.

* Keep Apollo's Own API Reboot Timeout as the Template Default

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.

* Correct the Substitution Documentation Against the Tree

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.

* Name the Two Reboot Substitutions in the Bench Remedy

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.

* Fix the Possessive in the Compile Recipe Introduction
Copilot AI lite review requested due to automatic review settings September 21, 2026 01:19
@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 56 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: f0ee2a74-4e71-4114-93ed-c4fd6408925d

📥 Commits

Reviewing files that changed from the base of the PR and between d583a90 and f2f1d22.

📒 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

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.

@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

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

🔵 Needs a closer look

OPERATIONS.md documents an Apollo PLT-1B substitution (aht_variant) that is not implemented by the corresponding template, so the published contract is internally inconsistent.

Review effort: Lite
Findings: None

What changed in this PR

Promotes the template substitution contract updates from develop to main, making reboot-timeout knobs and template header substitution declarations consistent across the template catalog and documenting local CI-equivalent compile steps.

Changes:

  • Add wifi_reboot_timeout alongside api_reboot_timeout and wire both through templates that set reboot timeouts.
  • Align multiple template headers with the “required / optional / machinery” substitution contract and document additional exposed knobs (e.g., rgb_led_pin, templates_dir).
  • Update OPERATIONS.md / README.md to remove host-specific paths and document a container-based compile workflow matching CI.
File Description
templates/​wifi.yaml Parameterize WiFi reboot timeout via wifi_reboot_timeout.
templates/​waveshare-esp32-s3-eth.yaml Document and default rgb_led_pin for RGB LED status integration.
templates/​unexpectedmaker-pros3d.yaml Document rgb_led_pin as an optional override and annotate its usage.
templates/​temperature.yaml Remove stale “device_name required” header contract claim.
templates/​smarthome-ceilsense.yaml Add api_reboot_timeout / wifi_reboot_timeout knobs and wire them into api:/wifi: blocks.
templates/​rgb-led-status.yaml Remove stale “device_name required” header contract claim.
templates/​norvi-enet-ae06-r.yaml Document templates_dir as an optional substitution knob.
templates/​konnected-blaq.yaml Document wifi_reboot_timeout and clarify machinery substitutions for vendor package bridging.
templates/​ethernet-sensor.yaml Remove stale “device_name required” header contract claim.
templates/​esp32-s3-devkitc.yaml Document rgb_led_pin as an optional substitution knob.
templates/​debug.yaml Remove stale “device_name required” header contract claim.
templates/​common.yaml Update required secrets list to reflect composed includes (adds api_encryption_key).
templates/​basic.yaml Remove stale “device_name required” header contract claim.
templates/​apollo-plt-1b.yaml Add api_reboot_timeout / wifi_reboot_timeout knobs and wire them into api:/wifi: blocks.
templates/​api.yaml Document api_reboot_timeout and ensure it is consistently defined and used.
templates/​adafruit-esp32-s3-feather.yaml Document and default rgb_led_pin for RGB LED status integration.
README.md Update template catalog descriptions and make usage paths host-agnostic.
OPERATIONS.md Document substitution contract conventions and add CI-equivalent container compile invocation; remove host-specific paths.

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

* Drop the Apollo Substitution No Template Defines

aht_variant is documented as an exposed per-plant override and has never
existed in any template, so the published contract names a knob a reader
cannot set. Apollo hardcodes variant AHT20 in its own package, and no unit
in the fleet carries an AHT10.

The list now names the four substitutions the template actually exposes,
and the NVS wipe requirement is scoped to the two first-boot values it
applies to rather than to the reboot timeouts, which take effect on a
reflash.

* Qualify the Apollo Reboot Loop and the NVS Reset Routes

The reboot claim held only for a unit Prevent Sleep keeps awake, since a
sleeping unit resets at the 90 second wake window before a longer timeout
elapses. Apollo also ships a factory reset button, so a USB erase is not
the only way to move a stored first-boot value. The first two bullets now
state their defaults like the other two.

* Bound the Factory Reset Route to an Awake Unit

The factory reset reads as a ready alternative to the USB erase, and it is
not one on the deployed sleeping unit the paragraph is about, which has no
wakeup pin. The template comment also still carried the unqualified reboot
claim the section narrowed.

* Drop the Factory Reset Aside and Correct the Watchdog Comment

Every accurate form of the factory reset aside needs preconditions this
section is not about, so the paragraph keeps the USB route it always had.
The header comment also said 0s keeps a sensor awake, which Prevent Sleep
does, where 0s only disables the API reboot watchdog.

* Drop the False Necessity From the NVS Wipe Instruction

Apollo ships a factory reset that clears preferences too, so naming the
USB erase as the only route was wrong. The instruction now gives the route
without claiming it is the sole one.

* Attribute the Two Upstream Constants to Their Sources

* Read the Prevent Sleep Default and Its Values in One Pass

* State What Moving the Apollo API Timeout Does

* Condition the Apollo Reboot Cycle on an Awake Unit

* Name What Is Compared to the Apollo Run Duration

* Add the Relative Pronoun to the Awake Unit Condition

* Attribute the Humidity Observation to the Sensor the Board Has

The bullet reports tuning tried on the Apollo PLT-1B and then names an
SCD41, which that board does not carry. Its air sensor is the AHT that
Apollo pins to variant AHT20, and the only SCD4x in the tree is the
CeilSense's. The sentence now names the one sensor the claim was observed
on, which also settles the singular verb the compound subject carried.
Copilot AI review requested due to automatic review settings September 21, 2026 03:39

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

🔵 Needs a closer look

The docs include at least two correctness/portability issues (macOS-incompatible sed -i usage and a develop-branch clone instruction that conflicts with the repository’s @main consumption guidance).

Review effort: Lite
Findings: None

Previously missed (2)

In code that hasn't changed since last review

Medium severity Use portable in-place editing for secrets.yaml

OPERATIONS.md:93

Fix (medium): Use a cross-platform in-place edit for secrets.yaml.

sed -i has different semantics on GNU vs BSD/macOS sed, but the repo contract assumes Windows + macOS + Linux support, so this command will fail for macOS users running the CI-matching container compile recipe.

Use a suffix form (-i.bak) and remove the backup so the command works on both sed variants.

Low severity Change clone instructions to use main branch

README.md:245

Fix (medium): Align the clone command with the repository’s published @main usage.

This README section tells users to clone the develop branch into their ESPHome config directory. Elsewhere in the README and in the templates’ external-usage headers, the documented consumption form is consistently @main, so cloning develop here is a surprising default for adopters and can lead to pulling in unreleased changes.

Prefer cloning main in the default instructions (or explain why develop is required if that is intentional).

* Make the Compile Recipe and the Clone Instruction Portable

GNU and BSD sed disagree on a bare -i, which BSD reads as taking the next
argument as a backup suffix, so the recipe's placeholder substitution
failed on macOS, a supported platform. The step now writes sed's output to
a mktemp file and moves it into place, so it uses no -i form and never
touches a sibling path such as a secrets.yaml.bak someone moved aside.

It also fails closed. The key, the template's placeholder, the
substitution, and the move are one condition, so an empty key, a missing
or placeholder-free template, or a failed mv leaves no secrets.yaml for
the guard to keep on every later run, and the temp file is removed on any
failure.

The adopter clone instruction named develop while every other consumption
instruction in the README and the template headers names main. It now
defaults to main, and keeps develop as the route for tracking changes
before they are promoted.

* Give the Secrets Temp File an Explicit Template

A bare mktemp fails on implementations that require a template, and the
file's own lint recipe already names one under /tmp, so this matches it.

* Check mktemp Inside the Secrets Condition

A failed mktemp left tmp empty, so the redirect failed with an unrelated
error before the step's own message. mktemp now runs inside the condition,
only after the key and the template check pass, and the cleanup runs only
when a temp file exists.
Copilot AI review requested due to automatic review settings September 21, 2026 04:08

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

🟡 Changes recommended

The new compile recipe continues after a secrets.yaml generation failure, which can mask the root cause and wastes time running an expected-to-fail compile.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Low severity

Open (1)

Comment thread OPERATIONS.md Resolved
A failed secrets step printed its message and then carried on into docker
run, which failed later on a missing secret, a long way from the cause.
The run is now gated on secrets.yaml existing, so a failed generation
stops there with a non-zero status. An exit would close the terminal of
anyone pasting the recipe, which the gate avoids.
Copilot AI review requested due to automatic review settings September 21, 2026 04:18

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 changes consistently apply the documented substitution contract across templates and documentation without introducing unresolved correctness issues.

Review effort: Lite
Findings: None

Resolved since last review (1)

@ptr727

ptr727 commented Sep 21, 2026

Copy link
Copy Markdown
Owner Author

Answering the three findings the rounds on 84611aa7 and 3415c8c7 raised against this promotion. Two sat in a "Previously missed" block that opened no thread, and the third thread was resolved by the reviewer before a reply landed, so all three are answered here.

Use portable in-place editing for secrets.yaml, OPERATIONS.md: fixed in 3415c8c via #166. BSD sed reads the argument after a bare -i as a backup suffix, so the step failed on macOS. It now writes sed's output to a mktemp /tmp/esphome-secrets.XXXXXX file and moves it into place, with no -i form at all. It also fails closed: the key, the template's placeholder, the temp file, the substitution, and the move are one condition, so any failure leaves no secrets.yaml behind and removes the temp file. That was run as written under bash and dash across six cases, including a failing openssl, mv, and mktemp.

Change clone instructions to use main branch, README.md: fixed in 3415c8c via #166. The adopter instruction now defaults to -b main, matching every @main usage header, and keeps -b develop as the route for tracking changes before they are promoted.

Exit early when secrets.yaml generation fails, OPERATIONS.md: fixed in f2f1d22 via #167. The docker run is gated on secrets.yaml existing, so a failed generation stops before the compile with a non-zero status. A gate rather than exit, because an exit would close the terminal of anyone pasting the recipe. That was run with docker stubbed under bash and dash: it runs when secrets are generated or already present, and is skipped when generation fails.

@ptr727
ptr727 merged commit a7b46de into main Sep 21, 2026
40 checks passed
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