mirror of
https://github.com/home-assistant/core.git
synced 2026-08-24 10:13:52 -05:00
Address review issues for Sonos cancel annoucement (#177220)
This commit is contained in:
@@ -529,7 +529,6 @@ class SonosMediaPlayerEntity(SonosEntity, MediaPlayerEntity):
|
||||
)
|
||||
_LOGGER.debug("Playing %s using websocket audioclip", media_id)
|
||||
try:
|
||||
self.speaker.last_announce_id = None
|
||||
assert self.speaker.websocket
|
||||
response, data = await self.speaker.websocket.play_clip(
|
||||
async_process_play_media_url(self.hass, media_id),
|
||||
|
||||
@@ -1313,8 +1313,9 @@ class SonosSpeaker:
|
||||
translation_key="announcement_connection_error",
|
||||
translation_placeholders={"error": "websocket not available"},
|
||||
)
|
||||
announcement_id = self.last_announce_id
|
||||
try:
|
||||
response, _ = await self.websocket.cancel_clip(self.last_announce_id)
|
||||
response, _ = await self.websocket.cancel_clip(announcement_id)
|
||||
except SonosWebsocketError as exc:
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
@@ -1327,7 +1328,8 @@ class SonosSpeaker:
|
||||
translation_key="cancel_announcement_error",
|
||||
translation_placeholders={"response": str(response)},
|
||||
)
|
||||
self.last_announce_id = None
|
||||
if announcement_id == self.last_announce_id:
|
||||
self.last_announce_id = None
|
||||
|
||||
#
|
||||
# Media and playback state handlers
|
||||
|
||||
Reference in New Issue
Block a user