Add MEDIA_ENQUEUE to MediaPlayerEntityFeature (#95905)
parent
2b4f6ffcd6
commit
6dae3553f2
|
@ -82,6 +82,7 @@ SUPPORTED_FEATURES = (
|
|||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
| MediaPlayerEntityFeature.BROWSE_MEDIA
|
||||
| MediaPlayerEntityFeature.MEDIA_ENQUEUE
|
||||
)
|
||||
SUPPORTED_FEATURES_ZONE = (
|
||||
MediaPlayerEntityFeature.VOLUME_SET
|
||||
|
|
|
@ -51,6 +51,7 @@ from homeassistant.helpers.event import async_track_state_change_event
|
|||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, EventType
|
||||
|
||||
KEY_CLEAR_PLAYLIST = "clear_playlist"
|
||||
KEY_ENQUEUE = "enqueue"
|
||||
KEY_ON_OFF = "on_off"
|
||||
KEY_PAUSE_PLAY_STOP = "play"
|
||||
KEY_PLAY_MEDIA = "play_media"
|
||||
|
@ -116,6 +117,7 @@ class MediaPlayerGroup(MediaPlayerEntity):
|
|||
self._entities = entities
|
||||
self._features: dict[str, set[str]] = {
|
||||
KEY_CLEAR_PLAYLIST: set(),
|
||||
KEY_ENQUEUE: set(),
|
||||
KEY_ON_OFF: set(),
|
||||
KEY_PAUSE_PLAY_STOP: set(),
|
||||
KEY_PLAY_MEDIA: set(),
|
||||
|
@ -192,6 +194,10 @@ class MediaPlayerGroup(MediaPlayerEntity):
|
|||
self._features[KEY_VOLUME].add(entity_id)
|
||||
else:
|
||||
self._features[KEY_VOLUME].discard(entity_id)
|
||||
if new_features & MediaPlayerEntityFeature.MEDIA_ENQUEUE:
|
||||
self._features[KEY_ENQUEUE].add(entity_id)
|
||||
else:
|
||||
self._features[KEY_ENQUEUE].discard(entity_id)
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register listeners."""
|
||||
|
@ -434,6 +440,8 @@ class MediaPlayerGroup(MediaPlayerEntity):
|
|||
| MediaPlayerEntityFeature.VOLUME_SET
|
||||
| MediaPlayerEntityFeature.VOLUME_STEP
|
||||
)
|
||||
if self._features[KEY_ENQUEUE]:
|
||||
supported_features |= MediaPlayerEntityFeature.MEDIA_ENQUEUE
|
||||
|
||||
self._attr_supported_features = supported_features
|
||||
self.async_write_ha_state()
|
||||
|
|
|
@ -52,6 +52,7 @@ BASE_SUPPORTED_FEATURES = (
|
|||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
| MediaPlayerEntityFeature.GROUPING
|
||||
| MediaPlayerEntityFeature.BROWSE_MEDIA
|
||||
| MediaPlayerEntityFeature.MEDIA_ENQUEUE
|
||||
)
|
||||
|
||||
PLAY_STATE_TO_STATE = {
|
||||
|
|
|
@ -199,6 +199,7 @@ class MediaPlayerEntityFeature(IntFlag):
|
|||
BROWSE_MEDIA = 131072
|
||||
REPEAT_SET = 262144
|
||||
GROUPING = 524288
|
||||
MEDIA_ENQUEUE = 2097152
|
||||
|
||||
|
||||
# These SUPPORT_* constants are deprecated as of Home Assistant 2022.5.
|
||||
|
|
|
@ -154,6 +154,9 @@ play_media:
|
|||
enqueue:
|
||||
name: Enqueue
|
||||
description: If the content should be played now or be added to the queue.
|
||||
filter:
|
||||
supported_features:
|
||||
- media_player.MediaPlayerEntityFeature.MEDIA_ENQUEUE
|
||||
required: false
|
||||
selector:
|
||||
select:
|
||||
|
|
|
@ -195,6 +195,7 @@ class SonosMediaPlayerEntity(SonosEntity, MediaPlayerEntity):
|
|||
MediaPlayerEntityFeature.BROWSE_MEDIA
|
||||
| MediaPlayerEntityFeature.CLEAR_PLAYLIST
|
||||
| MediaPlayerEntityFeature.GROUPING
|
||||
| MediaPlayerEntityFeature.MEDIA_ENQUEUE
|
||||
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||
| MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
|
|
|
@ -234,6 +234,7 @@ class SqueezeBoxEntity(MediaPlayerEntity):
|
|||
| MediaPlayerEntityFeature.CLEAR_PLAYLIST
|
||||
| MediaPlayerEntityFeature.STOP
|
||||
| MediaPlayerEntityFeature.GROUPING
|
||||
| MediaPlayerEntityFeature.MEDIA_ENQUEUE
|
||||
)
|
||||
|
||||
def __init__(self, player):
|
||||
|
|
|
@ -191,7 +191,9 @@ async def test_supported_features(hass: HomeAssistant) -> None:
|
|||
| MediaPlayerEntityFeature.PLAY
|
||||
| MediaPlayerEntityFeature.STOP
|
||||
)
|
||||
play_media = MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
play_media = (
|
||||
MediaPlayerEntityFeature.PLAY_MEDIA | MediaPlayerEntityFeature.MEDIA_ENQUEUE
|
||||
)
|
||||
volume = (
|
||||
MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
| MediaPlayerEntityFeature.VOLUME_SET
|
||||
|
|
Loading…
Reference in New Issue