From 3b99c037aee34e22bd4a50f7ec23ecd7447b6865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Bachmann?= Date: Mon, 15 Jun 2026 09:36:42 +0000 Subject: [PATCH] custom_components/whatsapp_bridge_integration/__init__.py aktualisiert 0.2.2 --- .../whatsapp_bridge_integration/__init__.py | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/custom_components/whatsapp_bridge_integration/__init__.py b/custom_components/whatsapp_bridge_integration/__init__.py index 74a58cf..be6d67b 100644 --- a/custom_components/whatsapp_bridge_integration/__init__.py +++ b/custom_components/whatsapp_bridge_integration/__init__.py @@ -9,22 +9,34 @@ async def async_setup(hass: HomeAssistant, config: dict): return True async def async_setup_entry(hass: HomeAssistant, entry): - """Set up entry, create specific contact device and forward to sensor platform.""" - # Lege die Daten im hass-Objekt ab + """Set up entry, create specific contact device, central hub and forward to platforms.""" hass.data.setdefault(DOMAIN, {}) hass.data[DOMAIN][entry.entry_id] = entry.data - # 1. Eigenes Gerät SPEZIFISCH für diesen Account/Kontakt anlegen device_registry = dr.async_get(hass) + + # 1. Eigenes Gerät SPEZIFISCH für diesen Account/Kontakt anlegen device_registry.async_get_or_create( config_entry_id=entry.entry_id, identifiers={(DOMAIN, entry.entry_id)}, # Einzigartig pro Eintrag name=f"WhatsApp {entry.title}", manufacturer="Bahmcloud", model="Kontakt-Endpunkt", - sw_version="0.2.1", + sw_version="0.2.2", ) + # 2. Zentralen System-Hub NUR EINMALIG anlegen (wird an den ersten geladenen Account gekoppelt) + if not hass.data[DOMAIN].get("hub_device_created"): + device_registry.async_get_or_create( + config_entry_id=entry.entry_id, + identifiers={(DOMAIN, "global_bridge_hub")}, + name="WhatsApp Bridge Hub", + manufacturer="Bahmcloud", + model="Bridge Server", + sw_version="0.2.2", + ) + hass.data[DOMAIN]["hub_device_created"] = True + # Forward the setup to the sensor platform to create entities await hass.config_entries.async_forward_entry_setups(entry, ["sensor"])