From d420a8ad0676cf7f670259894f696d148c9ee66b Mon Sep 17 00:00:00 2001 From: Tomaae <23486452+tomaae@users.noreply.github.com> Date: Wed, 17 Aug 2022 09:29:46 +0200 Subject: [PATCH] Fixed duplication of tracker entities for restored entities #236 --- .../mikrotik_router/mikrotik_controller.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/custom_components/mikrotik_router/mikrotik_controller.py b/custom_components/mikrotik_router/mikrotik_controller.py index fd09392..f9a61f3 100644 --- a/custom_components/mikrotik_router/mikrotik_controller.py +++ b/custom_components/mikrotik_router/mikrotik_controller.py @@ -469,7 +469,17 @@ async def async_get_host_hass(self): entity.config_entry_id == self.config_entry.entry_id and entity.entity_id.startswith("device_tracker.") ): - self.data["host_hass"][entity.unique_id.upper()] = entity.original_name + tmp = entity.unique_id.split("-") + if tmp[0] != self.name.lower(): + continue + + if tmp[1] != "host": + continue + + if ":" not in tmp[2]: + continue + + self.data["host_hass"][tmp[2].upper()] = entity.original_name # --------------------------- # async_hwinfo_update