30 lines
839 B
Python
30 lines
839 B
Python
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.const import CONF_HOST, CONF_PORT
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from .common import Flickerstrip
|
|
from .const import (
|
|
DOMAIN,
|
|
)
|
|
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
"""Setup flickerstrip from config entry."""
|
|
|
|
hass.data.setdefault(DOMAIN, {})
|
|
hass.data[DOMAIN][entry.entry_id] = Flickerstrip(
|
|
hass=hass,
|
|
host=entry.data[CONF_HOST],
|
|
port=entry.data[CONF_PORT],
|
|
)
|
|
|
|
entry.async_on_unload(entry.add_update_listener(update_listener))
|
|
|
|
return True
|
|
|
|
|
|
async def update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
|
"""Update when config_entry options update."""
|
|
if entry.options:
|
|
await hass.config_entries.async_reload(entry.entry_id)
|