From 1a56dcfdafa521f78a3ef078a53707623a78a202 Mon Sep 17 00:00:00 2001 From: starkillerOG Date: Thu, 20 Feb 2025 10:46:24 +0100 Subject: [PATCH] Fix Reolink callback id collision (#138918) --- homeassistant/components/reolink/entity.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/reolink/entity.py b/homeassistant/components/reolink/entity.py index e3a84579865..55ce4ce891e 100644 --- a/homeassistant/components/reolink/entity.py +++ b/homeassistant/components/reolink/entity.py @@ -107,10 +107,10 @@ class ReolinkHostCoordinatorEntity(CoordinatorEntity[DataUpdateCoordinator[None] """Handle incoming TCP push event.""" self.async_write_ha_state() - def register_callback(self, unique_id: str, cmd_id: int) -> None: + def register_callback(self, callback_id: str, cmd_id: int) -> None: """Register callback for TCP push events.""" self._host.api.baichuan.register_callback( # pragma: no cover - unique_id, self._push_callback, cmd_id + callback_id, self._push_callback, cmd_id ) async def async_added_to_hass(self) -> None: @@ -118,23 +118,25 @@ class ReolinkHostCoordinatorEntity(CoordinatorEntity[DataUpdateCoordinator[None] await super().async_added_to_hass() cmd_key = self.entity_description.cmd_key cmd_id = self.entity_description.cmd_id + callback_id = f"{self.platform.domain}_{self._attr_unique_id}" if cmd_key is not None: self._host.async_register_update_cmd(cmd_key) if cmd_id is not None: - self.register_callback(self._attr_unique_id, cmd_id) + self.register_callback(callback_id, cmd_id) # Privacy mode - self.register_callback(f"{self._attr_unique_id}_623", 623) + self.register_callback(f"{callback_id}_623", 623) async def async_will_remove_from_hass(self) -> None: """Entity removed.""" cmd_key = self.entity_description.cmd_key cmd_id = self.entity_description.cmd_id + callback_id = f"{self.platform.domain}_{self._attr_unique_id}" if cmd_key is not None: self._host.async_unregister_update_cmd(cmd_key) if cmd_id is not None: - self._host.api.baichuan.unregister_callback(self._attr_unique_id) + self._host.api.baichuan.unregister_callback(callback_id) # Privacy mode - self._host.api.baichuan.unregister_callback(f"{self._attr_unique_id}_623") + self._host.api.baichuan.unregister_callback(f"{callback_id}_623") await super().async_will_remove_from_hass() @@ -193,10 +195,10 @@ class ReolinkChannelCoordinatorEntity(ReolinkHostCoordinatorEntity): """Return True if entity is available.""" return super().available and self._host.api.camera_online(self._channel) - def register_callback(self, unique_id: str, cmd_id: int) -> None: + def register_callback(self, callback_id: str, cmd_id: int) -> None: """Register callback for TCP push events.""" self._host.api.baichuan.register_callback( - unique_id, self._push_callback, cmd_id, self._channel + callback_id, self._push_callback, cmd_id, self._channel ) async def async_added_to_hass(self) -> None: