Skip to content

Layer the device base packages into common/chip/network - #93

Merged
nuttytree merged 2 commits into
masterfrom
f/base-package-refactor
Sep 30, 2026
Merged

nuttytree merged 2 commits into
masterfrom
f/base-package-refactor

Conversation

@nuttytree

@nuttytree nuttytree commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

device_base.yaml mixed three unrelated concerns into one file: the chip-agnostic core (api, ota, logger, diagnostics, time), and wifi — both the wifi: block itself and the wifi-only diagnostics (signal sensor, wifi-info text sensor). Because wifi was baked into the core, there was no way to build an ethernet device without either duplicating the whole core or including a wifi stack the board doesn't have. The static-IP/DHCP split made it worse: wifi/wifi.yaml and wifi/wifi_dhcp.yaml were near-identical copies of the same block, and every device carried ip_address/ip_subnet/ip_gateway substitutions whether or not it used them.

Devices now include exactly one combo package, which is nothing but a packages: block pulling in one common, one chip and one network layer. Adding an ethernet board is a two-line file rather than a fork of the core.

Changes:

  • Split device_base.yaml into device_common.yaml (chip- and network-agnostic core), device_esp32.yaml / device_esp8266.yaml (platform block only), and device_wifi.yaml / device_eth.yaml (network stack plus its own diagnostics).
  • Add the combo packages devices actually include: device_esp32_wifi.yaml, device_esp8266_wifi.yaml, device_esp32_eth.yaml. There is no esp8266+eth combo — no such device exists here.
  • Add text_sensor/ethernet_info.yaml for the eth layer's IP-address diagnostic, mirroring text_sensor/wifi_info.yaml. The ethernet: block itself stays in the device yaml, since PHY/pin wiring is board-specific.
  • Drop wifi/wifi_dhcp.yaml and collapse wifi/wifi.yaml to the DHCP form. Static IPs are handled by DHCP reservations on the router, so the manual_ip: variant and its substitutions are gone. wifi.yaml now sources wifi_ssid/wifi_password itself instead of relying on device_common.yaml to define them for it.
  • Rename econet_base.yaml to econet.yaml and repoint it at device_esp32_wifi.yaml; rename every device's device_base: package key to device:, now that it names a combo rather than a base.
  • Drop the OTA and AP passwords (password: ${pwd} in ota/ota.yaml and wifi/wifi.yaml) along with ap_timeout. This changes behaviour on upgrade: the first OTA push to each device must still use the old password (the running firmware enforces it), but every push after that is unauthenticated, as is the fallback AP. The per-device pwd: substitutions are left in the device yamls for now but are no longer referenced by anything.
  • Widen the CI build-cache key from device_base*.yaml to device_*.yaml so it still hashes the renamed files.
  • bt-proxy-basement: drop connection_slots from 4 to 3.
  • Add .claude/settings.json denying reads of devices/secrets.yaml.
  • pool.yaml: pin the pzem6l24 external_components source to esphome/esphome at 36d39416f0a7 with refresh: never, instead of tracking github://pr#17849. The PR head moved to automation.register_apply_action on 2026-09-23 ([core][cover] Add register_apply_action for actions that only forward values esphome/esphome#19469), which landed after the 2026.9 branch cut and so exists in no released ESPHome — it took CI's esphome config and compile pool down with it. 36d39416f0a7 is the last commit on that PR still using the stable automation.register_action. The github://pr#N shorthand accepts no @ref, hence the explicit type: git source. The pin is commented with when to drop it.
  • Update CLAUDE.md for the new package layout, and document that Bash filesystem commands must be scoped — devices/.esphome/ holds ~38k toolchain files on an SMB share, and Bash doesn't honour .gitignore the way Grep/Glob do.

Follows on from #92, which parked the pool display stack.

Verified with pre-commit run --all-files clean and esphome config on bt-proxy-basement (esp32+wifi), master-bed (esp8266+wifi), network-equipment (topgreener package) and hvac (econet package); CI validates all of them plus the five compiles.

🤖 Generated with Claude Code

nuttytree and others added 2 commits September 30, 2026 10:36
`device_base.yaml` mixed three unrelated concerns into one file: the
chip-agnostic core (api, ota, logger, diagnostics, time), and wifi --
both the `wifi:` block itself and the wifi-only diagnostics (signal
sensor, wifi-info text sensor). Because wifi was baked into the core,
there was no way to build an ethernet device without either duplicating
the whole core or including a wifi stack the board doesn't have. The
static-IP/DHCP split made it worse: `wifi/wifi.yaml` and
`wifi/wifi_dhcp.yaml` were near-identical copies of the same block,
and every device carried `ip_address`/`ip_subnet`/`ip_gateway`
substitutions whether or not it used them.

Devices now include exactly one combo package, which is nothing but a
`packages:` block pulling in one common, one chip and one network layer.
Adding an ethernet board is a two-line file rather than a fork of the
core.

Changes:
- Split `device_base.yaml` into `device_common.yaml` (chip- and
  network-agnostic core), `device_esp32.yaml` / `device_esp8266.yaml`
  (platform block only), and `device_wifi.yaml` / `device_eth.yaml`
  (network stack plus its own diagnostics).
- Add the combo packages devices actually include:
  `device_esp32_wifi.yaml`, `device_esp8266_wifi.yaml`,
  `device_esp32_eth.yaml`. There is no esp8266+eth combo -- no such
  device exists here.
- Add `text_sensor/ethernet_info.yaml` for the eth layer's IP-address
  diagnostic, mirroring `text_sensor/wifi_info.yaml`. The `ethernet:`
  block itself stays in the device yaml, since PHY/pin wiring is
  board-specific.
- Drop `wifi/wifi_dhcp.yaml` and collapse `wifi/wifi.yaml` to the DHCP
  form. Static IPs are handled by DHCP reservations on the router, so
  the `manual_ip:` variant and its substitutions are gone. `wifi.yaml`
  now sources `wifi_ssid`/`wifi_password` itself instead of relying on
  `device_common.yaml` to define them for it.
- Rename `econet_base.yaml` to `econet.yaml` and repoint it at
  `device_esp32_wifi.yaml`; rename every device's `device_base:`
  package key to `device:`, now that it names a combo rather than a base.
- Drop the OTA and AP passwords (`password: ${pwd}` in `ota/ota.yaml`
  and `wifi/wifi.yaml`) along with `ap_timeout`. **This changes
  behaviour on upgrade:** the first OTA push to each device must still
  use the old password (the running firmware enforces it), but every
  push after that is unauthenticated, as is the fallback AP. The
  per-device `pwd:` substitutions are left in the device yamls for now
  but are no longer referenced by anything.
- Widen the CI build-cache key from `device_base*.yaml` to
  `device_*.yaml` so it still hashes the renamed files.
- bt-proxy-basement: drop `connection_slots` from 4 to 3.
- Add `.claude/settings.json` denying reads of `devices/secrets.yaml`.
- Update CLAUDE.md for the new package layout, and document that Bash
  filesystem commands must be scoped -- `devices/.esphome/` holds ~38k
  toolchain files on an SMB share, and Bash doesn't honour .gitignore
  the way Grep/Glob do.

Verified with `pre-commit run --all-files` clean and `esphome config` on
bt-proxy-basement (esp32+wifi), master-bed (esp8266+wifi),
network-equipment (topgreener package) and hvac (econet package).

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
`external_components: source: github://pr#17849` tracks the head of
upstream's pzem6l24 PR. That PR merged on 2026-09-27, and on 2026-09-23
it picked up `automation.register_apply_action` for its `reset_energy`
action (esphome/esphome#19469). That helper merged into dev *after* the
2026.9 branch cut, so it is in no released ESPHome -- every
`esphome config`/`compile` of pool.yaml against 2026.9.1 now dies with
`module 'esphome.automation' has no attribute 'register_apply_action'`,
which took CI's `esphome config` and `compile pool` jobs down with it.

Tracking a PR head was always going to break the moment that head moved
past the installed release. The goal here is compatibility with a
*released* ESPHome, not dev, so pin the ref instead of chasing it.

Changes:
- Pin the pzem6l24 source to esphome/esphome at
  `36d39416f0a7cdabb536d5a7434222de462c3e89` -- the last commit on that
  PR before the `register_apply_action` switch, still on the stable
  `automation.register_action`. The `github://pr#N` shorthand accepts no
  ref (`validate_source_shorthand` only parses `@ref` for the
  `user/repo` form), so this uses the explicit `type: git` source.
- Change `refresh: 1h` to `refresh: never`: a pinned SHA is immutable,
  so re-fetching it hourly only costs time.
- Comment the pin with why it exists and when it can be dropped, so it
  gets removed once a release carries `register_apply_action` rather
  than silently freezing the component forever.

Verified with `esphome config pool.yaml` locally (valid, and the pinned
SHA fetches fine -- GitHub serves reachable commits by id).

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
@nuttytree
nuttytree merged commit 1b51f7d into master Sep 30, 2026
7 checks passed
@nuttytree
nuttytree deleted the f/base-package-refactor branch September 30, 2026 16:06
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.

1 participant