FIx Sonos announce regression issue (#125515)
* initial commit * initial commit
This commit is contained in:
parent
0b1a898c7c
commit
6b2526ddbd
2 changed files with 40 additions and 5 deletions
|
@ -84,6 +84,7 @@ REPEAT_TO_SONOS = {
|
|||
SONOS_TO_REPEAT = {meaning: mode for mode, meaning in REPEAT_TO_SONOS.items()}
|
||||
|
||||
UPNP_ERRORS_TO_IGNORE = ["701", "711", "712"]
|
||||
ANNOUNCE_NOT_SUPPORTED_ERRORS: list[str] = ["globalError"]
|
||||
|
||||
SERVICE_SNAPSHOT = "snapshot"
|
||||
SERVICE_RESTORE = "restore"
|
||||
|
@ -556,11 +557,24 @@ class SonosMediaPlayerEntity(SonosEntity, MediaPlayerEntity):
|
|||
) from exc
|
||||
if response.get("success"):
|
||||
return
|
||||
raise HomeAssistantError(
|
||||
translation_domain=SONOS_DOMAIN,
|
||||
translation_key="announce_media_error",
|
||||
translation_placeholders={"media_id": media_id, "response": response},
|
||||
)
|
||||
if response.get("type") in ANNOUNCE_NOT_SUPPORTED_ERRORS:
|
||||
# If the speaker does not support announce do not raise and
|
||||
# fall through to_play_media to play the clip directly.
|
||||
_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):
|
||||
media_type = spotify.resolve_spotify_media_type(media_type)
|
||||
|
|
|
@ -1123,6 +1123,27 @@ async def test_play_media_announce(
|
|||
)
|
||||
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(
|
||||
hass: HomeAssistant,
|
||||
|
|
Loading…
Add table
Reference in a new issue