Hi! Some update from myself after upgrading Openhab to latest version. So, after I did it OH restarted and the favorites don’t show under their assigned item. However they are going back when I add or remove one of the favorites on LMS. I didn’t try restarting LMS so I can’t tell now if this would be enough. Restart of OH doesn’t fix it. I don’t know how it works, but does the binding request for favorities update when starting?
The binding requests the favorites when the binding starts, and when the favorites are changed on the LMS.
In the released version of the binding, there’s a race condition at startup where sometimes the player handler is not fully initialized when the server handler tries to send it the favorites. This is fixed in a PR that hasn’t been merged yet.
Found your question looking for the same answer. As I did not liked the answer, and I dont know if you are still looking for it, but I found a workaround, all you have do do is copy the URI from the playlist, as a share, in the spotify app, and create a favorite with a name you can give and URI you just got on the LMS interface. Worked for me
I’m using this functionality booth in rules and sitemaps superb jobb. Maybe I’m missing something in my rule functionality, but I woluld like to find a way to send Favorites Name and not only ID wich I can now. I have a special button triggering my morning routine starting radio and send a messeage containing temperature and stuff.
You should be able to pull the favorites list from the favoritesList channel of the squeezebox server thing, then use the ID to lookup the favorite name. You would need to first split the list on "," to create an array of favorites, then iterate through the favorites splitting each favorite on "=" to separate the id from the name. I can post a code snippet if you’re not sure how to do this.
val String theOne = "1"
for(String favorite : FavoritesListItem.state.toString.split(",")) {
val String[] fav = favorite.split("=")
val String id = fav.get(0)
val String name = fav.get(1)
//logInfo("test", "(id,name) = ({},{})", id, name)
if (theOne.equals(id)) {
// Do something with name
}
}
Thanks for your example I would never figured that out myself. Right now I’ve got it working sort of, but allways get Favorit number one in my messeage, I assume that have something to do with the one val. But no idea how to make it better.
05:50:25.026 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘squeezekokfavorite’ received command 2
05:50:25.058 [INFO ] [arthome.event.ItemStatePredictedEvent] - squeezekokfavorite predicted to become 2
05:50:25.159 [INFO ] [smarthome.event.ItemStateChangedEvent] - squeezeKokPower changed from OFF to ON
05:50:25.498 [INFO ] [smarthome.event.ItemStateChangedEvent] - squeezeKokControl changed from PAUSE to PLAY
05:50:25.502 [INFO ] [g.eclipse.smarthome.model.script.test] - (id,name) = (1,Lugna Favoriter)
05:50:25.503 [INFO ] [smarthome.event.ItemStateChangedEvent] - squeezeKokPlay changed from OFF to ON
05:50:25.515 [INFO ] [g.eclipse.smarthome.model.script.test] - (id,name) = (2,Vinyl FM)
05:50:25.524 [INFO ] [g.eclipse.smarthome.model.script.test] - (id,name) = (3,Rockklassiker)
05:50:25.532 [INFO ] [g.eclipse.smarthome.model.script.test] - (id,name) = (4,Bandit Rock)
05:50:36.347 [INFO ] [smarthome.event.ItemStateChangedEvent] - g1_Innetemp changed from 15.25 to 15.37
I just figured it out I was a littlebit tired maybe. Just nedd to figure out the best trigger for it all, maybe best practice woulde be when players.favorite changed if polayer.favorite.state.asstring not equal to null?
‘’
rule “favorite name”
when
Item squeezeKokPlay changed //player name
then
if(squeezeKokPlay.state==ON){
val String theOne = squeezekokfavorite.state.toString
for(String favorite : squeezefavorite.state.toString.split(",")) { //LMS server favoriteslits channel
val String[] fav = favorite.split("=")
val String id = fav.get(0)
val String name = fav.get(1)
logInfo("test", "(id,name) = ({},{})", id, name)
if (theOne.equals(id)) {
sendBroadcastNotification("Du lyssnar på " + name +" i köket " + "Utomhustemperaturen just nu " + gT_Utetemp.state + "°C") // Do something with name
}
}
}
end