1 """The Frontier Silicon integration."""
3 from __future__
import annotations
7 from afsapi
import AFSAPI, ConnectionError
as FSConnectionError
14 from .const
import CONF_WEBFSAPI_URL, DOMAIN
16 PLATFORMS = [Platform.MEDIA_PLAYER]
18 _LOGGER = logging.getLogger(__name__)
22 """Set up Frontier Silicon from a config entry."""
24 webfsapi_url = entry.data[CONF_WEBFSAPI_URL]
25 pin = entry.data[CONF_PIN]
27 afsapi = AFSAPI(webfsapi_url, pin)
30 await afsapi.get_power()
31 except FSConnectionError
as exception:
32 raise ConfigEntryNotReady
from exception
34 hass.data.setdefault(DOMAIN, {})[entry.entry_id] = afsapi
36 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
42 """Unload a config entry."""
43 if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
44 hass.data[DOMAIN].pop(entry.entry_id)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)