OH3 - Send http command to Ethernet Module with Relays

Hi guys,

question from an absolute beginner, struggling with http…
Sending http://192.168.0.50/io.cgi?DOA2=10 activates a port on an ethernet module with relay for 1 sec.
I would like to have a pushbutton to send this request but can’t find the right setting. :frowning:

Created a thing wit base url: http://192.168.0.50 and then added channels with the extension /io.cgi?DOA2=10.
Created an item as switch, didn’t work, then as string, didn’t work.
Has anyone a simple example/procedure on how to set this up?

Thanks,
P.

No, but if you post your config we can probably tell you where things went wrong. There are a ton of details to get right when using a low level binding like this.
Please click the code tab and post the text code using code fences.

```
code goes here
```

Hi Rich,

These are the settings. This is a relay switch with 8 ports ( ETH008 )were I tried 2 different settings on 2 ports, port 1 as switch, port 2 as string.

Thing.

UID: http:url:7ee15f0fd9
label: "- HTTP URL Thing - "
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: 192.168.0.51
  delay: 0
  stateMethod: GET
  refresh: 30
  commandMethod: GET
  timeout: 3000
  bufferSize: 2048
channels:
  - id: P1
    channelTypeUID: http:switch
    label: Port 1
    description: ""
    configuration:
      onValue: /io.cgi?DOA1=10
      offValue: /io.cgi?DOA1=10
  - id: P2
    channelTypeUID: http:string
    label: Port 2
    description: ""
    configuration:
      commandExtension: /io.cgi?DOA2=10

Then

component: oh-toggle-card
config:
  title: Port 1
  item: HTTPURLThing_Port1

and for port 2

component: oh-label-card
config:
  title: Port 2
  action: options
  actionItem: HTTPURLThing_Port2
  actionOptions: /io.cgi?DOA2=10
  label: Port 2

Also tried a script.

events.sendCommand('TestETH008_Port2', 'http://192.168.0.51/io.cgi?DOA2=10');

Thanks!

Alright, so you’ve “hard-wired” those values into your Thing/channel. Looks sensible.

But you’ve already hard-wired those values into your Thing/channel.

What kind of Item is that? Switch types will not like you commanding anything than ON/OFF

Just need to send out the URL command on my home network, URL: http://192.168.0.51/io.cgi?DOA2=10 tells to a relay switch box to close relay n° 2 for 1 second. I use it on some lights with pushbuttons, it simulates me pushing the lights pushbutton.

also tried:

events.sendCommand('TestETH008_Port2', '/io.cgi?DOA2=10');

Tried it with a switch because I don’t get a pushbutton to work.

You are not using this like OH is deigned to work. Your Thing is defined using an http:switch Channel. That must be linked to a Switch Item. A Switch Item can only accept ON and OFF as a command.

The Thing is/should be where that ON and OFF are translated to to a URL and HTTP call. And that appears to be what you’ve done, or at least attempted. So your widgets will all work with a Switch. In your rules, when you command the Item you will only send ON and OFF as commands.

Thanks Rich, got it working

Patrick