Surface project_name / project_version / network for configured devices - #2692
davidcoulson wants to merge 1 commit into
Conversation
ESPHome broadcasts the running firmware's ``esphome: project:`` pair and the link it announced over in the same mDNS TXT as the identity trio, but only the adoption path ever read them — a configured device dropped all three on the floor, so the device table had nothing to sort or filter a fleet by. Ingest them through a descriptive applier table kept separate from ``_IDENTITY_TXT_APPLIERS``: these keys describe the firmware and never vouch for it, so a project-only TXT must not stamp ``deployed_identity_live`` and latch the verify-resolve loop off. The table holds ``(key, field, callback selector)`` triples driven through one private monitor applier rather than three public ``apply_*`` sisters — every entry is the same differ-gate-then-forward, and the monitor is at its PLR0904 ceiling. Persisted to the per-flavor device store alongside ``deployed_version`` for the same reason that one is: an mDNS-only field leaves offline rows permanently blank and silently drops them out of a project filter.
Merging this PR will not alter performance
Comparing Footnotes
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2692 +/- ##
=======================================
Coverage 99.73% 99.73%
=======================================
Files 283 283
Lines 24149 24188 +39
=======================================
+ Hits 24086 24125 +39
Misses 63 63
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Some deployment validation from running this branch against my own fleet (157 configured devices). The gap on Meanwhile the device itself is advertising this over mDNS right now: Three keys already on the wire, already in the TXT record this code path parses — just not surfaced. Scale on a real fleet. 33 of my 157 devices share that single
Happy to pull more numbers off this fleet if that would help review. Disclosure: this PR and this comment were written with AI assistance (Claude Code). I've reviewed the change and verified the test suite, mypy, and ruff locally, in addition to the deployment described above. |
|
Thanks for your contributions. I'm not sure I see the usefulness of the project name and version for the majority of users that would be using the ESPHome Device Builder. The project name and version are fields to be used by makers of devices that are providing / selling them and that users are simply on-boarding to their network and using. For this reason we don't think at this time that we want to have this extra code to have them showing in the tables. The network type is something we are willing to merge in and would like you to split that out so we can get it in there. Jesse |
|
Maybe I'm abnormal (wouldn't be the first time), but I use project name/version extensively in my own projects. For example, I have 60+ Lumary lights running ESPHome on esp32-c3s instead of using the tuya MCUs. There's maybe 3-4 different models of lights, so each model has a different project name that maps to the actual project. 99% of the time I am making a bulk change to one type of light (or as population that have addressable LEDs, etc), so being able to filter by project name then 'select all' when doing select multiple would be super helpful. There's always the odd one that chokes during an update bc 2.4ghz wifi is what it is, so being able to find that one 'old project version' out of a list of 60+ things is nice. I've been exposing that sensor into HA then using that to drive a build list, but it should all be doable in ESPHome Builder. I know there are labels and I've manually added Labels to a bunch of projects, but I've not figured out a good way to handle that automatically and the volume of ESPHome devices I have makes maintaining that super painful. If there is a better approach so I can use labels in a more useful way and not depend on project sensors LMK and I'll be happy to shift my focus :) |
|
The project field is intended for importable (usually off the shelf or Made for ESPHome) devices. If you pull those fields out we can merge the network one |
What does this implement/fix?
ESPHome broadcasts
project_name,project_versionandnetworkin the same mDNS TXT as the identity trio (version/config_hash/mac), but only the adoption path ever read them —AdoptableDevicecarries all three, while a configured device dropped them on the floor. So the device table has nothing to sort or filter a fleet by, even though the data is already on the wire:This surfaces all three on
DeviceRuntimeStatefor configured devices.Descriptive, not identity. The new keys are ingested through their own
_DESCRIPTIVE_TXT_APPLIERStable rather than joining_IDENTITY_TXT_APPLIERS. That separation is load-bearing: the identity appliers' presence is what stampsdeployed_identity_live, and aproject_name-only TXT that vouched for identity freshness would stop the verify-resolve loop from ever re-resolving. They also gate no update or pending-changes verdict. Both halves are pinned by tests.Applied on both the
_esphomelib._tcpand_http._tcppaths — ESPHome publishes the same descriptive set on whichever service the device has, so no-API devices get them too.Persisted to the per-flavor device store alongside
deployed_version, for the same reason that one is: an mDNS-only field leaves offline rows permanently blank and silently drops them out of a project filter.One implementation note for reviewers.
DeviceStateMonitorsits at exactly ruff'sPLR0904ceiling of 20 public methods, and the policy inpyproject.tomlis explicit that the rule exists to catch new growth, with existing offenders grandfathered rather than new ones added. So instead of three publicapply_*siblings ofapply_version, the appliers go through one private_apply_descriptive_observationdriven by a(txt_key, field, callback selector)table. Every entry is the same differ-gate-then-forward, so the table loses nothing — but say the word if you'd rather have the explicit trio and a threshold bump.Related issue or feature (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocsmaintenancecidependenciesFrontend coordination
The frontend PR adds the Project / Project Version / Network columns and the Project / Network facets that consume these fields. This PR is inert without it (the values ride
runtime_stateand simply go unrendered); that PR without this one renders three empty columns and self-hides both facets.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.Verification:
8587 passed, 26 skipped;mypy esphome_device_builderclean;ruff check+ruff format --checkclean.🤖 Generated with Claude Code