mirror of https://github.com/simbaja/ha_gehome.git
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
"""The ge_kitchen integration."""
|
|
|
|
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
|
import voluptuous as vol
|
|
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.core import HomeAssistant
|
|
from .const import (
|
|
DOMAIN
|
|
)
|
|
from .update_coordinator import GeKitchenUpdateCoordinator
|
|
|
|
CONFIG_SCHEMA = vol.Schema({DOMAIN: vol.Schema({})}, extra=vol.ALLOW_EXTRA)
|
|
|
|
async def async_setup(hass: HomeAssistant, config: dict):
|
|
return True
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|
"""Set up the ge_kitchen component."""
|
|
hass.data.setdefault(DOMAIN, {})
|
|
|
|
"""Set up ge_kitchen from a config entry."""
|
|
coordinator = GeKitchenUpdateCoordinator(hass, entry)
|
|
hass.data[DOMAIN][entry.entry_id] = coordinator
|
|
|
|
if not await coordinator.async_setup():
|
|
return False
|
|
|
|
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, coordinator.shutdown)
|
|
|
|
return True
|
|
|
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|
"""Unload a config entry."""
|
|
coordinator: GeKitchenUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
|
ok = await coordinator.async_reset()
|
|
if ok:
|
|
hass.data[DOMAIN].pop(entry.entry_id)
|
|
|
|
return ok
|
|
|
|
async def async_update_options(hass, config_entry):
|
|
"""Update options."""
|
|
await hass.config_entries.async_reload(config_entry.entry_id)
|