31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
import logging
|
|
from homeassistant.core import HomeAssistant
|
|
from .const import DOMAIN
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
async def async_setup(hass: HomeAssistant, config: dict):
|
|
return True
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry):
|
|
"""Set up entry and forward to sensor platform."""
|
|
# Lege die Daten im hass-Objekt ab
|
|
hass.data.setdefault(DOMAIN, {})
|
|
hass.data[DOMAIN][entry.entry_id] = entry.data
|
|
|
|
# Forward the setup to the sensor platform to create entities
|
|
await hass.config_entries.async_forward_entry_setups(entry, ["sensor"])
|
|
|
|
# Registriere den Service (nur beim ersten Mal)
|
|
if not hass.services.has_service(DOMAIN, "send_message"):
|
|
from .services import async_setup_services
|
|
await async_setup_services(hass)
|
|
|
|
return True
|
|
|
|
async def async_unload_entry(hass: HomeAssistant, entry):
|
|
"""Unload a config 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 |