Skip to content

Commit

Permalink
Merge pull request #96 from dougiteixeira/fix-unique_id-multiple-nodes
Browse files Browse the repository at this point in the history
Fixes unique id for multiple nodes
  • Loading branch information
dougiteixeira authored Jun 16, 2023
2 parents f7683b4 + be82028 commit 8d531c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions custom_components/proxmoxve/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async def async_setup_entry(
node=node,
),
description=description,
vm_id=None,
resource_id=node,
)
)

Expand All @@ -107,7 +107,7 @@ async def async_setup_entry(
vm_id=vm_id,
),
description=description,
vm_id=vm_id,
resource_id=vm_id,
)
)

Expand All @@ -129,7 +129,7 @@ async def async_setup_entry(
vm_id=container_id,
),
description=description,
vm_id=container_id,
resource_id=container_id,
)
)

Expand All @@ -138,15 +138,15 @@ async def async_setup_entry(

def create_binary_sensor(
coordinator,
vm_id,
resource_id,
config_entry,
info_device,
description,
) -> ProxmoxBinarySensorEntity:
"""Create a binary sensor based on the given data."""
return ProxmoxBinarySensorEntity(
coordinator=coordinator,
unique_id=f"{config_entry.entry_id}_{vm_id}_{description.key}",
unique_id=f"{config_entry.entry_id}_{resource_id}_{description.key}",
description=description,
info_device=info_device,
)
Expand Down
10 changes: 5 additions & 5 deletions custom_components/proxmoxve/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ async def async_setup_entry(
node=node,
),
description=description,
vm_id=None,
resource_id=node,
config_entry=config_entry,
)
)
Expand All @@ -454,7 +454,7 @@ async def async_setup_entry(
vm_id=vm_id,
),
description=description,
vm_id=vm_id,
resource_id=vm_id,
config_entry=config_entry,
)
)
Expand All @@ -476,7 +476,7 @@ async def async_setup_entry(
vm_id=ct_id,
),
description=description,
vm_id=ct_id,
resource_id=ct_id,
config_entry=config_entry,
)
)
Expand All @@ -489,13 +489,13 @@ def create_sensor(
info_device: DeviceInfo,
description: ProxmoxSensorEntityDescription,
config_entry: ConfigEntry,
vm_id: str | None = None,
resource_id: str | None = None,
) -> ProxmoxSensorEntity:
"""Create a sensor based on the given data."""
return ProxmoxSensorEntity(
coordinator=coordinator,
description=description,
unique_id=f"{config_entry.entry_id}_{vm_id}_{description.key}",
unique_id=f"{config_entry.entry_id}_{resource_id}_{description.key}",
info_device=info_device,
)

Expand Down

0 comments on commit 8d531c9

Please sign in to comment.