2021-05-20 09:15:49 -06:00
|
|
|
"""The ge_home integration."""
|
2020-08-12 09:03:22 -06:00
|
|
|
|
2020-12-30 14:31:58 -07:00
|
|
|
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
2020-08-12 09:03:22 -06:00
|
|
|
import voluptuous as vol
|
|
|
|
|
2020-12-28 15:46:15 -07:00
|
|
|
from homeassistant.config_entries import ConfigEntry
|
2020-08-12 09:03:22 -06:00
|
|
|
from homeassistant.core import HomeAssistant
|
2021-06-29 13:54:30 -06:00
|
|
|
from .const import DOMAIN
|
2021-05-20 09:15:49 -06:00
|
|
|
from .update_coordinator import GeHomeUpdateCoordinator
|
2020-08-12 09:03:22 -06:00
|
|
|
|
2020-08-13 15:10:55 -06:00
|
|
|
CONFIG_SCHEMA = vol.Schema({DOMAIN: vol.Schema({})}, extra=vol.ALLOW_EXTRA)
|
2020-08-12 09:03:22 -06:00
|
|
|
|
2021-06-29 13:54:30 -06:00
|
|
|
|
2020-08-12 09:03:22 -06:00
|
|
|
async def async_setup(hass: HomeAssistant, config: dict):
|
2020-12-30 14:31:58 -07:00
|
|
|
return True
|
2021-06-29 13:54:30 -06:00
|
|
|
|
|
|
|
|
2020-12-30 14:31:58 -07:00
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
2021-05-20 09:15:49 -06:00
|
|
|
"""Set up the ge_home component."""
|
2020-08-13 15:10:55 -06:00
|
|
|
hass.data.setdefault(DOMAIN, {})
|
2020-08-12 09:03:22 -06:00
|
|
|
|
2021-05-20 09:15:49 -06:00
|
|
|
"""Set up ge_home from a config entry."""
|
|
|
|
coordinator = GeHomeUpdateCoordinator(hass, entry)
|
2020-08-13 15:10:55 -06:00
|
|
|
hass.data[DOMAIN][entry.entry_id] = coordinator
|
2020-08-12 09:03:22 -06:00
|
|
|
|
2020-12-30 14:31:58 -07:00
|
|
|
if not await coordinator.async_setup():
|
|
|
|
return False
|
2020-08-12 09:03:22 -06:00
|
|
|
|
2020-12-30 14:31:58 -07:00
|
|
|
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, coordinator.shutdown)
|
2020-08-12 09:03:22 -06:00
|
|
|
|
|
|
|
return True
|
|
|
|
|
2021-06-29 13:54:30 -06:00
|
|
|
|
2020-08-12 09:03:22 -06:00
|
|
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|
|
|
"""Unload a config entry."""
|
2021-06-29 13:54:30 -06:00
|
|
|
coordinator: GeHomeUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
2020-12-30 14:31:58 -07:00
|
|
|
ok = await coordinator.async_reset()
|
|
|
|
if ok:
|
2020-08-12 09:03:22 -06:00
|
|
|
hass.data[DOMAIN].pop(entry.entry_id)
|
2021-06-29 13:54:30 -06:00
|
|
|
|
2020-12-30 14:31:58 -07:00
|
|
|
return ok
|
2020-08-25 11:09:28 -06:00
|
|
|
|
2021-06-29 13:54:30 -06:00
|
|
|
|
2020-08-25 11:09:28 -06:00
|
|
|
async def async_update_options(hass, config_entry):
|
|
|
|
"""Update options."""
|
|
|
|
await hass.config_entries.async_reload(config_entry.entry_id)
|