custom_components/whatsapp_bridge_integration/__init__.py aktualisiert

0.2.2
This commit is contained in:
2026-06-15 09:36:42 +00:00
parent 4f8a4304ba
commit 3b99c037ae

View File

@@ -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"])