Allow 'turning on' cast groups (#70642)

* Allow 'turning on' cast groups

* Adjust test
This commit is contained in:
Erik Montnemery 2022-04-25 14:41:24 +02:00 committed by GitHub
parent c467f318ed
commit 23d9e135bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View file

@ -794,16 +794,12 @@ class CastMediaPlayerEntity(CastDevice, MediaPlayerEntity):
def supported_features(self):
"""Flag media player features that are supported."""
support = (
MediaPlayerEntityFeature.PLAY_MEDIA | MediaPlayerEntityFeature.TURN_OFF
MediaPlayerEntityFeature.PLAY_MEDIA
| MediaPlayerEntityFeature.TURN_OFF
| MediaPlayerEntityFeature.TURN_ON
)
media_status = self._media_status()[0]
if self._chromecast and self._chromecast.cast_type in (
pychromecast.const.CAST_TYPE_CHROMECAST,
pychromecast.const.CAST_TYPE_AUDIO,
):
support |= MediaPlayerEntityFeature.TURN_ON
if (
self.cast_status
and self.cast_status.volume_control_type != VOLUME_CONTROL_TYPE_FIXED

View file

@ -800,10 +800,12 @@ async def test_entity_cast_status(hass: HomeAssistant):
| SUPPORT_PLAY_MEDIA
| SUPPORT_STOP
| SUPPORT_TURN_OFF
| SUPPORT_TURN_ON
| SUPPORT_VOLUME_MUTE
| SUPPORT_VOLUME_SET,
SUPPORT_PLAY_MEDIA
| SUPPORT_TURN_OFF
| SUPPORT_TURN_ON
| SUPPORT_VOLUME_MUTE
| SUPPORT_VOLUME_SET,
),
@ -1386,7 +1388,11 @@ async def test_entity_media_states_lovelace_app(hass: HomeAssistant):
state = hass.states.get(entity_id)
assert state.state == "playing"
assert state.attributes.get("supported_features") == (
SUPPORT_PLAY_MEDIA | SUPPORT_TURN_OFF | SUPPORT_VOLUME_MUTE | SUPPORT_VOLUME_SET
SUPPORT_PLAY_MEDIA
| SUPPORT_TURN_OFF
| SUPPORT_TURN_ON
| SUPPORT_VOLUME_MUTE
| SUPPORT_VOLUME_SET
)
media_status = MagicMock(images=None)