mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add reverse repeatmode mapping constant to Spotify (#43968)
This commit is contained in:
parent
180491f8cd
commit
9b7ecddde6
@ -82,12 +82,16 @@ SUPPORT_SPOTIFY = (
|
|||||||
| SUPPORT_VOLUME_SET
|
| SUPPORT_VOLUME_SET
|
||||||
)
|
)
|
||||||
|
|
||||||
REPEAT_MODE_MAPPING = {
|
REPEAT_MODE_MAPPING_TO_HA = {
|
||||||
"context": REPEAT_MODE_ALL,
|
"context": REPEAT_MODE_ALL,
|
||||||
"off": REPEAT_MODE_OFF,
|
"off": REPEAT_MODE_OFF,
|
||||||
"track": REPEAT_MODE_ONE,
|
"track": REPEAT_MODE_ONE,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
REPEAT_MODE_MAPPING_TO_SPOTIFY = {
|
||||||
|
value: key for key, value in REPEAT_MODE_MAPPING_TO_HA.items()
|
||||||
|
}
|
||||||
|
|
||||||
BROWSE_LIMIT = 48
|
BROWSE_LIMIT = 48
|
||||||
|
|
||||||
MEDIA_TYPE_SHOW = "show"
|
MEDIA_TYPE_SHOW = "show"
|
||||||
@ -390,7 +394,7 @@ class SpotifyMediaPlayer(MediaPlayerEntity):
|
|||||||
def repeat(self) -> Optional[str]:
|
def repeat(self) -> Optional[str]:
|
||||||
"""Return current repeat mode."""
|
"""Return current repeat mode."""
|
||||||
repeat_state = self._currently_playing.get("repeat_state")
|
repeat_state = self._currently_playing.get("repeat_state")
|
||||||
return REPEAT_MODE_MAPPING.get(repeat_state)
|
return REPEAT_MODE_MAPPING_TO_HA.get(repeat_state)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> int:
|
||||||
@ -469,9 +473,9 @@ class SpotifyMediaPlayer(MediaPlayerEntity):
|
|||||||
@spotify_exception_handler
|
@spotify_exception_handler
|
||||||
def set_repeat(self, repeat: str) -> None:
|
def set_repeat(self, repeat: str) -> None:
|
||||||
"""Set repeat mode."""
|
"""Set repeat mode."""
|
||||||
for spotify, home_assistant in REPEAT_MODE_MAPPING.items():
|
if repeat not in REPEAT_MODE_MAPPING_TO_SPOTIFY:
|
||||||
if home_assistant == repeat:
|
raise ValueError(f"Unsupported repeat mode: {repeat}")
|
||||||
self._spotify.repeat(spotify)
|
self._spotify.repeat(REPEAT_MODE_MAPPING_TO_SPOTIFY[repeat])
|
||||||
|
|
||||||
@spotify_exception_handler
|
@spotify_exception_handler
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user