diff --git a/homeassistant/components/media_source/__init__.py b/homeassistant/components/media_source/__init__.py index 2f996523fdc..928e46ab528 100644 --- a/homeassistant/components/media_source/__init__.py +++ b/homeassistant/components/media_source/__init__.py @@ -3,7 +3,7 @@ from __future__ import annotations from collections.abc import Callable -from typing import Any +from typing import Any, Protocol import voluptuous as vol @@ -58,6 +58,13 @@ __all__ = [ CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN) +class MediaSourceProtocol(Protocol): + """Define the format of media_source platforms.""" + + async def async_get_media_source(self, hass: HomeAssistant) -> MediaSource: + """Set up media source.""" + + def is_media_source_id(media_content_id: str) -> bool: """Test if identifier is a media source.""" return URI_SCHEME_REGEX.match(media_content_id) is not None @@ -87,7 +94,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def _process_media_source_platform( - hass: HomeAssistant, domain: str, platform: Any + hass: HomeAssistant, + domain: str, + platform: MediaSourceProtocol, ) -> None: """Process a media source platform.""" hass.data[DOMAIN][domain] = await platform.async_get_media_source(hass)