import datetime
from . import SonosData as SonosData
from .const import DATA_SONOS as DATA_SONOS, MEDIA_TYPES_TO_SONOS as MEDIA_TYPES_TO_SONOS, PLAYABLE_MEDIA_TYPES as PLAYABLE_MEDIA_TYPES, SONOS_CONTENT_UPDATE as SONOS_CONTENT_UPDATE, SONOS_CREATE_MEDIA_PLAYER as SONOS_CREATE_MEDIA_PLAYER, SONOS_ENTITY_CREATED as SONOS_ENTITY_CREATED, SONOS_GROUP_UPDATE as SONOS_GROUP_UPDATE, SONOS_MEDIA_UPDATE as SONOS_MEDIA_UPDATE, SONOS_PLAYER_RECONNECTED as SONOS_PLAYER_RECONNECTED, SONOS_VOLUME_UPDATE as SONOS_VOLUME_UPDATE
from .entity import SonosEntity as SonosEntity
from .media_browser import build_item_response as build_item_response, get_media as get_media, library_payload as library_payload
from .speaker import SonosSpeaker as SonosSpeaker
from collections.abc import Coroutine
from homeassistant.components.media_player import MediaPlayerEntity as MediaPlayerEntity
from homeassistant.components.media_player.const import ATTR_MEDIA_ENQUEUE as ATTR_MEDIA_ENQUEUE, MEDIA_TYPE_ALBUM as MEDIA_TYPE_ALBUM, MEDIA_TYPE_ARTIST as MEDIA_TYPE_ARTIST, MEDIA_TYPE_MUSIC as MEDIA_TYPE_MUSIC, MEDIA_TYPE_PLAYLIST as MEDIA_TYPE_PLAYLIST, MEDIA_TYPE_TRACK as MEDIA_TYPE_TRACK, REPEAT_MODE_ALL as REPEAT_MODE_ALL, REPEAT_MODE_OFF as REPEAT_MODE_OFF, REPEAT_MODE_ONE as REPEAT_MODE_ONE, SUPPORT_BROWSE_MEDIA as SUPPORT_BROWSE_MEDIA, SUPPORT_CLEAR_PLAYLIST as SUPPORT_CLEAR_PLAYLIST, SUPPORT_NEXT_TRACK as SUPPORT_NEXT_TRACK, SUPPORT_PAUSE as SUPPORT_PAUSE, SUPPORT_PLAY as SUPPORT_PLAY, SUPPORT_PLAY_MEDIA as SUPPORT_PLAY_MEDIA, SUPPORT_PREVIOUS_TRACK as SUPPORT_PREVIOUS_TRACK, SUPPORT_REPEAT_SET as SUPPORT_REPEAT_SET, SUPPORT_SEEK as SUPPORT_SEEK, SUPPORT_SELECT_SOURCE as SUPPORT_SELECT_SOURCE, SUPPORT_SHUFFLE_SET as SUPPORT_SHUFFLE_SET, SUPPORT_STOP as SUPPORT_STOP, SUPPORT_VOLUME_MUTE as SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET as SUPPORT_VOLUME_SET
from homeassistant.components.media_player.errors import BrowseError as BrowseError
from homeassistant.components.plex.const import PLEX_URI_SCHEME as PLEX_URI_SCHEME
from homeassistant.components.plex.services import play_on_sonos as play_on_sonos
from homeassistant.config_entries import ConfigEntry as ConfigEntry
from homeassistant.const import ATTR_TIME as ATTR_TIME, STATE_IDLE as STATE_IDLE, STATE_PAUSED as STATE_PAUSED, STATE_PLAYING as STATE_PLAYING
from homeassistant.core import HomeAssistant as HomeAssistant, ServiceCall as ServiceCall, callback as callback
from homeassistant.helpers import entity_platform as entity_platform, service as service
from homeassistant.helpers.dispatcher import async_dispatcher_connect as async_dispatcher_connect, async_dispatcher_send as async_dispatcher_send
from homeassistant.helpers.network import is_internal_request as is_internal_request
from homeassistant.util.dt import utcnow as utcnow
from pysonos.core import SoCo as SoCo
from pysonos.data_structures import DidlFavorite as DidlFavorite
from pysonos.events_base import Event as SonosEvent
from typing import Any, Callable

_LOGGER: Any
SUPPORT_SONOS: Any
SOURCE_LINEIN: str
SOURCE_TV: str
REPEAT_TO_SONOS: Any
SONOS_TO_REPEAT: Any
ATTR_SONOS_GROUP: str
UPNP_ERRORS_TO_IGNORE: Any
SERVICE_JOIN: str
SERVICE_UNJOIN: str
SERVICE_SNAPSHOT: str
SERVICE_RESTORE: str
SERVICE_SET_TIMER: str
SERVICE_CLEAR_TIMER: str
SERVICE_UPDATE_ALARM: str
SERVICE_SET_OPTION: str
SERVICE_PLAY_QUEUE: str
SERVICE_REMOVE_FROM_QUEUE: str
ATTR_SLEEP_TIME: str
ATTR_ALARM_ID: str
ATTR_VOLUME: str
ATTR_ENABLED: str
ATTR_INCLUDE_LINKED_ZONES: str
ATTR_MASTER: str
ATTR_WITH_GROUP: str
ATTR_NIGHT_SOUND: str
ATTR_SPEECH_ENHANCE: str
ATTR_QUEUE_POSITION: str
ATTR_STATUS_LIGHT: str
UNAVAILABLE_VALUES: Any

async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable) -> None: ...
def _get_entity_from_soco_uid(hass: HomeAssistant, uid: str) -> Union[SonosMediaPlayerEntity, None]: ...
def soco_error(errorcodes: Union[list[str], None]=...) -> Callable: ...
def soco_coordinator(funct: Callable) -> Callable: ...
def _timespan_secs(timespan: Union[str, None]) -> Union[None, float]: ...

class SonosMediaPlayerEntity(SonosEntity, MediaPlayerEntity):
    _volume_increment: int = ...
    _player_volume: Any = ...
    _player_muted: Any = ...
    _play_mode: Any = ...
    _coordinator: Any = ...
    _sonos_group: Any = ...
    _status: Any = ...
    _uri: Any = ...
    _media_library: Any = ...
    _media_duration: Any = ...
    _media_position: Any = ...
    _media_position_updated_at: Any = ...
    _media_image_url: Any = ...
    _media_channel: Any = ...
    _media_artist: Any = ...
    _media_album_name: Any = ...
    _media_title: Any = ...
    _queue_position: Any = ...
    _night_sound: Any = ...
    _speech_enhance: Any = ...
    _source_name: Any = ...
    _favorites: Any = ...
    _soco_snapshot: Any = ...
    _snapshot_group: Any = ...
    def __init__(self, speaker: SonosSpeaker, sonos_data: SonosData) -> None: ...
    async def async_added_to_hass(self) -> None: ...
    @property
    def unique_id(self) -> str: ...
    def __hash__(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def state(self) -> str: ...
    @property
    def is_coordinator(self) -> bool: ...
    @property
    def coordinator(self) -> SoCo: ...
    def _clear_media_position(self) -> None: ...
    def _set_favorites(self) -> None: ...
    async def async_reconnect_player(self) -> None: ...
    def _reconnect_player(self) -> None: ...
    async def async_update(self, now: Union[datetime.datetime, None]=...) -> None: ...
    def _update(self, now: Union[datetime.datetime, None]=...) -> None: ...
    def async_update_media(self, event: Union[SonosEvent, None]=...) -> None: ...
    def update_media(self, event: Union[SonosEvent, None]=...) -> None: ...
    def update_media_linein(self, source: str) -> None: ...
    def update_media_radio(self, variables: dict) -> None: ...
    def update_media_music(self, update_media_position: bool, track_info: dict) -> None: ...
    def async_update_volume(self, event: SonosEvent) -> None: ...
    def update_volume(self) -> None: ...
    def update_groups(self, event: Union[SonosEvent, None]=...) -> None: ...
    def async_update_groups(self, event: Union[SonosEvent, None]=...) -> None: ...
    def create_update_groups_coro(self, event: Union[SonosEvent, None]=...) -> Union[Coroutine, None]: ...
    def async_update_content(self, event: Union[SonosEvent, None]=...) -> None: ...
    @property
    def volume_level(self) -> Union[float, None]: ...
    @property
    def is_volume_muted(self) -> Union[bool, None]: ...
    @property
    def shuffle(self) -> Union[str, None]: ...
    @property
    def repeat(self) -> Union[str, None]: ...
    @property
    def media_content_id(self) -> Union[str, None]: ...
    @property
    def media_content_type(self) -> str: ...
    @property
    def media_duration(self) -> Union[float, None]: ...
    @property
    def media_position(self) -> Union[float, None]: ...
    @property
    def media_position_updated_at(self) -> Union[datetime.datetime, None]: ...
    @property
    def media_image_url(self) -> Union[str, None]: ...
    @property
    def media_channel(self) -> Union[str, None]: ...
    @property
    def media_artist(self) -> Union[str, None]: ...
    @property
    def media_album_name(self) -> Union[str, None]: ...
    @property
    def media_title(self) -> Union[str, None]: ...
    @property
    def queue_position(self) -> Union[int, None]: ...
    @property
    def source(self) -> Union[str, None]: ...
    @property
    def supported_features(self) -> int: ...
    def volume_up(self) -> None: ...
    def volume_down(self) -> None: ...
    def set_volume_level(self, volume: str) -> None: ...
    def set_shuffle(self, shuffle: str) -> None: ...
    def set_repeat(self, repeat: str) -> None: ...
    def mute_volume(self, mute: bool) -> None: ...
    def select_source(self, source: str) -> None: ...
    @property
    def source_list(self) -> list[str]: ...
    def media_play(self) -> None: ...
    def media_stop(self) -> None: ...
    def media_pause(self) -> None: ...
    def media_next_track(self) -> None: ...
    def media_previous_track(self) -> None: ...
    def media_seek(self, position: str) -> None: ...
    def clear_playlist(self) -> None: ...
    def play_media(self, media_type: str, media_id: str, **kwargs: Any) -> None: ...
    def join(self, slaves: list[SonosMediaPlayerEntity]) -> list[SonosMediaPlayerEntity]: ...
    @staticmethod
    async def join_multi(hass: HomeAssistant, master: SonosMediaPlayerEntity, entities: list[SonosMediaPlayerEntity]) -> None: ...
    def unjoin(self) -> None: ...
    @staticmethod
    async def unjoin_multi(hass: HomeAssistant, entities: list[SonosMediaPlayerEntity]) -> None: ...
    def snapshot(self, with_group: bool) -> None: ...
    @staticmethod
    async def snapshot_multi(hass: HomeAssistant, entities: list[SonosMediaPlayerEntity], with_group: bool) -> None: ...
    def restore(self) -> None: ...
    @staticmethod
    async def restore_multi(hass: HomeAssistant, entities: list[SonosMediaPlayerEntity], with_group: bool) -> None: ...
    @staticmethod
    async def wait_for_groups(hass: HomeAssistant, groups: list[list[SonosMediaPlayerEntity]]) -> None: ...
    def set_sleep_timer(self, sleep_time: int) -> None: ...
    def clear_sleep_timer(self) -> None: ...
    def set_alarm(self, alarm_id: int, time: Union[datetime.datetime, None]=..., volume: Union[float, None]=..., enabled: Union[bool, None]=..., include_linked_zones: Union[bool, None]=...) -> None: ...
    def set_option(self, night_sound: Union[bool, None]=..., speech_enhance: Union[bool, None]=..., status_light: Union[bool, None]=...) -> None: ...
    def play_queue(self, queue_position: int=...) -> None: ...
    def remove_from_queue(self, queue_position: int=...) -> None: ...
    @property
    def extra_state_attributes(self) -> dict[str, Any]: ...
    async def async_get_browse_image(self, media_content_type: Union[str, None], media_content_id: Union[str, None], media_image_id: Union[str, None]=...) -> tuple[Union[None, str], Union[None, str]]: ...
    async def async_browse_media(self, media_content_type: Union[str, None]=..., media_content_id: Union[str, None]=...) -> Any: ...
