hass_flickerstrip/custom_components/flickerstrip/__init__.py

30 lines
839 B
Python
Raw Normal View History

2023-01-29 13:29:34 -05:00
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.core import HomeAssistant
2023-01-29 09:34:51 -05:00
2023-01-29 13:29:34 -05:00
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))
2023-01-29 09:34:51 -05:00
return True
2023-01-29 13:29:34 -05:00
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)