#Is there a way to get spotify song information from xbox?

1 messages · Page 1 of 1 (latest)

primal ivy
#

I want to make an automation which will extract the main color of the song and set it as the background color of the TV.

I have a lot of guests weekly and asking everyone to login to a spotify service is a huge no-no for me.

Spotify can be accessed by any user on the LAN by using the spotify connect protocol but from what I saw the xbox entity doesn't expose which song is being played -- only that the spotify application itself is playing/is open.

Is there some way I can get some basic metadata of the song? Ideally the song ID.

winged nacelle
#

Author of the SpotifyPlus integration here ...
Are you wanting to do this from your existing HA Spotify media_player entity?
Or are you talking about a direct web-service call to the Spotify Web API?

It's an easy solution if you're using SpotifyPlus - just use the Get Image Vibrant Colors service to retrieve the vibrant colors of the currently playing image of the specified source device (in this case, your XBox). Assuming that you can select the XBox source since it's a Spotify Connect device.

action: spotifyplus.get_image_vibrant_colors
data:
  entity_id: media_player.spotifyplus_john_s
  color_count: 64
  color_quality: 1

If you want to go the direct web-service call route, then you will need to call the Spotify Web API Get Playback State endpoint. You can see if this works by using the "Try It" functionality on the above link. Ensure that the XBox is selected as the active player, then click the "Try It" button to retrieve the details. It should look something like the attached screen capture.

Hope it helps!

GitHub

Home Assistant integration for Spotify Player control, services, and soundtouchplus integration support. - thlucas1/homeassistantcomponent_spotifyplus

primal ivy
#

Hey @winged nacelle thanks for the response! Before I take a deep dive with the integration let me re-explain the scenario in more details, it might clarify some stuff.


So pretty much the xbox is there, let's say like a common spotify media player device. Everyone has access to it, even people who don't have access to the HA isntance. As long as they're on the wifi and nobody else is playing, they could just use spotify connect to play music on the device, without creating a jam // without being associated to my spotify account.

I'd like to be able to access the song metadata so the vibrant color service can extract it and set the background colorof the TV (more like backlight, just an LED strip).

I won't go with the route of every person has to connect their spotify app to the integration, that's just next level annoying when it's just due to light

#

I have no issues with the web API if that means that when someone else connects to it I can access the data

winged nacelle
#

Ahhhh, I see now. So your guests would be controlling the Spotify player using their devices (assuming Spotify App on their phones). How do they authenticate / connect up to the XBox player? Is it through their own Spotify accounts? Or is the XBox somehow sharing a Spotify account / using YOUR Spotify account maybe?

A better way to ask ... If you have the HA Spotify integration installed on your HA instance, and select the XBox device as the source, do you see the changes (in your HA Spotify player) to what's playing (on the XBox) when a guest connects up to the XBox player and changes the song? If you DO see the changes, then it's an easy automation via SpotifyPlus to get the dominant color of the currently playing cover art.

I'm not sure how you would apply that to the TV background color though; that would depend on the TV, and if there is an API to do that via HA.