mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
FIx Sonos announce regression issue (#125515)
* initial commit * initial commit
This commit is contained in:
parent
8d0dda6523
commit
2c48f9aa4c
@ -84,6 +84,7 @@ REPEAT_TO_SONOS = {
|
|||||||
SONOS_TO_REPEAT = {meaning: mode for mode, meaning in REPEAT_TO_SONOS.items()}
|
SONOS_TO_REPEAT = {meaning: mode for mode, meaning in REPEAT_TO_SONOS.items()}
|
||||||
|
|
||||||
UPNP_ERRORS_TO_IGNORE = ["701", "711", "712"]
|
UPNP_ERRORS_TO_IGNORE = ["701", "711", "712"]
|
||||||
|
ANNOUNCE_NOT_SUPPORTED_ERRORS: list[str] = ["globalError"]
|
||||||
|
|
||||||
SERVICE_SNAPSHOT = "snapshot"
|
SERVICE_SNAPSHOT = "snapshot"
|
||||||
SERVICE_RESTORE = "restore"
|
SERVICE_RESTORE = "restore"
|
||||||
@ -556,11 +557,24 @@ class SonosMediaPlayerEntity(SonosEntity, MediaPlayerEntity):
|
|||||||
) from exc
|
) from exc
|
||||||
if response.get("success"):
|
if response.get("success"):
|
||||||
return
|
return
|
||||||
raise HomeAssistantError(
|
if response.get("type") in ANNOUNCE_NOT_SUPPORTED_ERRORS:
|
||||||
translation_domain=SONOS_DOMAIN,
|
# If the speaker does not support announce do not raise and
|
||||||
translation_key="announce_media_error",
|
# fall through to_play_media to play the clip directly.
|
||||||
translation_placeholders={"media_id": media_id, "response": response},
|
_LOGGER.debug(
|
||||||
)
|
"Speaker %s does not support announce, media_id %s response %s",
|
||||||
|
self.speaker.zone_name,
|
||||||
|
media_id,
|
||||||
|
response,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
raise HomeAssistantError(
|
||||||
|
translation_domain=SONOS_DOMAIN,
|
||||||
|
translation_key="announce_media_error",
|
||||||
|
translation_placeholders={
|
||||||
|
"media_id": media_id,
|
||||||
|
"response": response,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
if spotify.is_spotify_media_type(media_type):
|
if spotify.is_spotify_media_type(media_type):
|
||||||
media_type = spotify.resolve_spotify_media_type(media_type)
|
media_type = spotify.resolve_spotify_media_type(media_type)
|
||||||
|
@ -1163,6 +1163,27 @@ async def test_play_media_announce(
|
|||||||
)
|
)
|
||||||
assert sonos_websocket.play_clip.call_count == 1
|
assert sonos_websocket.play_clip.call_count == 1
|
||||||
|
|
||||||
|
# Test speakers that do not support announce. This
|
||||||
|
# will result in playing the clip directly via play_uri
|
||||||
|
sonos_websocket.play_clip.reset_mock()
|
||||||
|
sonos_websocket.play_clip.side_effect = None
|
||||||
|
retval = {"success": 0, "type": "globalError"}
|
||||||
|
sonos_websocket.play_clip.return_value = [retval, {}]
|
||||||
|
|
||||||
|
await hass.services.async_call(
|
||||||
|
MP_DOMAIN,
|
||||||
|
SERVICE_PLAY_MEDIA,
|
||||||
|
{
|
||||||
|
ATTR_ENTITY_ID: "media_player.zone_a",
|
||||||
|
ATTR_MEDIA_CONTENT_TYPE: "music",
|
||||||
|
ATTR_MEDIA_CONTENT_ID: content_id,
|
||||||
|
ATTR_MEDIA_ANNOUNCE: True,
|
||||||
|
},
|
||||||
|
blocking=True,
|
||||||
|
)
|
||||||
|
assert sonos_websocket.play_clip.call_count == 1
|
||||||
|
soco.play_uri.assert_called_with(content_id, force_radio=False)
|
||||||
|
|
||||||
|
|
||||||
async def test_media_get_queue(
|
async def test_media_get_queue(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user