Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Sillyfrog <sillyfrog@users.noreply.github.com>
36 lines
1,006 B
Python
36 lines
1,006 B
Python
"""The Automate Pulse Hub v2 integration."""
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from .const import DOMAIN
|
|
from .hub import PulseHub
|
|
|
|
PLATFORMS = ["cover"]
|
|
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
"""Set up Automate Pulse Hub v2 from a config entry."""
|
|
hub = PulseHub(hass, entry)
|
|
|
|
if not await hub.async_setup():
|
|
return False
|
|
|
|
hass.data.setdefault(DOMAIN, {})
|
|
hass.data[DOMAIN][entry.entry_id] = hub
|
|
|
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
|
|
|
return True
|
|
|
|
|
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
"""Unload a config entry."""
|
|
hub = hass.data[DOMAIN][entry.entry_id]
|
|
|
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
|
if unload_ok:
|
|
if not await hub.async_reset():
|
|
return False
|
|
hass.data[DOMAIN].pop(entry.entry_id)
|
|
|
|
return unload_ok
|