mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Simplify get_unique_id helper function for zwave_js (#66221)
This commit is contained in:
parent
23e39d62d4
commit
72acda81a7
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user