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
11 changes: 8 additions & 3 deletions homeassistant/components/spotify/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
STATE_PLAYING,
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.config_entry_oauth2_flow import OAuth2Session
from homeassistant.helpers.entity import Entity
from homeassistant.util.dt import utc_from_timestamp
Expand Down Expand Up @@ -212,8 +213,12 @@ def wrapper(self, *args, **kwargs):
result = func(self, *args, **kwargs)
self.player_available = True
return result
except (SpotifyException, requests.RequestException):
except requests.RequestException:
self.player_available = False
except SpotifyException as exc:
self.player_available = False
if exc.reason == "NO_ACTIVE_DEVICE":
raise HomeAssistantError("No active playback device found") from None

return wrapper

Expand Down Expand Up @@ -623,7 +628,7 @@ def build_item_response(spotify, user, payload):
try:
item_id = item["id"]
except KeyError:
_LOGGER.debug("Missing id for media item: %s", item)
_LOGGER.debug("Missing ID for media item: %s", item)
continue
media_item.children.append(
BrowseMedia(
Expand Down Expand Up @@ -679,7 +684,7 @@ def item_payload(item):
media_type = item["type"]
media_id = item["uri"]
except KeyError as err:
_LOGGER.debug("Missing type or uri for media item: %s", item)
_LOGGER.debug("Missing type or URI for media item: %s", item)
raise MissingMediaInformation from err

try:
Expand Down