"""The NFAndroidTV integration.""" from notifications_android_tv.notifications import ConnectError, Notifications from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_HOST, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv from homeassistant.helpers.typing import ConfigType from .const import DATA_HASS_CONFIG, DOMAIN PLATFORMS = [Platform.NOTIFY] CONFIG_SCHEMA = cv.removed(DOMAIN, raise_if_present=False) async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the NFAndroidTV component.""" hass.data[DATA_HASS_CONFIG] = config return True async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up NFAndroidTV from a config entry.""" try: await hass.async_add_executor_job(Notifications, entry.data[CONF_HOST]) except ConnectError as ex: raise ConfigEntryNotReady( f"Failed to connect to host: {entry.data[CONF_HOST]}" ) from ex hass.data.setdefault(DOMAIN, {}) hass.async_create_task( discovery.async_load_platform( hass, Platform.NOTIFY, DOMAIN, dict(entry.data), hass.data[DATA_HASS_CONFIG], ) ) return True async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)