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.
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
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=
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”.
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"]
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])
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!