diff --git a/homeassistant/components/zwave_js/__init__.py b/homeassistant/components/zwave_js/__init__.py index 10088f62414..7fb785d429e 100644 --- a/homeassistant/components/zwave_js/__init__.py +++ b/homeassistant/components/zwave_js/__init__.py @@ -446,9 +446,7 @@ async def async_setup_entry( # noqa: C901 # We assert because we know the device exists assert device - unique_id = get_unique_id( - client.driver.controller.home_id, disc_info.primary_value.value_id - ) + unique_id = get_unique_id(client, disc_info.primary_value.value_id) entity_id = ent_reg.async_get_entity_id(disc_info.platform, DOMAIN, unique_id) raw_value = value_ = value.value diff --git a/homeassistant/components/zwave_js/entity.py b/homeassistant/components/zwave_js/entity.py index 87e9f3adbbd..a61fc3765c7 100644 --- a/homeassistant/components/zwave_js/entity.py +++ b/homeassistant/components/zwave_js/entity.py @@ -48,7 +48,7 @@ class ZWaveBaseEntity(Entity): # Entity class attributes self._attr_name = self.generate_name() self._attr_unique_id = get_unique_id( - self.client.driver.controller.home_id, self.info.primary_value.value_id + self.client, self.info.primary_value.value_id ) self._attr_entity_registry_enabled_default = ( self.info.entity_registry_enabled_default diff --git a/homeassistant/components/zwave_js/helpers.py b/homeassistant/components/zwave_js/helpers.py index de7ed5da502..3deb75cf761 100644 --- a/homeassistant/components/zwave_js/helpers.py +++ b/homeassistant/components/zwave_js/helpers.py @@ -55,9 +55,9 @@ def update_data_collection_preference( @callback -def get_unique_id(home_id: str, value_id: str) -> str: - """Get unique ID from home ID and value ID.""" - return f"{home_id}.{value_id}" +def get_unique_id(client: ZwaveClient, value_id: str) -> str: + """Get unique ID from client and value ID.""" + return f"{client.driver.controller.home_id}.{value_id}" @callback diff --git a/homeassistant/components/zwave_js/migrate.py b/homeassistant/components/zwave_js/migrate.py index d9b46ac725c..73a094fd95a 100644 --- a/homeassistant/components/zwave_js/migrate.py +++ b/homeassistant/components/zwave_js/migrate.py @@ -470,10 +470,7 @@ def async_migrate_discovered_value( ) -> None: """Migrate unique ID for entity/entities tied to discovered value.""" - new_unique_id = get_unique_id( - client.driver.controller.home_id, - disc_info.primary_value.value_id, - ) + new_unique_id = get_unique_id(client, disc_info.primary_value.value_id) # On reinterviews, there is no point in going through this logic again for already # discovered values @@ -485,10 +482,7 @@ def async_migrate_discovered_value( # 2021.2.*, 2021.3.0b0, and 2021.3.0 formats old_unique_ids = [ - get_unique_id( - client.driver.controller.home_id, - value_id, - ) + get_unique_id(client, value_id) for value_id in get_old_value_ids(disc_info.primary_value) ]