ha_gehome/custom_components/ge_kitchen/__init__.py

45 lines
1.4 KiB
Python
Raw Normal View History

2020-08-12 09:03:22 -06:00
"""The ge_kitchen integration."""
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
2020-08-12 09:03:22 -06:00
import voluptuous as vol
from homeassistant.config_entries import ConfigEntry
2020-08-12 09:03:22 -06:00
from homeassistant.core import HomeAssistant
2020-08-13 15:10:55 -06:00
from .const import (
DOMAIN
2020-08-12 09:03:22 -06:00
)
2020-08-13 15:10:55 -06:00
from .update_coordinator import GeKitchenUpdateCoordinator
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
async def async_setup(hass: HomeAssistant, config: dict):
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
2020-08-12 09:03:22 -06:00
"""Set up the ge_kitchen component."""
2020-08-13 15:10:55 -06:00
hass.data.setdefault(DOMAIN, {})
2020-08-12 09:03:22 -06:00
"""Set up ge_kitchen from a config entry."""
coordinator = GeKitchenUpdateCoordinator(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
if not await coordinator.async_setup():
return False
2020-08-12 09:03:22 -06:00
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, coordinator.shutdown)
2020-08-12 09:03:22 -06:00
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:
2020-08-12 09:03:22 -06:00
hass.data[DOMAIN].pop(entry.entry_id)
return ok
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)