Adapt drop_connect to set via_device_id in DeviceInfo - #178104
Merged
Conversation
Contributor
|
Hey there @ChandlerSystems, @pfrazer, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Contributor
There was a problem hiding this comment.
Pull request overview
Updates DROP child devices to reference an existing owner hub by device ID.
Changes:
- Looks up the owner hub during entity initialization.
- Sets
via_device_idwhen the hub is available. - Missing test coverage for successful linking.
Comment on lines
+51
to
+52
| if via_device is not None: | ||
| self._attr_device_info["via_device_id"] = via_device.id |
MartinHjelmare
marked this pull request as draft
August 3, 2026 18:59
MartinHjelmare
approved these changes
Aug 3, 2026
emontnemery
marked this pull request as draft
August 3, 2026 21:17
emontnemery
commented
Aug 4, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
homeassistant/components/drop_connect/entity.py:54
- Resolve the owner config entry first and scope the identifier lookup to it.
async_get_devices()returns matches in config-entry insertion order; after a shared device is split, several devices can retain this identifier, so[0]can link the child to the wrong split even when the actual hub exists. DROP config-entry unique IDs use this owner ID (config_flow.py:54-55), allowing an exact lookup.
via_devices = dr.async_get(coordinator.hass).async_get_devices(
identifiers={(DOMAIN, entry_data[CONF_DEVICE_OWNER_ID])}
)
if via_devices:
self._attr_device_info["via_device_id"] = via_devices[0].id
emontnemery
marked this pull request as ready for review
August 4, 2026 07:57
bramkragten
pushed a commit
that referenced
this pull request
Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed change
Adapt
drop_connectto setvia_device_idinDeviceInfoThe
via_device_idis best effort because the linked device may be created by another config entry.In a follow-up PR, the solution can be improved to for example update the device if the expected via device is created.
Context in https://developers.home-assistant.io/blog/2026/07/21/device-registry-single-config-entry/
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: