From 397ae438fe3eace42ddaf1d7b0f43a4e89b201fc Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Sat, 1 Aug 2026 01:40:38 +0200 Subject: [PATCH] Adapt zwave_js to set via_device_id in DeviceInfo (#177861) --- homeassistant/components/zwave_js/__init__.py | 10 +++++++--- homeassistant/components/zwave_js/api.py | 14 +++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/zwave_js/__init__.py b/homeassistant/components/zwave_js/__init__.py index c19060a9435e..340caab8481c 100644 --- a/homeassistant/components/zwave_js/__init__.py +++ b/homeassistant/components/zwave_js/__init__.py @@ -696,11 +696,15 @@ class ControllerEvents: node_id_device = self.dev_reg.async_get_device_by_identifier( device_id, self.config_entry.entry_id ) - via_identifier = None + via_device_id: str | None = None controller = driver.controller # Get the controller node device ID if this node is not the controller if controller.own_node and controller.own_node != node: - via_identifier = get_device_id(driver, controller.own_node) + via_device_id = dr.async_get_device_id_by_identifier( + self.hass, + get_device_id(driver, controller.own_node), + config_entry_id=self.config_entry.entry_id, + ) if device_id_ext: # If there is a device with this node ID but with a different hardware @@ -747,7 +751,7 @@ class ControllerEvents: model=node.device_config.label, manufacturer=node.device_config.manufacturer, suggested_area=node.location or UNDEFINED, - via_device=via_identifier, + via_device_id=via_device_id, ) async_dispatcher_send(self.hass, EVENT_DEVICE_ADDED_TO_REGISTRY, device) diff --git a/homeassistant/components/zwave_js/api.py b/homeassistant/components/zwave_js/api.py index d8af704cf05c..abeeed3ffce3 100644 --- a/homeassistant/components/zwave_js/api.py +++ b/homeassistant/components/zwave_js/api.py @@ -1141,6 +1141,14 @@ async def websocket_provision_smart_start_node( manufacturer = device_info.manufacturer model = device_info.label + via_device_id: str | None = None + if driver.controller.own_node: + via_device_id = dr.async_get_device_id_by_identifier( + hass, + get_device_id(driver, driver.controller.own_node), + config_entry_id=entry.entry_id, + ) + # Create an empty device device = dev_reg.async_get_or_create( config_entry_id=entry.entry_id, @@ -1148,11 +1156,7 @@ async def websocket_provision_smart_start_node( name=device_name, manufacturer=manufacturer, model=model, - via_device=( - get_device_id(driver, driver.controller.own_node) - if driver.controller.own_node - else None - ), + via_device_id=via_device_id, ) dev_reg.async_update_device( device.id, area_id=msg.get(AREA_ID), name_by_user=device_name