mirror of
https://github.com/bahmcloud/HA-KNX-Bridge.git
synced 2026-04-07 03:21:13 +00:00
Initial HA KNX Bridge scaffold
This commit is contained in:
31
custom_components/ha_knx_bridge/__init__.py
Normal file
31
custom_components/ha_knx_bridge/__init__.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
|
||||
from .bridge import BridgeManager
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
manager = BridgeManager(hass, entry)
|
||||
try:
|
||||
await manager.async_setup()
|
||||
except ConfigEntryNotReady:
|
||||
await manager.async_unload()
|
||||
raise
|
||||
entry.runtime_data = manager
|
||||
entry.async_on_unload(entry.add_update_listener(_update_listener))
|
||||
return True
|
||||
|
||||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
manager: BridgeManager | None = getattr(entry, "runtime_data", None)
|
||||
if manager is None:
|
||||
return True
|
||||
await manager.async_unload()
|
||||
return True
|
||||
|
||||
|
||||
async def _update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||
await hass.config_entries.async_reload(entry.entry_id)
|
||||
Reference in New Issue
Block a user