This widget has been developed for Squeezebox, but should work with any media control. You will need to update the PREVIOUS command in the widget code to suit your binding.
Pre-requisites:
- For the album art to work with Squeezebox you’ll need to update your binding to the 2.3.0 snapshot version. I built the jar file based on OH Github. Once I sort out my home server I will link to it from here.
- To get Spotify stations working with the Spotty plugin on Squeezebox, make sure you’re using a recent release. I used 7.9.1 from the nightly build server.
- You will need to create an audio.rules file (actually, any .rules file is fine, I just like to keep things separate)
In the rules file you create your stations. URLs and Squeezebox MAC addresses need to be Encoded using something like https://www.urlencoder.org/ and added to the appropriate variables
import org.openhab.core.library.types.*
import org.openhab.model.script.actions.*
import org.openhab.action.squeezebox.*
var squeezeServer = "http://192.168.3.11:9000/status.html?p0=playlist&p1=play&p2="
var String kitchenPlaylist
var string squeezeplayer = "b8%3A27%3Aeb%3Ab1%3A54%3Af6"
var String station1 = "randomplay%3A%2F%2Ftrack"
var String station2 = "http%3A%2F%2Fopml.radiotime.com%2FTune.ashx%3Fid%3Ds24939%26formats%3Daac%2Cogg%2Cmp3%2Cwmpro%2Cwma%2Cwmvoice%26partnerId%3D16%26serial%3D1aecf10be8fd71e50285a088058a7a49"
var String station3 = "spotify%3Auser%3Aspotify%3Aplaylist%3A37i9dQZF1DXeby79pVadGa"
var String station4 = "spotify%3Auser%3Aspotify%3Aplaylist%3A37i9dQZF1DWXF8Nf1uycDZ"
rule "Kitchen Playlist"
when
Item KitchenMusicPlaylist received update
then
switch (KitchenMusicPlaylist.state) {
case 0 :
kitchenPlaylist = "off"
case 1 :
kitchenPlaylist = station1
case 2 :
kitchenPlaylist = station2
case 3 :
kitchenPlaylist = station3
case 4 :
kitchenPlaylist = station4
}
logInfo("squeezeplaylist.rules",kitchenPlaylist)
if (kitchenPlaylist == "off") {
logInfo("squeezeplaylist.rules","Playlist Off")
KitchenMusicPower.sendCommand(OFF)
}
else {
if(KitchenMusicPower.state = OFF){
KitchenMusicPower.sendCommand(ON)
}
var playlistURL = squeezeServer + kitchenPlaylist + "&player=" + squeezeplayer
logInfo("squeezeplaylist.rules",playlistURL)
sendHttpGetRequest(playlistURL)
}
end
Then load in the widget and configure with your items.
Although it seems to render well (ok, acceptably) on my laptop, it’s not so good on my Nexus 7. I’m a bit of a hack when it comes to CSS so I need to work (or have assistance on) the centering of the play/skip icons and making the circles round. I’m also not overly happy with the volume control or stations so will work on making that look a little bit better.
SqueezePlayer.widget.json (6.3 KB)
Enjoy!