mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 06:37:52 +00:00
Raise Spotify exception if no active device found (#48486)
This commit is contained in:
parent
9d8521169b
commit
9043a1f5aa
@ -52,6 +52,7 @@ from homeassistant.const import (
|
|||||||
STATE_PLAYING,
|
STATE_PLAYING,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.config_entry_oauth2_flow import OAuth2Session
|
from homeassistant.helpers.config_entry_oauth2_flow import OAuth2Session
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.util.dt import utc_from_timestamp
|
from homeassistant.util.dt import utc_from_timestamp
|
||||||
@ -212,8 +213,12 @@ def spotify_exception_handler(func):
|
|||||||
result = func(self, *args, **kwargs)
|
result = func(self, *args, **kwargs)
|
||||||
self.player_available = True
|
self.player_available = True
|
||||||
return result
|
return result
|
||||||
except (SpotifyException, requests.RequestException):
|
except requests.RequestException:
|
||||||
self.player_available = False
|
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
|
return wrapper
|
||||||
|
|
||||||
@ -623,7 +628,7 @@ def build_item_response(spotify, user, payload):
|
|||||||
try:
|
try:
|
||||||
item_id = item["id"]
|
item_id = item["id"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
_LOGGER.debug("Missing id for media item: %s", item)
|
_LOGGER.debug("Missing ID for media item: %s", item)
|
||||||
continue
|
continue
|
||||||
media_item.children.append(
|
media_item.children.append(
|
||||||
BrowseMedia(
|
BrowseMedia(
|
||||||
@ -679,7 +684,7 @@ def item_payload(item):
|
|||||||
media_type = item["type"]
|
media_type = item["type"]
|
||||||
media_id = item["uri"]
|
media_id = item["uri"]
|
||||||
except KeyError as err:
|
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
|
raise MissingMediaInformation from err
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user