mirror of
https://github.com/home-assistant/core.git
synced 2026-02-14 23:28:42 +00:00
Move DATA_MP_ENTITIES in Onkyo (#162674)
This commit is contained in:
@@ -18,7 +18,7 @@ from .const import (
|
||||
ListeningMode,
|
||||
)
|
||||
from .receiver import ReceiverManager, async_interview
|
||||
from .services import DATA_MP_ENTITIES, async_setup_services
|
||||
from .services import async_setup_services
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -47,7 +47,6 @@ async def async_setup(hass: HomeAssistant, _: ConfigType) -> bool:
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: OnkyoConfigEntry) -> bool:
|
||||
"""Set up the Onkyo config entry."""
|
||||
|
||||
host = entry.data[CONF_HOST]
|
||||
|
||||
try:
|
||||
@@ -80,8 +79,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: OnkyoConfigEntry) -> boo
|
||||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: OnkyoConfigEntry) -> bool:
|
||||
"""Unload Onkyo config entry."""
|
||||
del hass.data[DATA_MP_ENTITIES][entry.entry_id]
|
||||
|
||||
entry.runtime_data.manager.start_unloading()
|
||||
|
||||
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
|
||||
@@ -4,7 +4,7 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from aioonkyo import Code, Kind, Status, Zone, command, query, status
|
||||
|
||||
@@ -14,11 +14,11 @@ from homeassistant.components.media_player import (
|
||||
MediaPlayerState,
|
||||
MediaType,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import ServiceValidationError
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
from homeassistant.util.hass_dict import HassKey
|
||||
|
||||
from . import OnkyoConfigEntry
|
||||
from .const import (
|
||||
DOMAIN,
|
||||
LEGACY_HDMI_OUTPUT_MAPPING,
|
||||
@@ -31,12 +31,17 @@ from .const import (
|
||||
VolumeResolution,
|
||||
)
|
||||
from .receiver import ReceiverManager
|
||||
from .services import DATA_MP_ENTITIES
|
||||
from .util import get_meaning
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import OnkyoConfigEntry
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
DATA_MP_ENTITIES: HassKey[dict[str, dict[Zone, OnkyoMediaPlayer]]] = HassKey(DOMAIN)
|
||||
|
||||
|
||||
SUPPORTED_FEATURES_BASE = (
|
||||
MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
@@ -104,6 +109,12 @@ async def async_setup_entry(
|
||||
entities: dict[Zone, OnkyoMediaPlayer] = {}
|
||||
all_entities[entry.entry_id] = entities
|
||||
|
||||
@callback
|
||||
def del_mp_entities() -> None:
|
||||
del all_entities[entry.entry_id]
|
||||
|
||||
entry.async_on_unload(del_mp_entities)
|
||||
|
||||
volume_resolution: VolumeResolution = entry.options[OPTION_VOLUME_RESOLUTION]
|
||||
max_volume: float = entry.options[OPTION_MAX_VOLUME]
|
||||
sources = data.sources
|
||||
|
||||
@@ -2,23 +2,15 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from aioonkyo import Zone
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.media_player import DOMAIN as MEDIA_PLAYER_DOMAIN
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.util.hass_dict import HassKey
|
||||
|
||||
from .const import DOMAIN, LEGACY_REV_HDMI_OUTPUT_MAPPING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .media_player import OnkyoMediaPlayer
|
||||
|
||||
DATA_MP_ENTITIES: HassKey[dict[str, dict[Zone, OnkyoMediaPlayer]]] = HassKey(DOMAIN)
|
||||
from .const import LEGACY_REV_HDMI_OUTPUT_MAPPING
|
||||
from .media_player import DATA_MP_ENTITIES, OnkyoMediaPlayer
|
||||
|
||||
ATTR_HDMI_OUTPUT = "hdmi_output"
|
||||
ONKYO_SELECT_OUTPUT_SCHEMA = vol.Schema(
|
||||
|
||||
Reference in New Issue
Block a user