[PLUGIN] Pandora Plugin 2.0

Looking at the pandora_handler.js is it supposed to remove “Radio” from the station name also? If so it isn’t doing that either. Could the number of stations have an effect? I have 40 of them

No, I’m pretty sure it’s a bonehead error on my part.

Quick fix: Change this line in pandora_handler.js:

PandoraHandler.prototype.setMQTTEnabled (should be line 117)

was: self.mqttHandler = mqttEnabled
change it to: self.mqttEnabled = mqttEnabled

I have the topic in MQTT Explorer now (nice free program for mqtt troubleshooting, by the way).

Let’s apply the duct tape and see what else breaks. :smiley: I’ll commit this fix to the develop branch

I think I did this to help with Google Assistant commands, so you could just say, ‘Hey Google, play Soundgarden’ as a shortcut. That can of course be looked at again.

I think that’s all right. I have about 30 or so. I don’t know what the limit is, but I guess at some point we’ll find out.

It looks like the template in the automations-volumio.yaml “Load Hornet Stations” automation was invalid. I’m not sure exactly what happened there – perhaps a change in the Jinja language? The from_json filter seems to have disappeared, but there was a way around that.

I think it’s a bit cleaner now. The stations are now populating in input_select.hornet_station – you can see them now.

I don’t think we’re out of the woods yet. I’ll take another stab at it tomorrow.

EDIT: I put the changes on that GitHub repo I linked in a previous post.

The station list is populating properly in the input selection.

I am still getting a “UndefinedError: ‘newStationName’ is undefined” error. I think it is due to the way the “play_volumio_pandora_station” template is being parsed as a shell command option.

I pushed v2.8.1 beta of the Pandora Plugin to GitHub if you want to update to that. The only change is to that variable name in the pandora_handler.js setMQTTEnabled() function. (package.json, Readme.md updates as well, yeah sure).

Good. At least that’s working.

I’ll take a look at that in a little bit after the coffee kicks in.

Well that took a while. I fixed a few things – I had a problem in the pyscript script I wrote. Slowly, things are improving.

Things seem to be happening twice with every station change. I’ll have to address that next.

The ‘None’ option is just a bad name I chose for “no choice” – I’ll change that to “nothing” perhaps.

Updates were pushed to the repo.

EDIT: One small change to the plugin beta was just pushed (index.js file). You’ll need that fix as well

Updated to latest versions. Changes made directly on Volumio are updated correctly in HA. The issue now is when making a change to the input on the HA side the follow error is thrown.

Error rendering command template: TypeError: Object of type Undefined is not JSON serializable

I spent a while looking at this process. I rewrote the python script to use socket.io and in synchronous code instead of using asyncio. It should not make a difference which way it is since the script only fires once and exits.

That template was a little screwy. Apparently, the executable command in a shell_command has to come first, and data cannot be in a template until after the first space (see the HA docs on the web). I think I’ll just hard code in the regular parameters for now and look into passing them to the function in the future if there is need for more functionality, leaving the Pandora station as an option.

I might pass in the station as a JSON rather than as a string and that will require one small change to the clearAndPlayStation() function. Not a big deal – it probably makes more sense to do that.

I think I had a reason for dropping the Radio suffix from the station names but I can’t remember what that was. That’s not written in stone and can be amended.

Anyway, I just have to make sure the station gets passed to the shell command and then we’ll have more progress. My new script will change the station from a command prompt, and that wasn’t happening when I started working on it today, so I’m calling that progress.

I want to take one more look before I commit these changes. I’ll do that sometime tomorrow morning here (East Coast USA).

Okay, things seem to be a bit better. I changed the input_select in the Developer Tools -> States dialog and the Pandora station played.

I need to have HA poll Volumio (via MQTT? websocket?) and have it yell at the plugin to publish the MQTT data. If HA starts after Volumio, the stations won’t update until a change or a refresh in the plugin.

One thing at a time. @Drizzay let me know what else is broken (and of course if this update doesn’t work for you).

To all you lurkers, throw some rocks this way if you see something!

Hey @truckershitch went away for a bit and am back. The station change from the developers tool still isn’t working for me. It looks like the script is being called though.

021-04-07 13:57:33 DEBUG (MainThread) [custom_components.pyscript.eval] file.update_options.update_options: calling get(“input_select.hornet_station”, {})

2021-04-07 13:57:33 DEBUG (MainThread) [custom_components.pyscript.eval] file.update_options.update_options: calling select_option(, {‘entity_id’: ‘input_select.hornet_station’, ‘option’: ‘Lemongrass’})

I’ll check this out today.

I’m not sure – maybe I didn’t post every change I made on this side to that GitHub repo? Things got a bit hectic last week.

I haven’t looked at this code since my last post. I’ll add something to post the stations in some regular fashion, perhaps publishing via MQTT from the Pandora script with a timer.

Anyway, I have a bit more time to dig into this now.

Oh, did you make sure you have the latest changes on the develop branch? I did change that one function to accept a JSON rather than a plain string for stationName and that could be your issue.

See v2.8.1 beta fix #2: clearAndPlayStation takes JSON input · truckershitch/volumio-plugins@7bb1bed · GitHub

I did a couple of commits last week so you may need a fresh pull.

v2.90 beta was committed to the develop branch.

The main change is the periodic publishing of the station data via MQTT. Before, the data wasn’t always ready for Home Assistant to pick it up. The data is now published approximately every minute. Maybe that’s too often for you? Set a different interval in timers.js if you wish. Be my guest :slight_smile:

Well, I’m gonna crack a beer. Send all hate mail here.

I think it is all working for me now. The current automation is based on the input_select.hornet changing state from none to something else so I might play around with that piece. Big thanks for helping with the WAF.

Great!

Basically, you can use a voice command to change that input_select from Google Assistant. I can’t remember the exact syntax, and that may have changed in the last six months or so.

The command I got to work was awkward, but like this last comment from January 6, 2021 says, you can make a Routine in your Google Home application on your phone to handle things:

Also here:

See if you find anything else with this search:

https://www.google.com/search?q=home+assistant+input+select+google+assistant

Let me know if you find a good way or if you think of any other HA automation ideas.