mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Explicitly pass in the config_entry in jellyfin coordinator (#138129)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
fd57803b15
commit
6d2f8b1076
@ -2,16 +2,13 @@
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
|
||||
from .client_wrapper import CannotConnect, InvalidAuth, create_client, validate_input
|
||||
from .const import CONF_CLIENT_DEVICE_ID, DOMAIN, PLATFORMS
|
||||
from .coordinator import JellyfinDataUpdateCoordinator
|
||||
|
||||
type JellyfinConfigEntry = ConfigEntry[JellyfinDataUpdateCoordinator]
|
||||
from .coordinator import JellyfinConfigEntry, JellyfinDataUpdateCoordinator
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: JellyfinConfigEntry) -> bool:
|
||||
@ -35,7 +32,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: JellyfinConfigEntry) ->
|
||||
|
||||
server_info: dict[str, Any] = connect_result["Servers"][0]
|
||||
|
||||
coordinator = JellyfinDataUpdateCoordinator(hass, client, server_info, user_id)
|
||||
coordinator = JellyfinDataUpdateCoordinator(
|
||||
hass, entry, client, server_info, user_id
|
||||
)
|
||||
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
||||
|
@ -13,9 +13,9 @@ from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.util.uuid import random_uuid_hex
|
||||
|
||||
from . import JellyfinConfigEntry
|
||||
from .client_wrapper import CannotConnect, InvalidAuth, create_client, validate_input
|
||||
from .const import CONF_CLIENT_DEVICE_ID, DOMAIN, SUPPORTED_AUDIO_CODECS
|
||||
from .coordinator import JellyfinConfigEntry
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -13,15 +13,18 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
||||
from .const import CONF_CLIENT_DEVICE_ID, DOMAIN, LOGGER, USER_APP_NAME
|
||||
|
||||
type JellyfinConfigEntry = ConfigEntry[JellyfinDataUpdateCoordinator]
|
||||
|
||||
|
||||
class JellyfinDataUpdateCoordinator(DataUpdateCoordinator[dict[str, dict[str, Any]]]):
|
||||
"""Data update coordinator for the Jellyfin integration."""
|
||||
|
||||
config_entry: ConfigEntry
|
||||
config_entry: JellyfinConfigEntry
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
config_entry: JellyfinConfigEntry,
|
||||
api_client: JellyfinClient,
|
||||
system_info: dict[str, Any],
|
||||
user_id: str,
|
||||
@ -30,6 +33,7 @@ class JellyfinDataUpdateCoordinator(DataUpdateCoordinator[dict[str, dict[str, An
|
||||
super().__init__(
|
||||
hass=hass,
|
||||
logger=LOGGER,
|
||||
config_entry=config_entry,
|
||||
name=DOMAIN,
|
||||
update_interval=timedelta(seconds=10),
|
||||
)
|
||||
@ -37,7 +41,7 @@ class JellyfinDataUpdateCoordinator(DataUpdateCoordinator[dict[str, dict[str, An
|
||||
self.server_id: str = system_info["Id"]
|
||||
self.server_name: str = system_info["Name"]
|
||||
self.server_version: str | None = system_info.get("Version")
|
||||
self.client_device_id: str = self.config_entry.data[CONF_CLIENT_DEVICE_ID]
|
||||
self.client_device_id: str = config_entry.data[CONF_CLIENT_DEVICE_ID]
|
||||
self.user_id: str = user_id
|
||||
|
||||
self.session_ids: set[str] = set()
|
||||
|
@ -8,7 +8,7 @@ from homeassistant.components.diagnostics import async_redact_data
|
||||
from homeassistant.const import CONF_PASSWORD
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import JellyfinConfigEntry
|
||||
from .coordinator import JellyfinConfigEntry
|
||||
|
||||
TO_REDACT = {CONF_PASSWORD}
|
||||
|
||||
|
@ -15,11 +15,10 @@ from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.util.dt import parse_datetime
|
||||
|
||||
from . import JellyfinConfigEntry
|
||||
from .browse_media import build_item_response, build_root_response
|
||||
from .client_wrapper import get_artwork_url
|
||||
from .const import CONTENT_TYPE_MAP, LOGGER
|
||||
from .coordinator import JellyfinDataUpdateCoordinator
|
||||
from .coordinator import JellyfinConfigEntry, JellyfinDataUpdateCoordinator
|
||||
from .entity import JellyfinClientEntity
|
||||
|
||||
|
||||
|
@ -19,7 +19,6 @@ from homeassistant.components.media_source import (
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import JellyfinConfigEntry
|
||||
from .const import (
|
||||
COLLECTION_TYPE_MOVIES,
|
||||
COLLECTION_TYPE_MUSIC,
|
||||
@ -48,6 +47,7 @@ from .const import (
|
||||
PLAYABLE_ITEM_TYPES,
|
||||
SUPPORTED_COLLECTION_TYPES,
|
||||
)
|
||||
from .coordinator import JellyfinConfigEntry
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -16,9 +16,8 @@ from homeassistant.components.remote import (
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import JellyfinConfigEntry
|
||||
from .const import LOGGER
|
||||
from .coordinator import JellyfinDataUpdateCoordinator
|
||||
from .coordinator import JellyfinConfigEntry, JellyfinDataUpdateCoordinator
|
||||
from .entity import JellyfinClientEntity
|
||||
|
||||
|
||||
|
@ -11,7 +11,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
|
||||
from . import JellyfinConfigEntry, JellyfinDataUpdateCoordinator
|
||||
from .coordinator import JellyfinConfigEntry, JellyfinDataUpdateCoordinator
|
||||
from .entity import JellyfinServerEntity
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user