Squeezebox Playlist selection?

It looks like it doesn’t recognize the item. This is what I normally do in those situations.

Try restarting openHAB.

There also could be a syntax error somewhere in the file. Maybe try putting the Squeezebox items in their own items file?

@mhilbush I have restarted several times. Could you take a look at the rules because i think if there is a fault thats where it is. Maybe i forgot to exchange some data with my own?
val String Squeeze_OliverMAC = “00:04:20:26:53:3d”

val org.eclipse.xtext.xbase.lib.Functions$Function2 Squeeze_Oliver_Play_Playlist = [
    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%3D2f8e3d8bf8c32452f470e9e55461fb14"
		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")
	Squeeze_Oliver_Play_Playlist.apply(Squeeze_OliverMAC, receivedCommand.toString)
end

I looked at the rule earlier and it looks fine.

Besides, I don’t think it’s making it to the rule. That error is complaining about not being able to get the item (Squeeze_Oliver_Play_PlayList) associated with the Selection widget in your sitemap.

Not sure if you are on Linux or Windows. In Linux you could try:

cd your-openhab-directory
./runtime/karaf/bin/client items | grep Squeeze

You should see something like this:

Squeezebox_Play_PlayList (Type=NumberItem, State=NULL, Label=Playlists, Category=network, Groups=[sbp_md_deck])

@mhilbush Im on windows.

Hmm. Maybe try this from a web browser on your Windows box. If you don’t have something to make the JSON pretty, it will look like a mess. But this would display the information about the item Squeeze_Oliver_Play_PlayList.

http://localhost:8080/rest/items/Squeeze_Oliver_Play_PlayList

Edit: Alternatively, in PaperUI, you could go to Configuration > Items and look for the item Squeeze_Oliver_Play_PlayList in the items list.

It works now! Finally. I went through the items in the rules and copy pasted so i made sure that it was making it to the right item. And it didnt show up in the rest api at first. Thank you very much @mhilbush i really appreciate the help. Cheers

It even works when i encode spotify urls to lets say playlist in the lms!

@Oliver_Roed_Scholer Glad you got it working!

Hey @mhilbush . Ive found that it works great except sometimes the radios turn on randomly. I think this has to do with the rule. When you send it a radio station it will turn on even with the radio off. So i think that when i connect with the android app, habmin, it sends the state of the radio station i chose last, resulting in radios turning on around the house

I tried to add an if to the rule but now it doesnt work. Here’s the code

rule "Squeeze_Oliver_Play_PlayList"
when
	Item Squeeze_Oliver_Play_PlayList received command
then
	if (Squeeze_Oliver_Power == ON){
		logInfo("squeezeplaylist.rules", "Playing playlist on Oliver Squeezebox")
		squeezeplaylist.apply(Squeeze_OliverMAC, receivedCommand.toString)
	}
end

Yeah, that could get annoying pretty quickly. :slight_smile:

Try Squeeze_Oliver_Power.state in your if statement.

Once again you made it work @mhilbush. Thank you very very much