Use UID instead of MAC or channel for unique_ID in Reolink (#119744)

This commit is contained in:
starkillerOG 2024-06-21 20:27:30 +02:00 committed by GitHub
parent d6be733287
commit 8b4a5042bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 213 additions and 28 deletions

View file

@ -112,17 +112,25 @@ class ReolinkChannelCoordinatorEntity(ReolinkHostCoordinatorEntity):
super().__init__(reolink_data, coordinator)
self._channel = channel
self._attr_unique_id = (
f"{self._host.unique_id}_{channel}_{self.entity_description.key}"
)
if self._host.api.supported(channel, "UID"):
self._attr_unique_id = f"{self._host.unique_id}_{self._host.api.camera_uid(channel)}_{self.entity_description.key}"
else:
self._attr_unique_id = (
f"{self._host.unique_id}_{channel}_{self.entity_description.key}"
)
dev_ch = channel
if self._host.api.model in DUAL_LENS_MODELS:
dev_ch = 0
if self._host.api.is_nvr:
if self._host.api.supported(dev_ch, "UID"):
dev_id = f"{self._host.unique_id}_{self._host.api.camera_uid(dev_ch)}"
else:
dev_id = f"{self._host.unique_id}_ch{dev_ch}"
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, f"{self._host.unique_id}_ch{dev_ch}")},
identifiers={(DOMAIN, dev_id)},
via_device=(DOMAIN, self._host.unique_id),
name=self._host.api.camera_name(dev_ch),
model=self._host.api.camera_model(dev_ch),