How can I start Spotify on my Samsung TV?

I am looking for a way to start the Spotify app on my Samsung TV. My TV is relatively recent, post-2019

I can already power up the TV, control it’s volume, etc from the media_player entity. Source list is only showing TV and HDMI:

I currently use an infrared repeater (broadlink), and I’ve programmed the button sequence, but it is very unreliable and depends on the TV’s responsiveness and current state, which sometimes differs.

Best would be to directly trigger spotify as an app. Is there a way to do this? Adding this as the sourcelist? I’ve added the TV from the integration page; it was auto detected.

Thanks for your help!

Not that I’m aware of, I’m afraid. Had a similar use-case, but although the smart tvs do have APIs and some even have home assistant integrations I could not personally get them to work for things like selecting playlists and performing actions inside of the apps on the TV. All they seem to do is control the basic TV functions.

I eventually went with “alexa play spotify on hifi” where “hifi” is another muted echo connected to the amplifier or a bluetooth receiver. Then I use the phone to control.

Such a basic need, yet I didn’t find anyone asking how to achieve that in the forums …

Take a look at GitHub - jaruba/ha-samsungtv-tizen: 📺 HomeAssistant - For Samsung TVs 2016+, Includes SmartThings API and Channel List Support
This custom component has more features that the official integration, including the ability to launch apps.

2 Likes

I use this one, works great to start an app

Thank you both @Holdestmade and @mjgarner1 ! Works perfectly

I also use ollo69’s code to select sources. It works fine to select sources. However, Spotify is a special case:
Selecting the Spotify app from the drop-down list in the UI is no problem, but I wanted to select the Spotify app from a script and this turned out to be difficult:
The select source script returned with no error but didn’t work when I used Spotify or spotify as source name.
In German, the source is called “Spotify – Musik und Podcasts” in the UI. Something is special about the spaces and the dash.
The solution was to use the developer menu “states”. Here, the media player shows the sources as YAML.
The Spotify entry contains a backslash.
I copied this entry verbatim into the YAML for the service call, and it works.
Hope this helps other non-English users.

2 Likes

Thanks for the tip! Unfortunately I still cannot get it to work.
In the developer tools stats it says “Spotify\_– Musik und Podcasts” (including the quotation marks).
When I enter that verbatim into a service call I get “unknown error” and node red (where I want to use this) is complaining about “unsupported escape sequence”…

Do you have any other idea how to get this work?

The other integrations mentioned here didn’t work for me either.

Edit: My frustration got to the point where I simply changed my TV language to english which fixed it for me… still curious how to to select a source with a backslash in it.

I used copy & paste and edited the YAML directly.

Thanks to the advice of @hvb I got my automation to work.

However I also want to set the icon color depending on the state, but this Jinja2 template doesn’t work for me. It returns grey even so “Spotify” is the current source:

{{ is_state_attr("media_player.lg_tv", "source", "Spotify\_– Musik und Podcasts") | iif("#1DB954", "grey") }}

Has anybody a clue?

Edit:
Alright figured it out myself.

Turns out Jinja2 interprets source (“Spotify\_– Musik und Podcasts”) as Spotify – Musik und Podcasts with a Non-Breaking Space between “y” and the dash. See attached image.

grafik

Once I added this, the template renders as expected:

{{ is_state_attr("media_player.lg_tv", "source", "Spotify – Musik und Podcasts") | iif("#1DB954", "grey") }}

how did you do it, cant open any app myself