Repository navigation
Derive a device's board from its merged config - #3035
Conversation
The board id was derived from a raw text scan of the YAML, so a chip or board set inside packages: or behind a substitution was never seen. Derive it at device load instead, where the merged config is already in hand, and take the esp32 chip from resolve_esp32_variant so the board and the logger interface agree on it.
|
ESPHome Bot (@esphbot) review |
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the changes that derive board identification from merged configuration.
No open issues 🎉
What changed in this PR
Moves board identification into device loading, where merged configuration exposes boards and chips defined through packages or substitutions. This follows #3030 and addresses #2987 while preserving explicit user board selections.
Changes:
- Derives board metadata from merged configuration and reuses ESP32 variant resolution.
- Passes catalog lookup through the scanner, eliminating the metadata resolver’s extra YAML read.
- Adds package and substitution coverage and updates lookup, metadata, and migration tests.
| File | Description |
|---|---|
tests/test_device_board_id.py |
Adds merged-config, substitution, and user-selection coverage. |
tests/controllers/devices/test_metadata_resolver.py |
Updates expectations for user-picked versus derived boards. |
tests/controllers/devices/test_derive_board_id.py |
Tests catalog lookup independently of YAML reading. |
tests/controllers/devices/test_board_id_user_set_migration.py |
Checks migrated board IDs through device loading. |
esphome_device_builder/helpers/device_yaml/_loading.py |
Derives unset board IDs during device loading. |
esphome_device_builder/helpers/device_yaml/_chip.py |
Adds board resolution and shares platform-field extraction. |
esphome_device_builder/helpers/device_yaml/__init__.py |
Exports the board-derivation callback type. |
esphome_device_builder/controllers/devices/metadata.py |
Keeps user picks and separates catalog lookup from YAML reading. |
esphome_device_builder/controllers/devices/controller.py |
Supplies board lookup to the scanner. |
esphome_device_builder/controllers/devices/__init__.py |
Updates the documented helper name. |
esphome_device_builder/controllers/_device_scanner.py |
Threads board derivation into device loads. |
Review effort: Balanced
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3035 +/- ##
=======================================
Coverage 99.77% 99.77%
=======================================
Files 300 300
Lines 26556 26565 +9
=======================================
+ Hits 26495 26504 +9
Misses 61 61
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
|
ESPHome Bot (esphbot)
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
A scanner built without it would silently load every device with no board. Also pin that the last compile's chip outranks the board table.
|
ESPHome Bot (@esphbot) review |
PR Review — Derive a device's board from its merged configReady to merge. The earlier wiring concern is fixed, and only one non-blocking note is left. What the PR does well:
Remaining note:
✅ Resolved since last review (1)Previously-flagged issues verified fixed
Checklist
Automated review by Kōan (Claude) |
ESPHome Bot (esphbot)
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
What does this implement/fix?
A device's board was worked out from a raw text scan of its YAML, so a chip or board set inside
packages:or behind a substitution was invisible and those devices showed no board; it is now derived at device load from the merged config, so they show the board they actually compile for.variant:takes its chip fromresolve_esp32_variant, the rule the logger interface already uses, so both agree on the chip.Live check with the issue's layouts
Dev backend pointed at a scratch config dir,
board_idfromsubscribe_eventsinitial state:esp32:framework only, variant in a packageesp32-generic-s3-bluetooth-proxyesp32:block in a packageesp32-generic-s3-bluetooth-proxyboard: lolin_s3_miniin a packagelolin_s3_miniThe startup shallow scan has no merged config yet, so these show no board until the deep pass fills it in; same as
mcutoday. Which S3 entry wins is catalog order (the bluetooth proxy manifests are marked generic); that is separate from this change.Related issue or feature (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocsmaintenancecidependenciesFrontend coordination
Checklist
ruff,codespell, yaml/json/python checks).tests/where applicable.components.index.json/definitions/components/*.jsonhave not been hand-edited (regenerate viascript/sync_components.pyif a sync is needed).docs/ARCHITECTURE.mdand/ordocs/API.md.