mirror of
https://github.com/home-assistant/core.git
synced 2025-08-02 10:08:23 +00:00
Handle transport errors when updating media via events (#50480)
Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com>
This commit is contained in:
parent
88574034b7
commit
2c492d71f7
@ -498,9 +498,14 @@ class SonosMediaPlayerEntity(SonosEntity, MediaPlayerEntity):
|
|||||||
if new_status == "TRANSITIONING":
|
if new_status == "TRANSITIONING":
|
||||||
return
|
return
|
||||||
|
|
||||||
self._play_mode = (
|
if variables and "transport_state" in variables:
|
||||||
variables["current_play_mode"] if variables else self.soco.play_mode
|
self._play_mode = variables["current_play_mode"]
|
||||||
)
|
track_uri = variables["current_track_uri"]
|
||||||
|
music_source = self.soco.music_source_from_uri(track_uri)
|
||||||
|
else:
|
||||||
|
self._play_mode = self.soco.play_mode
|
||||||
|
music_source = self.soco.music_source
|
||||||
|
|
||||||
self._uri = None
|
self._uri = None
|
||||||
self._media_duration = None
|
self._media_duration = None
|
||||||
self._media_image_url = None
|
self._media_image_url = None
|
||||||
@ -514,13 +519,6 @@ class SonosMediaPlayerEntity(SonosEntity, MediaPlayerEntity):
|
|||||||
update_position = new_status != self._status
|
update_position = new_status != self._status
|
||||||
self._status = new_status
|
self._status = new_status
|
||||||
|
|
||||||
if variables:
|
|
||||||
track_uri = variables["current_track_uri"]
|
|
||||||
music_source = self.soco.music_source_from_uri(track_uri)
|
|
||||||
else:
|
|
||||||
# This causes a network round-trip so we avoid it when possible
|
|
||||||
music_source = self.soco.music_source
|
|
||||||
|
|
||||||
if music_source == MUSIC_SRC_TV:
|
if music_source == MUSIC_SRC_TV:
|
||||||
self.update_media_linein(SOURCE_TV)
|
self.update_media_linein(SOURCE_TV)
|
||||||
elif music_source == MUSIC_SRC_LINE_IN:
|
elif music_source == MUSIC_SRC_LINE_IN:
|
||||||
@ -556,7 +554,7 @@ class SonosMediaPlayerEntity(SonosEntity, MediaPlayerEntity):
|
|||||||
self._media_title = source
|
self._media_title = source
|
||||||
self._source_name = source
|
self._source_name = source
|
||||||
|
|
||||||
def update_media_radio(self, variables: dict) -> None:
|
def update_media_radio(self, variables: dict | None) -> None:
|
||||||
"""Update state when streaming radio."""
|
"""Update state when streaming radio."""
|
||||||
self._clear_media_position()
|
self._clear_media_position()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user