custom_components/whatsapp_bridge_integration/__init__.py aktualisiert
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers import device_registry as dr
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@@ -8,11 +9,22 @@ async def async_setup(hass: HomeAssistant, config: dict):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry):
|
async def async_setup_entry(hass: HomeAssistant, entry):
|
||||||
"""Set up entry and forward to sensor platform."""
|
"""Set up entry, create general device and forward to sensor platform."""
|
||||||
# Lege die Daten im hass-Objekt ab
|
# Lege die Daten im hass-Objekt ab
|
||||||
hass.data.setdefault(DOMAIN, {})
|
hass.data.setdefault(DOMAIN, {})
|
||||||
hass.data[DOMAIN][entry.entry_id] = entry.data
|
hass.data[DOMAIN][entry.entry_id] = entry.data
|
||||||
|
|
||||||
|
# 1. Hauptgerät (General Device) im Device Registry anlegen
|
||||||
|
device_registry = dr.async_get(hass)
|
||||||
|
device_registry.async_get_or_create(
|
||||||
|
config_entry_id=entry.entry_id,
|
||||||
|
identifiers={(DOMAIN, "general_gateway")},
|
||||||
|
name="WhatsApp Bridge Gateway",
|
||||||
|
manufacturer="Bahmcloud",
|
||||||
|
model="Bridge Server v0.2.0",
|
||||||
|
sw_version="0.2.0",
|
||||||
|
)
|
||||||
|
|
||||||
# Forward the setup to the sensor platform to create entities
|
# Forward the setup to the sensor platform to create entities
|
||||||
await hass.config_entries.async_forward_entry_setups(entry, ["sensor"])
|
await hass.config_entries.async_forward_entry_setups(entry, ["sensor"])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user