Home Assistant custom integration for NVIDIA Shield TV that composes the Android TV Remote, Jellyfin, smart plug, and receiver entities into a single unified media player with ADB-based now-playing from any app. Part of the Media Zone ecosystem. Entities: - media_player: power (with smart plug fallback), transport, input, volume routed to receiver, rich stream info overlay when Jellyfin is active - sensor: DAG attributes and stream info - button: Pair ADB Config: - Two-step flow: basic setup + optional ADB pairing on the Shield - Configurable ADB port (default 5555) - Pick an existing Jellyfin media_player entity — stream info is read from the HA Jellyfin integration's own DataUpdateCoordinator, so no server URL / API key / extra config needed here - Privacy mode (adb_store_app_info=False) suppresses non-Jellyfin media details, showing only the app name Ecosystem: - Exposes media_dag_* attributes for ha-media-zone orchestration - Exposes media_dag_running_apps and async_bring_to_foreground for the Media Zone card's app switcher Shared ADB code lives in ltomes/ha-adb-common and is vendored at custom_components/nvidia_shield/ha_adb_common/ for HACS installs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
"""ADB media session reader for NVIDIA Shield.
|
|
|
|
Thin wrapper around ha_adb_common.AdbClientBase — adds the Shield-specific
|
|
`poll()` method that calls wake check + media session in sequence.
|
|
|
|
Re-exports MediaSessionInfo and ensure_adb_key for existing importers.
|
|
"""
|
|
|
|
import logging
|
|
|
|
from .ha_adb_common import AdbClientBase, ensure_adb_key as _ensure_adb_key
|
|
from .ha_adb_common import MediaSessionInfo # noqa: F401 (re-export)
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
DOMAIN = "nvidia_shield"
|
|
|
|
|
|
def ensure_adb_key(hass_config_dir: str) -> str:
|
|
"""Ensure an ADB key pair exists for the nvidia_shield integration."""
|
|
return _ensure_adb_key(hass_config_dir, DOMAIN)
|
|
|
|
|
|
class AdbMediaSessionPoller(AdbClientBase):
|
|
"""ADB client for NVIDIA Shield — extends base with wake-state tracking."""
|
|
|
|
def __init__(self, host: str, port: int, key_path: str):
|
|
super().__init__(host, port, key_path)
|
|
|
|
async def poll(self, foreground_package: str | None = None) -> MediaSessionInfo | None:
|
|
"""Query the current media session. Returns parsed info or None.
|
|
|
|
Args:
|
|
foreground_package: The package name of the foreground app, used to
|
|
prefer its media session over stale sessions from other apps.
|
|
"""
|
|
return await self.poll_media_sessions(foreground_package)
|