From 7f40dacc6c07dc526879b07af1af788793c847d3 Mon Sep 17 00:00:00 2001 From: Koen Hendriks Date: Wed, 24 Jan 2024 14:25:25 +0100 Subject: [PATCH] Add hub_id as prefix for entity identifier. --- custom_components/button_plus/button.py | 4 ++-- custom_components/button_plus/buttonplushub.py | 2 +- custom_components/button_plus/light.py | 4 ++-- custom_components/button_plus/switch.py | 4 ++-- custom_components/button_plus/text.py | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/custom_components/button_plus/button.py b/custom_components/button_plus/button.py index 828806e..315708a 100644 --- a/custom_components/button_plus/button.py +++ b/custom_components/button_plus/button.py @@ -77,12 +77,12 @@ def device_info(self): device_info["name"] = f"BAR Module {self._connector.connector_id}" device_info["connections"] = {("bar_module", self._connector.connector_id)} device_info["model"] = "BAR Module" - device_info["identifiers"] = {(DOMAIN, f'{self._btn_id}_bar_module_{self._connector.connector_id}')} + device_info["identifiers"] = {(DOMAIN, f'{self._hub.hub_id}_{self._btn_id}_bar_module_{self._connector.connector_id}')} case 2: device_info["name"] = f"Display Module" device_info["connections"] = {("display_module", 1)} device_info["model"] = "Display Module" - device_info["identifiers"] = {(DOMAIN, f'{self._btn_id}_display_module')} + device_info["identifiers"] = {(DOMAIN, f'{self._hub.hub_id}_{self._btn_id}_display_module')} return device_info diff --git a/custom_components/button_plus/buttonplushub.py b/custom_components/button_plus/buttonplushub.py index 4ef751f..63f738e 100644 --- a/custom_components/button_plus/buttonplushub.py +++ b/custom_components/button_plus/buttonplushub.py @@ -22,7 +22,7 @@ def __init__(self, hass: HomeAssistant, config: DeviceConfiguration, entry: Conf _LOGGER.debug(f"New hub with config {config.core}") self._hass = hass self.config = config - self._name = config.core.name + self._name = config.info.device_id self._id = self.config.info.device_id self._client = LocalApiClient(config.info.ip_address, aiohttp_client.async_get_clientsession(hass)) self.online = True diff --git a/custom_components/button_plus/light.py b/custom_components/button_plus/light.py index 850975b..1939c28 100644 --- a/custom_components/button_plus/light.py +++ b/custom_components/button_plus/light.py @@ -82,12 +82,12 @@ def device_info(self): device_info["name"] = f"BAR Module {self._connector.connector_id}" device_info["connections"] = {("bar_module", self._connector.connector_id)} device_info["model"] = "BAR Module" - device_info["identifiers"] = {(DOMAIN, f'{self._btn_id}_bar_module_{self._connector.connector_id}')} + device_info["identifiers"] = {(DOMAIN, f'{self._hub.hub_id}_{self._btn_id}_bar_module_{self._connector.connector_id}')} case 2: device_info["name"] = f"Display Module" device_info["connections"] = {("display_module", 1)} device_info["model"] = "Display Module" - device_info["identifiers"] = {(DOMAIN, f'{self._btn_id}_display_module')} + device_info["identifiers"] = {(DOMAIN, f'{self._hub.hub_id}_{self._btn_id}_display_module')} return device_info diff --git a/custom_components/button_plus/switch.py b/custom_components/button_plus/switch.py index eef75b3..2475267 100644 --- a/custom_components/button_plus/switch.py +++ b/custom_components/button_plus/switch.py @@ -71,12 +71,12 @@ def device_info(self): device_info["name"] = f"BAR Module {self._connector.connector_id}" device_info["connections"] = {("bar_module", self._connector.connector_id)} device_info["model"] = "BAR Module" - device_info["identifiers"] = {(DOMAIN, f'{self._btn_id}_bar_module_{self._connector.connector_id}')} + device_info["identifiers"] = {(DOMAIN, f'{self._hub.hub_id}_{self._btn_id}_bar_module_{self._connector.connector_id}')} case 2: device_info["name"] = f"Display Module" device_info["connections"] = {("display_module", 1)} device_info["model"] = "Display Module" - device_info["identifiers"] = {(DOMAIN, f'{self._btn_id}_display_module')} + device_info["identifiers"] = {(DOMAIN, f'{self._hub.hub_id}_{self._btn_id}_display_module')} return device_info diff --git a/custom_components/button_plus/text.py b/custom_components/button_plus/text.py index bff67d1..c8afb20 100644 --- a/custom_components/button_plus/text.py +++ b/custom_components/button_plus/text.py @@ -87,12 +87,12 @@ def device_info(self): device_info["name"] = f"BAR Module {self._connector.connector_id}" device_info["connections"] = {("bar_module", self._connector.connector_id)} device_info["model"] = "BAR Module" - device_info["identifiers"] = {(DOMAIN, f'{self._btn_id}_bar_module_{self._connector.connector_id}')} + device_info["identifiers"] = {(DOMAIN, f'{self._hub.hub_id}_{self._btn_id}_bar_module_{self._connector.connector_id}')} case 2: device_info["name"] = f"Display Module" device_info["connections"] = {("display_module", 1)} device_info["model"] = "Display Module" - device_info["identifiers"] = {(DOMAIN, f'{self._btn_id}_display_module')} + device_info["identifiers"] = {(DOMAIN, f'{self._hub.hub_id}_{self._btn_id}_display_module')} return device_info