mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
Add Sonos support for media_player.repeat_set service (#41735)
* Add Sonos support for media_player.repeat_set service * Update homeassistant/components/sonos/media_player.py * Remove else for pylint Co-authored-by: cgtobi <cgtobi@users.noreply.github.com>
This commit is contained in:
parent
d00655810f
commit
b5308bda09
@ -33,6 +33,9 @@ from homeassistant.components.media_player.const import (
|
||||
MEDIA_TYPE_MUSIC,
|
||||
MEDIA_TYPE_PLAYLIST,
|
||||
MEDIA_TYPE_TRACK,
|
||||
REPEAT_MODE_ALL,
|
||||
REPEAT_MODE_OFF,
|
||||
REPEAT_MODE_ONE,
|
||||
SUPPORT_BROWSE_MEDIA,
|
||||
SUPPORT_CLEAR_PLAYLIST,
|
||||
SUPPORT_NEXT_TRACK,
|
||||
@ -40,6 +43,7 @@ from homeassistant.components.media_player.const import (
|
||||
SUPPORT_PLAY,
|
||||
SUPPORT_PLAY_MEDIA,
|
||||
SUPPORT_PREVIOUS_TRACK,
|
||||
SUPPORT_REPEAT_SET,
|
||||
SUPPORT_SEEK,
|
||||
SUPPORT_SELECT_SOURCE,
|
||||
SUPPORT_SHUFFLE_SET,
|
||||
@ -86,6 +90,7 @@ SUPPORT_SONOS = (
|
||||
| SUPPORT_PLAY
|
||||
| SUPPORT_PLAY_MEDIA
|
||||
| SUPPORT_PREVIOUS_TRACK
|
||||
| SUPPORT_REPEAT_SET
|
||||
| SUPPORT_SEEK
|
||||
| SUPPORT_SELECT_SOURCE
|
||||
| SUPPORT_SHUFFLE_SET
|
||||
@ -502,6 +507,7 @@ class SonosEntity(MediaPlayerEntity):
|
||||
self._player_volume = None
|
||||
self._player_muted = None
|
||||
self._shuffle = None
|
||||
self._repeat = None
|
||||
self._coordinator = None
|
||||
self._sonos_group = [self]
|
||||
self._status = None
|
||||
@ -674,6 +680,7 @@ class SonosEntity(MediaPlayerEntity):
|
||||
"""Get basic information and add event subscriptions."""
|
||||
try:
|
||||
self._shuffle = self.soco.shuffle
|
||||
self._repeat = self.soco.repeat
|
||||
self.update_volume()
|
||||
self._set_favorites()
|
||||
|
||||
@ -719,6 +726,7 @@ class SonosEntity(MediaPlayerEntity):
|
||||
return
|
||||
|
||||
self._shuffle = self.soco.shuffle
|
||||
self._repeat = self.soco.repeat
|
||||
self._uri = None
|
||||
self._media_duration = None
|
||||
self._media_image_url = None
|
||||
@ -954,6 +962,18 @@ class SonosEntity(MediaPlayerEntity):
|
||||
"""Shuffling state."""
|
||||
return self._shuffle
|
||||
|
||||
@property
|
||||
@soco_coordinator
|
||||
def repeat(self):
|
||||
"""Return current repeat mode."""
|
||||
if self._repeat is True:
|
||||
return REPEAT_MODE_ALL
|
||||
|
||||
if self._repeat == "ONE":
|
||||
return REPEAT_MODE_ONE
|
||||
|
||||
return REPEAT_MODE_OFF
|
||||
|
||||
@property
|
||||
@soco_coordinator
|
||||
def media_content_id(self):
|
||||
@ -1055,6 +1075,17 @@ class SonosEntity(MediaPlayerEntity):
|
||||
"""Enable/Disable shuffle mode."""
|
||||
self.soco.shuffle = shuffle
|
||||
|
||||
@soco_error(UPNP_ERRORS_TO_IGNORE)
|
||||
@soco_coordinator
|
||||
def set_repeat(self, repeat):
|
||||
"""Set repeat mode."""
|
||||
repeat_map = {
|
||||
REPEAT_MODE_OFF: False,
|
||||
REPEAT_MODE_ALL: True,
|
||||
REPEAT_MODE_ONE: "ONE",
|
||||
}
|
||||
self.soco.repeat = repeat_map[repeat]
|
||||
|
||||
@soco_error()
|
||||
def mute_volume(self, mute):
|
||||
"""Mute (true) or unmute (false) media player."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user