OH2 Squeezebox select paylist?

Hi there,

Can anyone tell me how to play a playlist through the squeezebox binding?
I’ve got playlists for radio channels in my LMS and I don’t want to duplicate all stream URLs in openhab - I know
it’s possible to select streams.

It might be related to the playlist index channel, but I found no documentation on what it exactly does…

Thank you,
Christoph

Hi! I got this working in my sitemap. I can select different playlists or radio stations from this
This is the rule

val String Squeeze_OliverMAC = “”
val String Squeeze_StueMAC = “”
val String Squeeze_SurroundMAC = "
val String Squeeze_KitchenMAC = “”
val String Squeeze_RuneMAC = “”
val String Squeeze_BedroomMAC = “”
val String Squeeze_MarkusMAC = “”
val String Squeeze_WorkshopMAC = “”

val org.eclipse.xtext.xbase.lib.Functions$Function2 squeezeplaylist = [
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 = “%09http%3A%2F%2Fopml.radiotime.com%2FTune.ashx%3Fid%3Ds216726%26formats%3Daac%2Cogg%2Cmp3%2Cwmpro%2Cwma%2Cwmvoice%26partnerId%3D16%26serial%3D2f8e3d8bf8c32452f470e9e55461fb14”
case “2” :
station = “http%3A%2F%2Fopml.radiotime.com%2FTune.ashx%3Fid%3Ds24861%26formats%3Daac%2Cogg%2Cmp3%2Cwmpro%2Cwma%2Cwmvoice%26partnerId%3D16%26serial%3D2f8e3d8bf8c32452f470e9e55461fb14”
case “3” :
station = “http%3A%2F%2Fopml.radiotime.com%2FTune.ashx%3Fid%3Ds9085%26formats%3Daac%2Cogg%2Cmp3%2Cwmpro%2Cwma%2Cwmvoice%26partnerId%3D16%26serial%3Df29bc9c96a57a8e16b521da616db3839”
case “4” :
station = “%09http%3A%2F%2Fopml.radiotime.com%2FTune.ashx%3Fid%3Ds128359%26formats%3Daac%2Cogg%2Cmp3%2Cwmpro%2Cwma%2Cwmvoice%26partnerId%3D16%26serial%3D2f8e3d8bf8c32452f470e9e55461fb14”
case “5” :
station = “http%3A%2F%2Fopml.radiotime.com%2FTune.ashx%3Fid%3Ds69060%26formats%3Daac%2Cogg%2Cmp3%2Cwmpro%2Cwma%2Cwmvoice%26partnerId%3D16%26serial%3D2f8e3d8bf8c32452f470e9e55461fb14”
case “6” :
station = “https%3A%2F%2Fapi.voicerss.org%2F%3Fkey%3Dbe1cf2d7464b42a692baaeade72db451%26f%3D44khz_16bit_stereo%26hl%3Den-gb%26src%3DThis%2520is%2520Major%2520Tom%2520to%2520Ground%2520Control”
case “7” :
station = “”
case “8” :
station = “spotify%3Auser%3Ai%3Aplaylist%3A4R0GXciJ7Wfmjl86t6oHvE”
default : {
logError(“squeezeplaylist.rules”, “Received a request for an unknown playlist!”)
success = false
}
}

if (success == true) {
requestURL = “http://URL OF LOGITECH MEDIA SERVER/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
if (Squeeze_Oliver_Power.state == ON){
logInfo(“squeezeplaylist.rules”, “Playing playlist on Oliver Squeezebox”)
squeezeplaylist.apply(Squeeze_OliverMAC, receivedCommand.toString)
}
end

rule “Squeeze_Stue_Play_PlayList”
when
Item Squeeze_Stue_Play_PlayList received command
then
if (Squeeze_Stue_Power.state==ON){
logInfo(“squeezeplaylist.rules”, “Playing playlist on Stue Squeezebox”)
squeezeplaylist.apply(Squeeze_StueMAC, receivedCommand.toString)
}
end

rule “Squeeze_Surround_Play_PlayList”
when
Item Squeeze_Surround_Play_PlayList received command
then
if(Squeeze_Surround_Power.state==ON){
logInfo(“squeezeplaylist.rules”, “Playing playlist on Surround Squeezebox”)
squeezeplaylist.apply(Squeeze_SurroundMAC, receivedCommand.toString)
}
end

rule “Squeeze_Kitchen_Play_PlayList”
when
Item Squeeze_Kitchen_Play_PlayList received command
then
if(Squeeze_Kitchen_Power.state==ON){
logInfo(“squeezeplaylist.rules”, “Playing playlist on Kitchen Squeezebox”)
squeezeplaylist.apply(Squeeze_KitchenMAC, receivedCommand.toString)
}
end

rule “Squeeze_Rune_Play_PlayList”
when
Item Squeeze_Rune_Play_PlayList received command
then
if(Squeeze_Rune_Power.state==ON){
logInfo(“squeezeplaylist.rules”, “Playing playlist on Rune Squeezebox”)
squeezeplaylist.apply(Squeeze_RuneMAC, receivedCommand.toString)
}
end

rule “Squeeze_Bedroom_Play_PlayList”
when
Item Squeeze_Bedroom_Play_PlayList received command
then
if(Squeeze_Bedroom_Power.state==ON){
logInfo(“squeezeplaylist.rules”, “Playing playlist on Bedroom Squeezebox”)
squeezeplaylist.apply(Squeeze_BedroomMAC, receivedCommand.toString)
}
end

rule “Squeeze_Markus_Play_PlayList”
when
Item Squeeze_Markus_Play_PlayList received command
then
if(Squeeze_Markus_Power.state==ON){
logInfo(“squeezeplaylist.rules”, “Playing playlist on Markus Squeezebox”)
squeezeplaylist.apply(Squeeze_MarkusMAC, receivedCommand.toString)
}
end

rule “Squeeze_Workshop_Play_PlayList”
when
Item Squeeze_Workshop_Play_PlayList received command
then
if(Squeeze_Workshop_Power.state==ON){
logInfo(“squeezeplaylist.rules”, “Playing playlist on Workshop Squeezebox”)
squeezeplaylist.apply(Squeeze_WorkshopMAC, receivedCommand.toString)
}

We have the sitemap config

Selection item=Squeeze_Oliver_Play_PlayList mappings=[0=“Nova Fm”, 1=“myRock”, 2=“DR P3”, 3=“The Voice”, 4=“Pop FM”, 5=“DR P5”, 7=“Test”]

and the items

Number Squeeze_Oliver_Play_PlayList “Play a radio station” <audio_playlist>

You would need to change the mac adress of the players, and the url for the items can be found in the logitech media server and you need to convert the url with this tool URL Decoder/Encoder and press encode. Not exactly sure if this is what you wanted but here you have it

Or look at this thread for more Squeezebox Playlist selection? - #14 by Oliver_Roed_Scholer

Thanks for the files @Oliver_Roed_Scholer - however, that’s precisely what I wanted to avoid :slight_smile:

What I wanted to do is just send the LMS playlist to be played to LMS.
I’ve created a playlist for each radio station I usually listen to on LMS plus some other playlists.

Ideally the binding would provide two things:

a) list of playlists
b) possibility to tell player X to playback playlist Y

From what I see in the code the playlistIndex channel should actually select the playlist to be played, but it doesn’t seem to work.

Well i cant help you with that, as i got help from what i sent, as seen in the thread i linked to. Might want to ask the guy who helped me there.

I did it with a simple post request in a rule that is bound to a String Item

Hi all,

if the Squeezebox binding lacks a feature you need, e.g. playlist operations you may need the HTTP interface. Example below clears the existing playlist and selects playlist “All”:

rule PlayRandomTitle
  when
    Item ItemPlayRandomTitles changed to ON
  then
   val _serverURL = "http://HAUS:9000/status.html"
   
   val _parameterP0 = "?p0="
   val _parameterP1 = "&p1="
   val _parameterP2 = "&p2="
// val _parameterP3 = "&p3="
   
   val _requestURLClearPlaylist = _serverURL 
                                + _parameterP0 + "playlist" 
                                + _parameterP1 + "clear"
                                
   val _requestURLAddAllToPlaylist = _serverURL 
                                   + _parameterP0 + "playlist" 
                                   + _parameterP1 + "add" 
                                   + _parameterP2 + "All"
   /* Shuffle the playlist. 
    * p1=0 no shuffle, 
    * p1=1 shuffle songs in the playlist, 
    * p1=2 shuffle albums in the playlist. 
    * Omit p1 to toggle shuffle mode.
    */
   val _requestURLPlaylistShuffle = _serverURL
                                  + _parameterP0 + "playlist"
                                  + _parameterP1 + "1"
   
//   println("Request URL:" + _requestURLClearPlaylist)
//   println("Request URL:" + _requestURLAddAllToPlaylist)
//   println("Request URL:" + _requestURLPlaylistShuffle)
   
   sendHttpGetRequest(_requestURLClearPlaylist)
   sendHttpGetRequest(_requestURLAddAllToPlaylist)
   sendHttpGetRequest(_requestURLPlaylistShuffle)
   
   ItemPlayRandomTitles.postUpdate(OFF)
  end

with kind regards,
Patrik

How does this rule look like, that I can play a radio station? I have already tried many variations.

I can turn the Squeezebox on and off and adjust the volume.

Sitemap:
Switch item= squeezeSelect1Station mappings=[1=“HR3”] visibility=[squeeze1Control==PLAY]

Rule:
rule "play Radio"
when
Item squeezeSelect1Station received command
then
{
sendCommand(squeezeSelect1Station,“http://www.antenne.de/webradio/antenne.m3u”)

// or: sendCommand(squeezeSelect1Station,“http://192.168.178.36:9000/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:2a:9c:16”)

}
end

I had tested many configurations, nothing works.

Hope somebody can help.

Hi Chris,

Looks like you need an extra Item, one which is mapped to the Streamchannel of the Squeezebox thing you want to control:
.items:

String squeeze_mySqueezebox_Stream "Stream" (gSqueezebox) { channel="squeezebox:squeezeboxplayer:lms:mySB:stream" }
String squeeze_mySqueezebox_Power "Power" (gSqueezebox) { channel="squeezebox:squeezeboxplayer:lms:mySB:power" }
String squeeze_mySqueezebox_Play "Play" (gSqueezebox) { channel="squeezebox:squeezeboxplayer:lms:mySB:play" }

You then call the sendCommand on that item:

rule "play Radio"
    when
        Item squeezeSelect1Station received command
    then
    {
        squeeze_mySqueezebox_Power.sendCommand(ON)
        squeeze_mySqueezebox_Stream.sendCommand("http://www.antenne.de/webradio/antenne.m3u")
        squeeze_mySqueezebox_Play.sendCommand(ON)

    }
end

Hope that helps.

James

Hi James,

thank you very much for reply/help.

I had tested, but it does not work. :frowning:

I entered exactly these lines:

Sitemap:
Switch item=squeezeSelect1Station mappings=[1=“AntenneBayern”] visibility=[squeeze1Control==PLAY]

Item:
String squeeze_mySqueezebox “Stream” { channel=“squeezebox:squeezeboxplayer:iRadioServer:0004202a9b15:stream” }

Rule:
rule "Play SqueezeBoxRadio"
when
Item squeezeSelect1Station received command
then
{
squeeze_mySqueezebox.sendCommand(“http%3A%2F%2Fwww.antenne.de%2Fwebradio%2Fantenne.m3u”)
// or: squeeze_mySqueezebox.sendCommand(“http://www.antenne.de/webradio/antenne.m3u”)
// or: squeeze_mySqueezebox.sendCommand(“http://192.168.178.36:9000/status.html?p0=playlist&p1=play&p2=http%3A%2F%2Fwww.antenne.de%2Fwebradio%2Fantenne.m3u&player=00:04:20:2a:9b:15”)
}
end

Can you imagine why it does not work?
I’ve been testing for a few weeks.

I would be very grateful if someone can help.

In the prizip I would like only one playlist (m3u) play.

The OS ist Windows 10, openHAB 2.2, SqueezeBox Binding 2.2.0. But I have already tested it with openHAB 2.0 / 2.1. Unfortunately that did not work, too.

PLEASE HELP :slight_smile:

Sure, can you post your .things config for your server and the squeezebox. I’m away from desk so can’t check.

One thing I forgot to add, you need to turn the power on and play the sb with separate commands, it doesn’t work like the v1 binding which auto played.

Cheers
James

Hi Chris,

I’ve edited my example above to copy what I’ve done - it’d be helpful to post you .things and .items if you’re having further trouble - also, try and please use code fences - three `s before and after your code - or the second icon from the right on the compose header.

Cheers
James

It took some time, but now it works! :slight_smile:

OpenHAB 2.2, Build #1060
Squeezebox Binding binding-squeezebox - 2.2.0.SNAPSHOT

I have installed the latest LMS (LogitechMediaServer-7.9.1-1505480690.exe):
http://downloads.slimdevices.com/nightly/?ver=7.9

And I used the URL Decoder/Encoder to encode the html-address:
http://meyerweb.com/eric/tools/dencoder/
example:
http://www.charivari.de/webradio/955-charivari-stream-webradio.m3u
after encode:
http%3A%2F%2Fwww.charivari.de%2Fwebradio%2F955-charivari-stream-webradio.m3u

My Sitemap:
Text label=“iRadio Küche” icon=“Squeezbox” {
Switch item=squeezeboxOnOff icon=“Squeezbox” mappings=[“ON”=“EIN”, “OFF”=“AUS”]
Selection item=squeezeboxSender mappings=[1=“Antenne Bayern”,2=“Bayern 3”,3=“Charivari Hitmix”]
Switch item=squeezeboxPlay mappings=[“OFF”=“Pause”, “ON”=“Play”]
// Default item=squeezeboxControl
Switch item=squeezeboxMute mappings=[“OFF”=“Mute”]
Slider item=squeezeboxVolume icon="LautstaerkeLa"
Text item=squeezeboxTitel label="Title"
Text item=squeezeboxArtist label=“Artist”
}

My Items:
Switch squeezeboxOnOff “Squeezbox” { channel=“squeezebox:squeezeboxplayer:iRadioServer:0004202a9xxx:power”}
Dimmer squeezeboxVolume “Lautst. +/- [%.1f %%]” { channel=“squeezebox:squeezeboxplayer:iRadioServer:0004202a9xxx:volume”}
String squeezeboxTitel “Stream: [MAP(streams.map):%s]” { channel=“squeezebox:squeezeboxplayer:iRadioServer:0004202a9xxx:title”}
String squeezeboxArtist “von: [%s]” { channel=“squeezebox:squeezeboxplayer:iRadioServer:0004202a9xxx:artist”}
Switch squeezeboxMute “Mute” { channel=“squeezebox:squeezeboxplayer:iRadioServer:0004202a9xxx:mute”}
Switch squeezeboxPlay “Play” { channel=“squeezebox:squeezeboxplayer:iRadioServer:0004202a9xxx:playPause” }
Number squeezeboxSender “Sender” { channel=“squeezebox:squeezeboxplayer:iRadioServer:0004202a9xxx:stream” }

My Rules:
rule "Squeezebox Stream-Play"
when
Item squeezeboxSender received command
then
switch(receivedCommand) {
case 1: {
sendHttpGetRequest(“http://192.168.178.36:9000/status.html?p0=playlist&p1=play&p2=http%3A%2F%2Fwww.antenne.de%2Fwebradio%2Fantenne.m3u&player=00:04:20:2a:9x:xx”)
squeezeboxPlay.sendCommand(ON)
}
case 2: {
playStream(“http://192.168.178.36:9000/status.html?p0=playlist&p1=play&p2=http%3A%2F%2Fstreams.br.de%2Fbayern3_2.m3u&player=00:04:20:2a:9x:xx”)
squeezeboxPlay.sendCommand(ON)
}
case 3: {
playStream(“http://192.168.178.36:9000/status.html?p0=playlist&p1=play&p2=http%3A%2F%2Fwww.charivari.de%2Fwebradio%2F955-charivari-stream-webradio.m3u&player=00:04:20:2a:9x:xx”)
squeezeboxPlay.sendCommand(ON)
}
}
end


Both sendHttpGetRequest and playStream works.

(“http:///status.html?p0=playlist&p1=play&p2=&player=”)

Hope it helps someone else

Best regards

Chris

2 Likes