Squeezebox Playlist selection?

Is there any way to select a playlist for a squeezebox in openhab 2? And what does playlistindex do? there is very little documentation and examples, unless i just cant find it. Also any example on playing a radio station? Im new so i dont know how to use the stream channel or how to find the radio ip.

Thanks in advance

Can’t help too much with openhab 2 as I’m still on 1.8 at the moment until it comes out of beta and has an apt-get install all done. It’s on the to do list with everything else.

It can be done on openhab 1 with playlists (it is manual with rules though). I’m pretty sure there is something with it and radio streams on the wiki as I did write some a while ago.

Josh

There are a few examples here.

And here.

@joshpond80 There is a stream channel for openhab 2 but im fairly new and i have set up some different rules for other stuff so know a little thing or two about rules, but i dont know how to send the url to the squeezebox. There is no documentation for the stream channel. And i couldnt get the oh 1 rules to work. That though may be my fault, i dont know

@mhilbush Thanks. Ill check out the first one tomorrow as it seems like the second is for oh 1? But the first thread looks promising

Thanks!

I included the second thread because I have a post in there that describes how to play pandora stations thinking that the same approach might be used for radio stations.

I use both the Spotify plugin, nas files and tunein radio.

The urls provided when i favorite is following
Spotify = spotify:user::playlist:3obFbjfq2TxJyBFBjFO2Lz
Tunein = http://opml.radiotime.com/Tune.ashx?id=s87164&formats=aac,ogg,mp3,wmpro,wma,wmvoice&partnerId=16&serial=f29bc9c96a57a8e16b521da616db3839

None ending with .mp3 and none working when just inserted. You know how to get it to work?

Also realised that “val org.eclipse.xtext.xbase.lib.Functions$Function2” is giving me a notice that “Function2 is a raw type. References to generic type Function2<P1,
P2, Result> should be parameterized”

Is that in the designer? I think I get that too, but I haven’t used the designer in a long time.

Its in the designer yes. Otherwise everything looks fine. Ive changed out the items, and the request url but still, doesnt work. Its on port 9002 if that matters?

Not sure. You could try URL-encoding the radiotime URL, then inserting it into the logitech URL in the place where I have the URL-encoded pandora URL.

Here’s the URL-encoded version of the radiotime URL

http%3A%2F%2Fopml.radiotime.com%2FTune.ashx%3Fid%3Ds87164%26formats%3Daac%2Cogg%2Cmp3%2Cwmpro%2Cwma%2Cwmvoice%26partnerId%3D16%26serial%3Df29bc9c96a57a8e16b521da616db3839

And here it is inserted into the logitech URL. You need to replace hostname with the name or IP of your LMS server, replace MACaddress with the MAC address of the Logitech player, and replace 9000 with the port number for your LMS.

http://hostname:9000/status.html?p0=playlist&p1=play&p2=http%3A%2F%2Fopml.radiotime.com%2FTune.ashx%3Fid%3Ds87164%26formats%3Daac%2Cogg%2Cmp3%2Cwmpro%2Cwma%2Cwmvoice%26partnerId%3D16%26serial%3Df29bc9c96a57a8e16b521da616db3839&player=MACaddress

If I get some time tonight, I can see if I can get it to work…

Still doesnt work. I get send to a page with simple controls over the radio and status of currently playing station. Here is my rule, if have time i’d appreciate if you could check it out

val String Squeeze_OliverMAC = “myadressehere”

val org.eclipse.xtext.xbase.lib.Functions$Function2 squeezePlayPlaylist = [
String player,
String playlist |

logInfo(“squeezeplaylist.rules”, "In squeezePlayPlaylist with player of " + player)

var String station
var String requestURL
var boolean success = true

switch(playlist) {
case “0” :
station = “http%3A%2F%2Fopml.radiotime.com%2FTune.ashx%3Fid%3Ds87164%26formats%3Daac%2Cogg%2Cmp3%2Cwmpro%2Cwma%2Cwmvoice%26partnerId%3D16%26serial%3Df29bc9c96a57a8e16b521da616db3839”
case “1” :
station = “spotify:track:124NFj84ppZ5pAxTuVQYCQ”
case “2” :
station = “http://opml.radiotime.com/Tune.ashx?id=s24861&formats=aac,ogg,mp3,wmpro,wma,wmvoice&partnerId=16&serial=2f8e3d8bf8c32452f470e9e55461fb14
case “3” :
station = “pandora%3A%2F%2F79741376504106105.mp3”
case “4” :
station = “pandora%3A%2F%2F3230131829791886457.mp3”
case “5” :
station = “pandora%3A%2F%2F72031231602953337.mp3”
default : {
logError(“squeezeplaylist.rules”, “Received a request for an unknown playlist!”)
success = false
}
}

if (success == true) {
requestURL = “http://192.168.1.11:9002/status.html?p0=playlist&p1=play&p2=” + station + “&player=” + player
logInfo(“squeezeplaylist.rules”, "Sending playlist request to server: " + requestURL)
sendHttpGetRequest(requestURL)
}
]

rule “Squeeze_Oliver_Play_PlayList”
when
Item Squeeze_Oliver_Play_Playlist received command
then
logInfo(“squeezeplaylist.rules”, “Playing playlist on Oliver Squeezebox”)
squeezePlayPlaylist.apply(Squeeze_OliverMAC, receivedCommand.toString)
end

I’ve tried many things with the adresses, trial and error but nothing works out for me.The sitemap and items are just renamed to fit my layout. Ill check back tomorrow and try to figure it out.

Thank you very much for the help, much appreciated

Oliver

Try pasting this into your web browser (after changing the hostname, port, and mac address to match your settings). It should play the College Sports Now radio station.

http://HOSTNAME:PORT/status.html?p0=playlist&p1=play&p2=http%3A%2F%2Fopml.radiotime.com%2FTune.ashx%3Fid%3Ds254142%26formats%3Daac%2Cogg%2Cmp3%2Cwma%2Cwmvoice%26partnerId%3D16%26serial%3D01cc89df798110127d45d6daf&player=00:04:20:16:45:26

Unbelievable! It works. What did you do to the url? @mhilbush

Go here, copy the radiotime URL into the box, and click encode. Then copy the encoded URL and paste it into your logitech URL after the p2= and before the &player= :slight_smile:

http://meyerweb.com/eric/tools/dencoder/

BTW, there are many other URL encoders out there. This just happened to be the one that was the first search result when I googled “URL encoder”. :grinning:

2 Likes

Thanks @mhilbush. The url i get from the lms encoded now works in the direct url, but sadly not in the rule you provided. Any way to fix this issue? Or am i missing a obvious step here?

Not sure. What are you seeing in openhab.log when the rule executes?

This is what it says when i press the selection in my sitemap @mhilbush

2016-10-26 21:24:09.843 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item ‘Squeeze_Oliver_Play_PlayList’ for widget org.eclipse.smarthome.model.sitemap.Selection
2016-10-26 21:24:09.843 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Selection
2016-10-26 21:24:09.843 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item ‘Squeeze_Oliver_Play_PlayList’ for widget org.eclipse.smarthome.model.sitemap.Selection
2016-10-26 21:24:09.843 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item ‘Squeeze_Oliver_Play_PlayList’ for widget org.eclipse.smarthome.model.sitemap.Selection
2016-10-26 21:24:09.843 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item ‘Squeeze_Oliver_Play_PlayList’ for widget org.eclipse.smarthome.model.sitemap.Selection
2016-10-26 21:25:23.963 [INFO ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at ‘items/Squeeze_Oliver_Play_PlayList’ for the unknown item ‘Squeeze_Oliver_Play_PlayList’.

Hmm. Could you post the Squeezebox items and sitemap entry you’re using? It looks like something might be missing. Maybe also try restarting openHAB.

In a .items file, there should be an item defined that looks like this.

Number Squeeze_Oliver_Play_PlayList

And something like this in the .sitemap file.

Selection item=Squeeze_Oliver_Play_PlayList label="Play a Playlist" 
                            mappings=[0="Playlist 1", 1="PL2", 2="PL3", 3="PL4", 4="PL5", 5="PL6"]

Thats exactly what i have. The items is that and this is the sitemap
Selection item=Squeeze_Oliver_Play_PlayList label="Play a Playlist" mappings=[0="Playlist0", 1="Playlist1", 2="Playlist2", 3="Playlist3", 4="Playlist4", 5="Playlist5"]