1
0
mirror of https://github.com/home-assistant/core.git synced 2026-07-14 10:03:52 +01:00
Files
2026-07-07 16:41:27 +02:00

29 lines
972 B
Python

"""NeoPool integration for Home Assistant."""
from neopool_modbus import NeoPoolModbusClient
from homeassistant.core import HomeAssistant
from .const import PLATFORMS
from .coordinator import NeoPoolConfigEntry, NeoPoolCoordinator
async def async_setup_entry(hass: HomeAssistant, entry: NeoPoolConfigEntry) -> bool:
"""Set up the NeoPool integration from a config entry."""
client = NeoPoolModbusClient(entry.data)
coordinator = NeoPoolCoordinator(hass, client, entry)
await coordinator.async_config_entry_first_refresh()
entry.runtime_data = coordinator
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True
async def async_unload_entry(hass: HomeAssistant, entry: NeoPoolConfigEntry) -> bool:
"""Unload a NeoPool config entry."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok:
await entry.runtime_data.client.close()
return unload_ok