diff --git a/homeassistant/components/enigma2/__init__.py b/homeassistant/components/enigma2/__init__.py index 241ca7444fb..4e4f8bdb687 100644 --- a/homeassistant/components/enigma2/__init__.py +++ b/homeassistant/components/enigma2/__init__.py @@ -16,12 +16,12 @@ from homeassistant.const import ( from homeassistant.core import HomeAssistant from homeassistant.helpers.aiohttp_client import async_create_clientsession -from .const import DOMAIN +type Enigma2ConfigEntry = ConfigEntry[OpenWebIfDevice] PLATFORMS = [Platform.MEDIA_PLAYER] -async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: +async def async_setup_entry(hass: HomeAssistant, entry: Enigma2ConfigEntry) -> bool: """Set up Enigma2 from a config entry.""" base_url = URL.build( scheme="http" if not entry.data[CONF_SSL] else "https", @@ -35,14 +35,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: hass, verify_ssl=entry.data[CONF_VERIFY_SSL], base_url=base_url ) - hass.data.setdefault(DOMAIN, {})[entry.entry_id] = OpenWebIfDevice(session) + entry.runtime_data = OpenWebIfDevice(session) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) return True async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> 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) diff --git a/homeassistant/components/enigma2/media_player.py b/homeassistant/components/enigma2/media_player.py index 037d82cd6c0..adda8f9e1c8 100644 --- a/homeassistant/components/enigma2/media_player.py +++ b/homeassistant/components/enigma2/media_player.py @@ -32,6 +32,7 @@ from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType +from . import Enigma2ConfigEntry from .const import ( CONF_DEEP_STANDBY, CONF_MAC_ADDRESS, @@ -102,12 +103,12 @@ async def async_setup_platform( async def async_setup_entry( hass: HomeAssistant, - entry: ConfigEntry, + entry: Enigma2ConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: """Set up the Enigma2 media player platform.""" - device: OpenWebIfDevice = hass.data[DOMAIN][entry.entry_id] + device = entry.runtime_data about = await device.get_about() device.mac_address = about["info"]["ifaces"][0]["mac"] entity = Enigma2Device(entry, device, about)