Http binding with channels or rules

OpenHAB version: 4.1
Openhabian RPI 4b

I have one Ethernet controller relay card like the link below

I can control it by commads like this (relay 1 - on)
curl -X GET http://192.168.0.73/30000/01
In a DSL rule give this

sendHttpGetRequest("http://192.168.0.73/30000/01")

In a ECMEscript.

var HttpUtil        = Java.type("org.openhab.core.io.net.http.HttpUtil")
var url = "http://192.168.0.73/30000/01"
HttpUtil.executeUrl("GET", "http://192.168.0.73/30000/00",2000 )

But there is also with the http binding the possiblility to add an item and then add channels for the 16 relays with a switch. On value “01” Off value 00
Is this possible with this type of hardware because I don’t succee in configuring these channels?
Is there an example?

I can add metadata and a rule for a certain group. But what would be the best approach?

Pieter

As Port 30000 is mentioned in the text, I would expect http://192.1168.0.73:30000/01 rather than http://192.1168.0.73/30000/01, but maybe they’re not that deep into coding…

Is there any additional documentation other than the text at aliexpress?
A http binding configuration should look like this (using port 80, not 30000 :wink: ):

UID: http:url:relays
label: 16 Channel Relay Board
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: http://192.168.0.73/30000/
  delay: 0
  stateMethod: GET
  refresh: 30
  commandMethod: GET
  timeout: 3000
  bufferSize: 2048
channels:
  - id: ch01
    channelTypeUID: http:switch
    label: Channel 01
    description: ""
    configuration:
      onValue: "01"
      mode: WRITEONLY
      offValue: "00"
      commandExtension: "%2$s"
  - id: ch02
    channelTypeUID: http:switch
    label: Channel 02
    description: ""
    configuration:
      onValue: "03"
      mode: WRITEONLY
      offValue: "02"
      commandExtension: "%2$s"
  - id: ch03
    channelTypeUID: http:switch
    label: Channel 03
    description: ""
    configuration:
      onValue: "05"
      mode: WRITEONLY
      offValue: "04"
      commandExtension: "%2$s"

Is there an option to get the current state of one/all relays? Is there a way to control all relays at once?

Yes that “:” or “/” has taken me also some time.
I’ll try to create the same items
30000 is the default I didn’t change it to avoid problems.
But I can change IP and port .
I have no other documentation found.

30000/99 → Gives 00001000 and so 16 digits depending on the relay and a 0 for off and 1 for on
So for this relay 5 on and the others off

30000/44 all of
30000/45 all on

These channels do the trick.
Thank you

1 Like

So there is a chance to get the real state. Will be more tricky, though, because onValue and offValue can’t be set individually for state and command.
e.g.

stateExtension: 99
mode: READWRITE
stateTransformation: 'DSL:|if(input.subString(1,1) == "0") "02" else "03"' // for channel 2

but I did not check whether this is the correct code :wink: The idea is, to get the (n)th character from the output of baseUrl/99, then check if it’s 0 or 1 and set the fitting on/offValue (which is different for each channel…)
Maybe with some additional scripting (for command as well) there is a chance to get one parametrized script for each direction, which is then valid for all channels, but I’m not very deep into these scripts.

I understand the idea. But I don’t see how I can implement your suggestion or what this means with the difference between command and state.
I have a script that send that “99”. With some lines, I can strip that html respons to the 16 digits.
Then it is possible to update the items. The things seems difficult because it is writeonly and the items of those don’t update.

Channels are stateless (at least sort of). Communication between external systems and openHAB has two directions, and openHAB is (per definition) the master, so openHAB commands the external systems, while the external systems tell openHAB states. Of course, there are some cases which differ :slight_smile:

So, there is no real need to use the channels to get the states.