WTH: Update HA and HAOS Support for Pandora (the Music system)

Use of Pianobar for Pandora is limited at best and isn’t even supported by the preferred HA installation or using HAOS. It is about time HA gets with the times and updates this Legacy Integration!

Hard to conceptualize “get with the times” and “Pandora” in the same breath :sweat_smile:

1 Like

Snarky comments aside, it does look like there is some movement for Pandora support in Music Assistant. This might be something to watch @DanGarion

1 Like

I’ve been one of those commenting on that thread! :slight_smile: I’ve tried to set up pianobar a few times in the past but never was able to make use of it. Now I can’t since I run HAOS so until there is another solution I’m stuck. I’ve used Pandora for well over 10 years I’ve TRIED multiple times to move to another service but unfortunately, nothing else has the main Pandora feature I feel is the most important thing to have, which is the curated stations.

3 Likes

They do, might not be as good as pandora but they all have stations that you can create and it will play similar music. I’ve never used pandora, I’ve used IHeart and Spotify, and Amazon, all 3 have this.

But where? All I have ever found are playlists, which are just lists of music I like. I’ve never located a way to create a station that plays music I like (which I can thumbs up/down).

1 Like

Just search for an artist, one of the options found will be “< the artist > Station”, it will start with a song from that artist then introduce similar ones beyond that. As you listen you can thumb up or down things and that list/station will remain in your recently played.

1 Like

In Spotify, if you click on the more options (ellipses) menu on any Artist or Song you can go to a “radio station” inspired by that selection. It works pretty well im my opinion, and I was a long time Pandora user many moons ago.

2 Likes

Out of pure curiosity @DanGarion would you mind sharing a bit more about your usecase? I’m curious the role Home Assitant plays in your setup and how you are using automations with your radio stations and/or speaker endpoints.

I’m going to try and give Spotify Premium another honest run through again for 2 months (along with the rest of the family) to see if it can fit our needs.

@DanGarion
If giving Spotify a try on Home Assistant, you might check out the SpotifyPlus Card.

Hope it helps!

1 Like

I was the OP for that referenced thread about supporting Pandora. I find Pandora spectacularly good at creating curated stations that give me the type of music I want to hear at any given time. I have no patience to create my own play lists.

But I will indeed have to check out one or more of the mentioned alternatives that are already supported in HA / MA. If they are capable of tailoring my stations in a very similar manner, that’s certainly a lot simpler than creating a whole new integration.

Thanks for the discussion!

4 Likes

I’m with Dan, Pandora stations are 10x better than any other service. I have 1 or 2 stations that are over 10 years old and they’re perfectly tuned to what I want to hear. I even have Spotify premium currently because my sister uses it and she added me to her family plan. But I usually only use it for podcasts, not music. I just couldn’t get it to curate similar stations to Pandora.

I would love to be able to start a Pandora station on one of my google homes as an alarm clock so I can have my entire wakeup routine in home assistant rather than 2 different places. Right now I have the Pandora part setup in the google home app, and the rest of my automations for waking up(lights on, fan off) in home assistant. As it stands, I have to disable 2 automations if for instance school is cancelled because of snow.

4 Likes

FYI, my family and I took a 2 month test drive of Spotify and we ended up with the same conclusion we have always had and went back to Pandora.

2 Likes

Dan,
You’re living my life. Once you train your entire family on how to use a service, it’s impossible to tell them “now you have to use Spotify”. All I heard was “Spotify sucks”. So Alexa is still powered on and the VPE and Sat1 devices now sit in a drawer.

Curated stations are WAY better on Pandora,they always have been. I don’t get it… the poll put Pandora at the very top of what folks want that’s missing. Voice assistants are all the rage right now and the #1 music streaming service is still missing from MA.

A little effort on this will go a long way.

4 Likes

The HA app has a sensor that can pull your phones next alarm time as a sensor. You can tie the HA wakeup automation to your next alarm so it automatically updates to when you’re waking up, or if its outside of certain hours, the automation won’t fire. It’s made my life so much easier.

Pandora would still be nice though.

Just voicing my support for Pandora inclusion, but it appears that all access to Pandora’s API is gated behind a developer application, and that they aren’t accepting any new developer applications right now. Otherwise, I’ve got some time on my hands and would love to help out with this.

In the meantime, while this is in no way ideal, I added an input_toggle to my HomeAssistant named “Pandora Playing” and a routine to an Echo dot that monitors this exposed sensor and plays Pandora when it is “on” and stops when it is “off”. Adding a button to my HA instance that manipulates this sensor was easy. This gives me an easy way to stop and start Pandora from HA. It does not provide any way to manipulate what is playing, but Pandora is very very good about picking stuff, so I almost never adjust any of that anyway. Also, of course, there’s not much control over where the sound comes out, other than what’s connected to your Echo dot.

I’m really interested in this conversation/development. Right now, I don’t have any free time nor do I have enough knowledge (yet) to contribute much on the code side but I’m happy to help test things out - especially since I don’t know what I’m doing yet :slight_smile:

While here though, could someone point me to a link for figuring out how to get sound from the Home Assistant Green. My guess is I somehow need to have bluetooth speakers and then add a bluetooth dongle to my Green? Or can I also use the Voice Assistant PE as a speaker?

Thanks!

I was searching around to see if there has been any movement on support for pandora in music assistant, and found this thread. I’ve been interested in a more seamless pandora experience for a while.

That said, I figured I should give an explanation of a solution that has been working for me for a number of years: I’ve successfully integrated Pianobar control in Home Assistant. It’s hacky and requires quite a bit of setup, but it works. It’s probably important to note that I’m using Pianobar version (2022.04.01) on a headless Raspberry Pi 4b running Ubuntu. The rPi, as well as the pi zero clients, use HiFiBerry hats to allow for RCA connection to various speakers/receivers.

The “trick” is to use node red on both the HA server and the pianobar server. You must use the Pianobar Control script add-on, which allows CLI control through a snapfifo. On the HA server node red instance I have button/switch nodes for each of the desired functions (start, stop, next, ban, love, tired, play/pause, etc) that communicate with the pianobar server node red instance over MQTT. On the pianobar server node red, those MQTT payloads flow to an Exec(ute) node, which run the various CLI control commands.

Example of the command for next:

echo -n 'n' > ~/.config/pianobar/snapfifo

Quit:

echo -n 'q' > ~/.config/pianobar/snapfifo

Note that the exec node “command” is “echo”, and the option for “append payload” completes the command. This way one exec node can be used for all the commands.

“Start” is also run though an exec node, but without a payload. The command is simply: pianobar

Another ability is to select stations. You can find the station number through the pianobar CLI, then:

echo -n 's' > ~/.config/pianobar/snapfifo && echo -n 'STATION_#_HERE' > ~/.config/pianobar/snapfifo && echo -ne '\n' > ~/.config/pianobar/snapfifo

This compound command (1) initiates the station select command “s” then (2) enters the station number “#” and finally (3) emulates a keyboard return with “\n”

Note: adding a new station through pandora will change the station numbers for other channels, as they are listed in alphabetical order.

Lastly, I scrape the Artist, Track, and Station data on the pianobar server, echo/save them individually and on the fly to files, and then mqtt those file contents back to the HA server node red and into custom sensors. The bash script located in ~/.config/pianobar/ that is doing the heavy lifting is:

#!/bin/bash
while read L; do
        k="`echo "$L" | cut -d '=' -f 1`"
        v="`echo "$L" | cut -d '=' -f 2`"
        export "$k=$v"
done < <(grep -e '^\(title\|artist\|album\|stationName\|pRet\|pRetStr\|wRet\|wRetStr\|songDuration\|songPlayed\|rating\)=' /dev/stdin)
case "$1" in
        songstart)
        echo "$artist - $title" > $HOME/.config/pianobar/nowplaying
        echo "$title" > $HOME/.config/pianobar/title
        echo "$artist" > $HOME/.config/pianobar/artist
        echo "$stationName" > $HOME/.config/pianobar/station
esac

The only other weirdness I’ve found with this solution is that it’s easy to accidentally start multiple instances of pianobar, so I found another (hacky!) solution:

From the Pianobar server node red, I execute:

ps -ef | grep pianobar

And I take that exec node output and use a function node to decide on if there are multiple instances of pianobar running:

// Check if "pianobar" is running and handle errors
var output = msg.payload; // Assuming msg.payload contains the output from the exec node
// Count the occurrences of "pianobar" in the output excluding "/pianobar/eventcmd"
var numberOfOccurrences = (output.match(/pianobar(?!\/eventcmd)/g) || []).length;
// Set the output property based on the result
if (numberOfOccurrences === 3) {
    msg.payload = 1; // "pianobar" is running
} else if (numberOfOccurrences > 3) {
    msg.payload = -1; // Error: more than 1 instance of "pianobar"
} else {
    msg.payload = 0; // "pianobar" is not running
}
return msg;

A switch node then looks for the output number (1, 0, -1) and kills pianobar if it’s “-1” using another exec node and the command pkill pianobar

Yes, all very convoluted, and it took me months to get it all worked out… but it does indeed work. I’ve left out a bit, such as a drop down list for stations and the function that adds their station number to the command call, but the bones of the system are here.

…and this is why I want Pandora integrated into Music Assistant…

1 Like

I suppose I should add that my pianobar server also runs a Snapcast server + client, which allows for synchronized multi-room Pandora audio (the main objective for me for this whole setup.)

I was excited to learn recently that Music Assistant allows me to push audio to this external snapcast server, so I can pull all my local audio files from Jellyfin and push them out to all my snapcast clients.

(It’s wild to me that listening to my local files in the living room utilizes 4 different devices: HA server running MA, Jellyfin server, Snapcast server, and finally a Snapcast client. There are assuredly ways to condense the stack, but it is what it is.)