HTTP switch channel configuration

Platform information:
    Hardware: Raspberry Pi 3 Model B
    openHAB version: OpenHAB 3

OK I’m giving up. Throws the towel in the ring,and seeks help in this forum.
I have a music player where to send html commands to start playback or pause it.
The player, along with several other players, is connected to a server at the base URL: http://192.168.1.235:9000. Since there are several players, the MAC address of the player must be entered in the command.
The commands are: /status.html?p0=play&player=00:04:20:06:9e:e5
and: /status.html?p0=pause&player=00:04:20:06:9e:e5.

I have imagined that this could be done using a HTTP switch, but I have serious troubles (= I have no idea about how to do it) with configuration of the channel. The log viewer shows that the problem is the command transformation.

The HTTP switch is made using Openhab UI.

I hope that someone reading this post will take the time to help an old man, and please don’t just link to Openhab tutorials. I have tried to read them several times but I still not know what to do.

UID: http:url:Max2Play_Radio
label: Max2Play Radio
thingTypeUID: http:url
configuration:
authMode: BASIC
ignoreSSLErrors: false
baseURL: http://192.168.1.235:9000
delay: 0
stateMethod: GET
refresh: 30
commandMethod: GET
contentType: text/html
timeout: 3000
bufferSize: 2048
location: Spisestue
channels:

  • id: Max2Play_Radio
    channelTypeUID: http:switch
    label: Max2Play Radio
    description: “”
    configuration:
    onValue: play
    offValue: pause
    commandTransformation: (which information shall I fill in this??)

This is empty - do you mean for it to be empty?

I know it is empty. It is because everything I have tried to type so far is not working. I’m asking for help to fill that info.

OK, understood. And you’ve made a separate Thing for each of your players, or at least a separate Channel in the same Thing?

What data does your player return when you command it to play or pause?

Either way, the missing bit should say

commandTransformation: /status.html?p0=%2$s&player=00:04:20:06:9e:e5

assuming this Channel is correctly linked to a Switch Item. The syntax above is derived from the URL Formatting section of the documentation for this binding.

You’ll need the same configuration with the different MAC in a different Channel for the other player.

as to my understanding transformation is for changing incoming values (initiated by an http request). What I undestand what you want to acieve is not to get the state of that device (stopped or playing), you want to send commands (play / stop) to that device, right?
In this case you could also simply create a rule with this command:

sendHttpGetRequest("http://192.168.1.235:9000/status.html?p0=play&player=00:04:20:06:9e:e5")

Not the commandTransformation - that’s for outgoing. And onValue and offValue are bi-directional.

ok. thanks

On a completely different note: Max2Play uses a Squeezebox server internally. Tried using the Squeezebox binding already? :wink:

Under the “Advanced settings” I found af Play/ Pause switch in the Squeezebox binding.