Squeezebox controller widget

Hi,

I created a small widgetto control my Squeezeboxes around the house and thought it might be of interest to others too. It offers most of the player controls that are available (play/pause, power, repeat mode, volume control). In addition it show progress of current song and queries the server for the track length (which isn’t available through the binding), this also shows a method to fetch basically all the data that the server has via a json rpc api. I know it isn’t very good code, but I’m not a good coder, and the thing works :slight_smile: It’s made for a 1920x1080 screen and doesn’t scale down very nicely. Maybe someone might like to develop it further?
Squeezbox_controller
SqueezeboxController.widget.json (8.6 KB)

Rule for track duration:

rule "BedroomPlayerData"
when
    Item SqueezeLiteBedroom_Title changed
then
	logInfo("Squeezebox", "Title change")
	val myURL = 'http://x.x.x.x:9000/jsonrpc.js'
	val payload = '{"id":1,"method":"slim.request","params":["00:00:00:00:00:01",["duration","?"]]}'
	val String json = sendHttpPostRequest(myURL, "application/json", payload)
	SqueezeLiteBedroom_CurrentTrackLength.postUpdate(Float.valueOf(transform("JSONPATH", "$.result._duration", json)))
	logInfo("Squeezebox", "Track length: " + SqueezeLiteBedroom_CurrentTrackLength.state + " seconds.")
end

replace x.x.x.x with the ip of your server and 00:00:00:00:00:01 with the mac address of your squeezebox. It sometimes takes a few seconds for the new track length to come through.

1 Like

Nice work.

FYI, the duration channel is supposed to provide the length (in seconds) of the currently playing track.

Edit: Hmm. It looks like someone forgot to add the duration channel to the documentation. :roll_eyes: :blush:

Looks good!

Fixing documentation…

Yeah, I thought that I made a request for it sometime in the past and that it was added. I couldn’t find it in paperUi though, so I came up with an alternative solution :wink:

If you haven’t deleted and rediscovered the player Thing since the channel was added (over a year ago), you might need to delete/rediscover the player Thing to make the channel show up.

Yep, haven’t done that, explains it missing then.

Hello,

I tried to use your widget, but some things works, but the title , Artist from the settings are not used anywhere ?!

Is there a Update of this widget ?

Thanks

Regards
Thorsten