Fix add-on discovery and bridge communication
This commit is contained in:
@@ -2,6 +2,7 @@ import logging
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from .const import DOMAIN
|
||||
from .api import WhatsAppBridgeApi
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -12,6 +13,7 @@ async def async_setup_entry(hass: HomeAssistant, entry):
|
||||
"""Set up entry, create devices, and clean up old orphaned devices."""
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
hass.data[DOMAIN][entry.entry_id] = entry.data
|
||||
hass.data[DOMAIN].setdefault("api", WhatsAppBridgeApi(hass))
|
||||
|
||||
device_registry = dr.async_get(hass)
|
||||
|
||||
@@ -40,7 +42,7 @@ async def async_setup_entry(hass: HomeAssistant, entry):
|
||||
name=f"WhatsApp {entry.title}",
|
||||
manufacturer="Bahmcloud",
|
||||
model="Kontakt-Endpunkt",
|
||||
sw_version="0.2.4",
|
||||
sw_version="0.3.0",
|
||||
)
|
||||
|
||||
# 3. Zentralen System-Hub anlegen mit erzwungener config_entry_id Bindung (HA Core Anforderung)
|
||||
@@ -51,7 +53,7 @@ async def async_setup_entry(hass: HomeAssistant, entry):
|
||||
name="WhatsApp Bridge Hub",
|
||||
manufacturer="Bahmcloud",
|
||||
model="Bridge Server",
|
||||
sw_version="0.2.4",
|
||||
sw_version="0.3.0",
|
||||
)
|
||||
|
||||
# Forward the setup to the sensor platform to create entities
|
||||
@@ -69,4 +71,7 @@ async def async_unload_entry(hass: HomeAssistant, entry):
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, ["sensor"])
|
||||
if unload_ok:
|
||||
hass.data[DOMAIN].pop(entry.entry_id)
|
||||
return unload_ok
|
||||
if hass.data[DOMAIN].get("global_entities_entry_id") == entry.entry_id:
|
||||
hass.data[DOMAIN].pop("global_entities_entry_id", None)
|
||||
hass.data[DOMAIN].pop("global_entities_registered", None)
|
||||
return unload_ok
|
||||
|
||||
Reference in New Issue
Block a user