Skip to content

Infer one_wire platform gpio for a platform-less source block - #1756

Merged
bdraco merged 1 commit into
mainfrom
bus-onewire-gpio-inference
Jun 30, 2026
Merged

Infer one_wire platform gpio for a platform-less source block#1756
bdraco merged 1 commit into
mainfrom
bus-onewire-gpio-inference

Conversation

@bdraco

@bdraco bdraco commented Jun 30, 2026

Copy link
Copy Markdown
Member

What does this implement/fix?

Two imported boards (kincony_kc868_aio, kincony_kc868_uair) ship a
dallas_temp sensor whose one_wire bus was never lifted into the catalog, so
the full-setup config failed to compile. They were allow-listed by #1755 with the
note "one_wire: block omits platform:".

Root cause: their source (verified on the live devices.esphome.io pages) writes
the older one_wire:\n - pin: GPIO27 form with no platform: key. Modern
ESPHome requires one_wire: - platform: gpio\n pin: X, so _materialize_bus
took the platform-style branch, found no platform, and bailed.

Fix: infer platform: gpio for a one_wire block that has a pin but no
platform. gpio is the only pin-driven one_wire platform (ds2484 is
i2c-bridged and carries no raw pin), so the inference is unambiguous. Pulled the
platform resolution into a small _block_platform helper to keep
_materialize_bus under the complexity limit.

The two boards are removed from the guard's _UNSATISFIED_BUS_ALLOW_LIST; the
guard then verifies the bus is actually lifted (validation stays at 0 errors).
Regenerated against ESPHome 2026.6.3 — the diff is exactly those two boards gaining
a one_wire.gpio entry with its pin locked and the dallas sensor's requires.

Related issue or feature (if applicable):

Types of changes

  • Bugfix (non-breaking change which fixes an issue) — bugfix

Frontend coordination

  • No frontend change needed

Checklist

  • The code change is tested and works locally.
  • Pre-commit hooks pass (ruff, codespell, yaml/json/python checks).
  • Tests have been added or updated under tests/ where applicable.
  • components.index.json / definitions/components/*.json have not been hand-edited.
  • Architecture-level changes are reflected in docs/ARCHITECTURE.md and/or docs/API.md.

Two boards (kincony_kc868_aio, kincony_kc868_uair) ship a dallas_temp whose
one_wire bus never lifted: their source writes the older 'one_wire: - pin: X'
form with no platform:, so _materialize_bus's platform branch bailed. Infer
platform gpio when a one_wire block has a pin but no platform (gpio is the only
pin-driven one_wire platform; ds2484 is i2c-bridged). Extract _block_platform to
keep _materialize_bus under the complexity limit. Drop both boards from the
guard's allow list; regenerated against ESPHome 2026.6.3.
@bdraco bdraco added the bugfix Bug fix label Jun 30, 2026
@codspeed-hq

codspeed-hq Bot commented Jun 30, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 27 untouched benchmarks


Comparing bus-onewire-gpio-inference (7aaf665) with main (78855c1)

Open in CodSpeed

@esphbot

esphbot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

PR Review — Infer one_wire platform gpio for a platform-less source block

Tight, well-scoped fix that infers platform: gpio for legacy platform-less one_wire blocks. Merge-ready.

Strengths:

  • The _block_platform helper extracts the platform-resolution branch cleanly and keeps _materialize_bus under the complexity limit, with a docstring that records the load-bearing fact (gpio is the only pin-driven one_wire platform; ds2484 is i2c-bridged with no raw pin) — exactly the kind of non-obvious rationale CLAUDE.md wants captured.

  • The inference is correctly narrow: it only fires for bus_domain == "one_wire" with a pin and no platform. A non-string/empty platform still falls through the final isinstance(platform, str) and platform guard, so the original reject behavior is preserved; ds2484 (no raw pin) and the multi-block ambiguity path are untouched.

  • New test test_infers_gpio_platform_for_platform_less_one_wire mirrors the existing platform-style test and pins component_id, locked pin value, consumer requires, and pin occupancy — behavior-level assertions, no source inspection.

  • The two boards are dropped from _UNSATISFIED_BUS_ALLOW_LIST so the guard now actively verifies the lift (validation stays at 0 errors), and the regenerated manifests/board bodies show exactly the promised delta: a one_wire.gpio featured entry with locked pin, the dallas sensor gaining requires: [one_wire_bus], and the pin marked occupied.

  • No correctness, security, or YAGNI concerns found.

  • Diff matches the PR description; the remaining 3 allow-list entries (uart/i2c, id-less consumers) are correctly left in place with clarified comments.

  • docs checklist box is unchecked, which is appropriate — no architecture/API surface changed.



Checklist

  • Inference logic correct and narrowly scoped
  • Edge cases preserved (non-string platform, ds2484, multi-block ambiguity)
  • Test coverage for new branch
  • Generated artifacts regenerated, not hand-edited
  • Diff aligns with PR description

Automated review by Kōan (Claude) HEAD=7aaf665 45s

@esphbot esphbot 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.

No blocking issues found.

@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.54%. Comparing base (78855c1) to head (7aaf665).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1756   +/-   ##
=======================================
  Coverage   99.54%   99.54%           
=======================================
  Files         228      228           
  Lines       18203    18203           
=======================================
  Hits        18121    18121           
  Misses         82       82           
Flag Coverage Δ
py3.12 99.52% <ø> (ø)
py3.14 99.54% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bdraco
bdraco marked this pull request as ready for review June 30, 2026 01:15
Copilot AI review requested due to automatic review settings June 30, 2026 01:15

Copilot AI 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.

Pull request overview

This PR fixes bus lifting for imported boards whose source YAML uses the legacy platform-less one_wire syntax (one_wire: - pin: ...). It improves script/sync_esphome_devices.py so the catalog generation can infer platform: gpio in this specific case, ensuring full-setup featured configs compile and letting validate_definitions.py enforce satisfied bus dependencies without allow-listing those boards.

Changes:

  • Infer one_wire platform as gpio when a platform-style bus block has pin but no platform.
  • Remove kincony_kc868_aio and kincony_kc868_uair from the unsatisfied-bus allow list and regenerate their lifted catalogs (YAML + JSON bodies) with the new one_wire.gpio bus and requires.
  • Add a regression test covering platform-less one_wire lifting.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
script/sync_esphome_devices.py Adds _block_platform() and uses it in _materialize_bus() to infer one_wire.gpio for platform-less blocks.
tests/test_sync_esphome_devices_bus_dep.py Adds regression test ensuring platform-less one_wire lifts to one_wire.gpio and stamps requires.
script/validate_definitions.py Removes the two boards from _UNSATISFIED_BUS_ALLOW_LIST now that the bus can be lifted.
esphome_device_builder/definitions/boards/kincony_kc868_uair/manifest.yaml Adds featured one_wire.gpio bus entry, pin occupancy, and requires for the dallas sensor.
esphome_device_builder/definitions/boards/kincony_kc868_aio/manifest.yaml Adds featured one_wire.gpio bus entry, pin occupancy, and requires for the dallas sensor.
esphome_device_builder/definitions/board_bodies/kincony_kc868_uair.json Regenerated body reflecting the lifted one_wire.gpio bus and requires.
esphome_device_builder/definitions/board_bodies/kincony_kc868_aio.json Regenerated body reflecting the lifted one_wire.gpio bus and requires.

Comment thread script/sync_esphome_devices.py
@bdraco
bdraco merged commit 9acd745 into main Jun 30, 2026
24 checks passed
@bdraco
bdraco deleted the bus-onewire-gpio-inference branch June 30, 2026 01:19
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bugfix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants