Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions homeassistant/components/sonos/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def state(self):
if self._status in ("PAUSED_PLAYBACK", "STOPPED",):
# Sonos can consider itself "paused" but without having media loaded
# (happens if playing Spotify and via Spotify app you pick another device to play on)
if self._media_title is None:
if self.media_title is None:
return STATE_IDLE
return STATE_PAUSED
if self._status in ("PLAYING", "TRANSITIONING"):
Expand Down Expand Up @@ -614,12 +614,19 @@ def update_media_radio(self, variables, track_info):
except (TypeError, KeyError, AttributeError):
pass

# Radios without tagging can have part of the radio URI as title.
# Non-playing radios will not have a current title. In these cases we
# try to use the radio name instead.
# Non-playing radios will not have a current title. Radios without tagging
# can have part of the radio URI as title. In these cases we try to use the
# radio name instead.
try:
if self._media_title in self._uri or self.state != STATE_PLAYING:
self._media_title = variables["enqueued_transport_uri_meta_data"].title
uri_meta_data = variables["enqueued_transport_uri_meta_data"]
if isinstance(
uri_meta_data, pysonos.data_structures.DidlAudioBroadcast
) and (
self.state != STATE_PLAYING
or self.soco.is_radio_uri(self._media_title)
or self._media_title in self._uri
):
self._media_title = uri_meta_data.title
except (TypeError, KeyError, AttributeError):
pass

Expand Down