mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Use runtime_data in frontier_silicon (#137633)
This commit is contained in:
parent
f06d209b2d
commit
60fd07f501
@ -11,14 +11,18 @@ from homeassistant.const import CONF_PIN, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
|
||||
from .const import CONF_WEBFSAPI_URL, DOMAIN
|
||||
from .const import CONF_WEBFSAPI_URL
|
||||
|
||||
PLATFORMS = [Platform.MEDIA_PLAYER]
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
type FrontierSiliconConfigEntry = ConfigEntry[AFSAPI]
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: FrontierSiliconConfigEntry
|
||||
) -> bool:
|
||||
"""Set up Frontier Silicon from a config entry."""
|
||||
|
||||
webfsapi_url = entry.data[CONF_WEBFSAPI_URL]
|
||||
@ -31,16 +35,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
except FSConnectionError as exception:
|
||||
raise ConfigEntryNotReady from exception
|
||||
|
||||
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = afsapi
|
||||
entry.runtime_data = afsapi
|
||||
|
||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
async def async_unload_entry(
|
||||
hass: HomeAssistant, entry: FrontierSiliconConfigEntry
|
||||
) -> bool:
|
||||
"""Unload a config entry."""
|
||||
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
|
||||
hass.data[DOMAIN].pop(entry.entry_id)
|
||||
|
||||
return unload_ok
|
||||
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
|
@ -20,11 +20,11 @@ from homeassistant.components.media_player import (
|
||||
MediaPlayerState,
|
||||
MediaType,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import FrontierSiliconConfigEntry
|
||||
from .browse_media import browse_node, browse_top_level
|
||||
from .const import DOMAIN, MEDIA_CONTENT_ID_PRESET
|
||||
|
||||
@ -33,12 +33,12 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
config_entry: FrontierSiliconConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the Frontier Silicon entity."""
|
||||
|
||||
afsapi: AFSAPI = hass.data[DOMAIN][config_entry.entry_id]
|
||||
afsapi = config_entry.runtime_data
|
||||
|
||||
async_add_entities(
|
||||
[
|
||||
|
Loading…
x
Reference in New Issue
Block a user