Add Spotify media browser capability (#39240)
Co-authored-by: Tobias Sauerwein <cgtobi@gmail.com> Co-authored-by: Bram Kragten <mail@bramkragten.nl> Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
7 files changed
+390
-21
No files matched your search
@@ -1,4 +1,5 @@
|
||||
"""The spotify integration."""
|
||||
import logging
|
||||
|
||||
from spotipy import Spotify, SpotifyException
|
||||
import voluptuous as vol
|
||||
@@ -16,7 +17,15 @@ from homeassistant.helpers.config_entry_oauth2_flow import (
|
||||
)
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import DATA_SPOTIFY_CLIENT, DATA_SPOTIFY_ME, DATA_SPOTIFY_SESSION, DOMAIN
|
||||
from .const import (
|
||||
DATA_SPOTIFY_CLIENT,
|
||||
DATA_SPOTIFY_ME,
|
||||
DATA_SPOTIFY_SESSION,
|
||||
DOMAIN,
|
||||
SPOTIFY_SCOPES,
|
||||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
@@ -71,6 +80,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
DATA_SPOTIFY_SESSION: session,
|
||||
}
|
||||
|
||||
if set(session.token["scope"].split(" ")) <= set(SPOTIFY_SCOPES):
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": "reauth"},
|
||||
data=entry.data,
|
||||
)
|
||||
)
|
||||
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_forward_entry_setup(entry, MEDIA_PLAYER_DOMAIN)
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user