OpenHAB2: HTTP Binding help

Hello to all,

I’m trying to POST some values to an IP-CAM to enable and disable the Motion Detection. Until here all OK! I’m able to do it definig this item:

Switch          IPCam01_MDetect                         "Motion Detection - Soggiorno"                  { http=">[ON:POST:http://<MY-IP>/web/cgi-bin/hi3510/param.cgi?cmd=setmdattr&-name=1&-enable=1{Authorization=Basic MY-KEY}] >[OFF:POST:http://<MY-IP>/web/cgi-bin/hi3510/param.cgi?cmd=setmdattr&-name=1&-enable=0{Authorization=Basic MY-KEY}]" }

Now, I need to query the content of a post and map it to the switch, because the motion could be enabled/disabled from the IP-CAM interface as well. From cli, I can query the cam as follow:

 #curl --data "cmd=getmdattr" http://<user>:<pass>@<IP-CAM>/web/cgi-bin/hi3510/param.cgi -vvv

And the output is this:

Hostname was NOT found in DNS cache
*   Trying <CAM-IP>...
* Connected to <CAM-IP> port 80 (#0)
* Server auth using Basic with user 'admin'
> POST /web/cgi-bin/hi3510/param.cgi HTTP/1.1
> Authorization: Basic MY-KEY
> User-Agent: curl/7.38.0
> Host: <CAM-IP>
> Accept: */*
> Content-Length: 13
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 13 out of 13 bytes
< HTTP/1.1 200 OK
* Server Hipcam is not blacklisted
< Server: Hipcam
< Cache-Control: no-cache
< Content-Type:text/html
< Connection: close
< Content-Length: 544
< 
var m1_enable="0";
var m1_x="0";
var m1_y="50";
var m1_w="1280";
var m1_h="670";
var m1_sensitivity="50";
var m1_threshold="0";
var m2_enable="0";
var m2_x="1120";
var m2_y="0";
var m2_w="160";
var m2_h="160";
var m2_sensitivity="50";
var m2_threshold="0";
var m3_enable="0";
var m3_x="0";
var m3_y="560";
var m3_w="160";
var m3_h="160";
var m3_sensitivity="50";
var m3_threshold="0";
var m4_enable="0";
var m4_x="1120";
var m4_y="560";
var m4_w="160";
var m4_h="160";
var m4_sensitivity="50";
var m4_threshold="0";
* Closing connection 0

What I need to get and MAP is the valie of m1_enable. If it’s m1_enable=0 the switch should be OFF, otherwise if m1_enable=1 then the switch should be ON.

Can someone help me with this?

Thanks!

Simon

Use the REGEX transformation…

Switch IPCam01_MDetect "Motion Detection - Soggiorno [%s]" { http=">[ON:POST:http://<MY-IP>/web/cgi-bin/hi3510/param.cgi?cmd=setmdattr&-name=1&-enable=1{Authorization=Basic MY-KEY}] >[OFF:POST:http://<MY-IP>/web/cgi-bin/hi3510/param.cgi?cmd=setmdattr&-name=1&-enable=0{Authorization=Basic MY-KEY}] <[http://<MY-IP>/web/cgi-bin/hi3510/param.cgi?cmd=getmdattr{Authorization=Basic MY-KEY}:30000:REGEX(.*m1_enable=.(?).*)]" }

I’m pretty sure 0 and 1 are directly transformed to OFF and ON. If not, you can try javascript transformation.

http://docs.openhab.org/addons/transformations.html

Hello @Udo_Hartmann , thanks for the answer.
BTW I’m getting this error:

 2017-08-07 17:19:16.045 [INFO ] [.internal.RegExTransformationService] - the given regular expression '^.*m1_enable=.(?).*$' doesn't contain a group. No content will be extracted and returned!

Then, I’ve noticed that I need to make a POST HTTP to get the values, I’ve tried this way, but seems not to work:

{ http=">[ON:POST:http://<CAM-IP>/web/cgi-bin/hi3510/param.cgi?cmd=setmdattr&-name=1&-enable=1{Authorization=Basic <CAM-KEY>}] >[OFF:POST:http://<CAM-IP>/web/cgi-bin/hi3510/param.cgi?cmd=setmdattr&-name=1&-enable=0{Authorization=Basic <CAM-KEY>}] <[*:POST:http://<CAM-IP>/web/cgi-bin/hi3510/param.cgi?cmd=getmdattr{Authorization=Basic <CAM-KEY>}:10000:REGEX(.*m1_enable=.(?).*)]"}

Ideas?

Thanks!

Simon

argh… sorry should be

REGEX(.*m1_enable=.(.).*)

Ok @Udo_Hartmann , now I don’t get any error.
BTW the item is not updated. Is there a way to debug these calls?
Thanks a lot!
Simon

Sorry @Udo_Hartmann, I’ve made some step further.
I’ve used tcpdump to check if http requests are at least sent out to get the value status. The status is a different URL (getmdattr instead of setmdattr), so I can look if the URL is at least called.
Those are sent out well, also the syntax as written by you is ok (I’ve corrected only a little error I’ve made).
BTW I cannot get the values into the Item. The REGEX should be ok as well (AFAYK).
Maybe it’s a MAP issue, but I would like to debug the incoming answer to understand why it’s not mapped correctly to the item.
Any idea?
Thanks!
Simon

Well @Udo_Hartmann I think I’m really near to the solution.
I’m not able to use map.
I was able to tcpdump the requests and DEBUG from the console the log.
From the logs I get the http response and the error:

2017-08-08 16:01:03.147 [DEBUG] [he.commons.httpclient.HttpMethodBase] - Should close connection in response to directive: close
2017-08-08 16:01:03.151 [DEBUG] [he.commons.httpclient.HttpConnection] - Releasing connection back to connection manager.
2017-08-08 16:01:03.158 [DEBUG] [ab.binding.http.internal.HttpBinding] - transformed response is '1'
2017-08-08 16:01:03.163 [DEBUG] [ab.binding.http.internal.HttpBinding] - Couldn't create state for item 'IPCam02_MDetect' from string '1'

I’ve tried defining the Item as follow, but the map doesn’t work:

Switch          IPCam01_MDetect                         "Motion Detection - Soggiorno [MAP(1on0off.map):%d]"     { http=">[ON:POST:(....)

where 1on0off.map conains:

# cat 1on0off.map        
1=ON
0=OFF

What I’m making wrong?

Thanks!

Simon

Well, seems openHAB can’t make an ON/OFF out of 1/0… sooo…
.items

Switch IPCam01_MDetect "Motion Detection - Soggiorno [%s]" { http=">[ON:POST:http://<MY-IP>/web/cgi-bin/hi3510/param.cgi?cmd=setmdattr&-name=1&-enable=1{Authorization=Basic MY-KEY}] >[OFF:POST:http://<MY-IP>/web/cgi-bin/hi3510/param.cgi?cmd=setmdattr&-name=1&-enable=0{Authorization=Basic MY-KEY}] <[http://<MY-IP>/web/cgi-bin/hi3510/param.cgi?cmd=getmdattr{Authorization=Basic MY-KEY}:30000:JS(getOnOff.js)]" }

scripts/getOnOff.js

(function(i) {
    var re = new RegExp('.*m1_enable=.(.).*');
    var out = re.exec(i);
    return if(out=="1") ON else OFF;
})(input)

As I’m not very familiar with Java Script, there might be an error in getOnOff.js

Again thank you @Udo_Hartmann for the help.
It seems there is an error on the script, but javascript is something not familiar for me as well.

Here the output:

 2017-08-09 10:04:40.358 [ERROR] [ab.binding.http.internal.HttpBinding] - Transformation 'JS(getOnOff.js)' threw an exception. [response=var m1_enable="1";
var m1_x="0";
var m1_y="50";
var m1_w="1280";
var m1_h="670";
var m1_sensitivity="50";
var m1_threshold="0";
var m2_enable="0";
var m2_x="1120";
var m2_y="0";
var m2_w="160";
var m2_h="160";
var m2_sensitivity="50";
var m2_threshold="0";
var m3_enable="0";
var m3_x="0";
var m3_y="560";
var m3_w="160";
var m3_h="160";
var m3_sensitivity="50";
var m3_threshold="0";
var m4_enable="0";
var m4_x="1120";
var m4_y="560";
var m4_w="160";
var m4_h="160";
var m4_sensitivity="50";
var m4_threshold="0";
]
org.openhab.core.transform.TransformationException: An error occurred while loading script.
        at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:62)[176:org.openhab.core.compat1x:2.2.0.201707122217]
        at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:189)[202:org.openhab.binding.http:1.11.0.201708050109]
        at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:157)[176:org.openhab.core.compat1x:2.2.0.201707122217]
        at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169)[176:org.openhab.core.compat1x:2.2.0.201707122217]
2017-08-09 10:04:40.361 [DEBUG] [ab.binding.http.internal.HttpBinding] - transformed response is 'var m1_enable="1";
var m1_x="0";
var m1_y="50";
var m1_w="1280";
var m1_h="670";
var m1_sensitivity="50";
var m1_threshold="0";
var m2_enable="0";
var m2_x="1120";
var m2_y="0";
var m2_w="160";
var m2_h="160";
var m2_sensitivity="50";
var m2_threshold="0";
var m3_enable="0";
var m3_x="0";
var m3_y="560";
var m3_w="160";
var m3_h="160";
var m3_sensitivity="50";
var m3_threshold="0";
var m4_enable="0";
var m4_x="1120";
var m4_y="560";
var m4_w="160";
var m4_h="160";
var m4_sensitivity="50";
var m4_threshold="0";
'
2017-08-09 10:04:40.362 [DEBUG] [ab.binding.http.internal.HttpBinding] - Couldn't create state for item 'IPCam02_MDetect' from string 'var m1_enable="1";
var m1_x="0";
var m1_y="50";
var m1_w="1280";
var m1_h="670";
var m1_sensitivity="50";
var m1_threshold="0";
var m2_enable="0";
var m2_x="1120";
var m2_y="0";
var m2_w="160";
var m2_h="160";
var m2_sensitivity="50";
var m2_threshold="0";
var m3_enable="0";
var m3_x="0";
var m3_y="560";
var m3_w="160";
var m3_h="160";
var m3_sensitivity="50";
var m3_threshold="0";
var m4_enable="0";
var m4_x="1120";
var m4_y="560";
var m4_w="160";
var m4_h="160";
var m4_sensitivity="50";
var m4_threshold="0";
'

Someone has an idea? :slight_smile:

Could it be because this regex has a netsted result? Testing it online I get a two group result.

Thanks!!

Simon

Please try this… :slight_smile:

(function(i) {
    var re = new RegExp('.*m1_enable=.(.).*');
    var out = i.replace("$1");
    return if(out=="1") ON else OFF;
})(input)

Nope :disappointed_relieved:

I’re restarted OH2 as well to be sure it’s correctly loaded.

Switch          IPCam01_MDetect                         "Motion Detection - Soggiorno [%s]"                     { http=">[ON:POST:http://<CAM-IP>/web/cgi-bin/hi3510/param.cgi?cmd=setmdattr&-name=1&-enable=1{Authorization=Basic YWRtaW46Yms4NjdzbXhlZmls}] >[OFF:POST:http://<CAM-IP>/web/cgi-bin/hi3510/param.cgi?cmd=setmdattr&-name=1&-enable=0{Authorization=Basic YWRtaW46Yms4NjdzbXhlZmls}] <[http://<CAM-IP>/web/cgi-bin/hi3510/param.cgi?cmd=getmdattr{Authorization=Basic YWRtaW46Yms4NjdzbXhlZmls}:12000:JS(getOnOff.js)]" }

 # cat getOnOff.js 
(function(i) {
    var re = new RegExp('.*m1_enable=.(.).*');
    var out = i.replace("$1");
    return if(out=="1") ON else OFF;
})(input)

Response:

2017-08-10 11:07:43.987 [DEBUG] [ab.binding.http.internal.HttpBinding] - item 'IPCam01_MDetect' is about to be refreshed now
2017-08-10 11:07:43.988 [DEBUG] [.httpclient.params.DefaultHttpParams] - Set parameter http.socket.timeout = 5000
2017-08-10 11:07:43.989 [DEBUG] [.httpclient.params.DefaultHttpParams] - Set parameter http.method.retry-handler = org.apache.commons.httpclient.DefaultHttpMethodRetryHandler@8c2ed9
2017-08-10 11:07:43.990 [DEBUG] [he.commons.httpclient.HttpConnection] - Open connection to <CAM-IP>:80
2017-08-10 11:07:43.996 [DEBUG] [httpclient.wire.header              ] - >> "GET /web/cgi-bin/hi3510/param.cgi?cmd=getmdattr HTTP/1.1[\r][\n]"
2017-08-10 11:07:43.998 [DEBUG] [he.commons.httpclient.HttpMethodBase] - Adding Host request header
2017-08-10 11:07:43.999 [DEBUG] [httpclient.wire.header              ] - >> "Authorization: Basic YWRtaW46Yms4NjdzbXhlZmls[\r][\n]"
2017-08-10 11:07:44.000 [DEBUG] [httpclient.wire.header              ] - >> "User-Agent: Jakarta Commons-HttpClient/3.1[\r][\n]"
2017-08-10 11:07:44.001 [DEBUG] [httpclient.wire.header              ] - >> "Host: <CAM-IP>[\r][\n]"
2017-08-10 11:07:44.001 [DEBUG] [httpclient.wire.header              ] - >> "[\r][\n]"
2017-08-10 11:07:44.009 [DEBUG] [httpclient.wire.header              ] - << "HTTP/1.1 200 OK[\r][\n]"
2017-08-10 11:07:44.010 [DEBUG] [httpclient.wire.header              ] - << "HTTP/1.1 200 OK[\r][\n]"
2017-08-10 11:07:44.011 [DEBUG] [httpclient.wire.header              ] - << "Server: Hipcam[\r][\n]"
2017-08-10 11:07:44.012 [DEBUG] [httpclient.wire.header              ] - << "Cache-Control: no-cache[\r][\n]"
2017-08-10 11:07:44.013 [DEBUG] [httpclient.wire.header              ] - << "Content-Type:text/html[\r][\n]"
2017-08-10 11:07:44.014 [DEBUG] [httpclient.wire.header              ] - << "Connection: close[\r][\n]"
2017-08-10 11:07:44.014 [DEBUG] [httpclient.wire.header              ] - << "Content-Length: 545[\r][\n]"
2017-08-10 11:07:44.015 [DEBUG] [httpclient.wire.header              ] - << "[\r][\n]"
2017-08-10 11:07:44.016 [DEBUG] [httpclient.wire.content             ] - << "    var m1_enable="1";[\r][\n]"
2017-08-10 11:07:44.017 [DEBUG] [httpclient.wire.content             ] - << "    var m1_x="30";[\r][\n]"
2017-08-10 11:07:44.018 [DEBUG] [httpclient.wire.content             ] - << "    var m1_y="31";[\r][\n]"
2017-08-10 11:07:44.018 [DEBUG] [httpclient.wire.content             ] - << "    var m1_w="1214";[\r][\n]"
2017-08-10 11:07:44.019 [DEBUG] [httpclient.wire.content             ] - << "    var m1_h="667";[\r][\n]"
2017-08-10 11:07:44.019 [DEBUG] [httpclient.wire.content             ] - << "    var m1_sensitivity="50";[\r][\n]"
2017-08-10 11:07:44.020 [DEBUG] [httpclient.wire.content             ] - << "    var m1_threshold="0";[\r][\n]"
2017-08-10 11:07:44.021 [DEBUG] [httpclient.wire.content             ] - << "    var m2_enable="0";[\r][\n]"
2017-08-10 11:07:44.021 [DEBUG] [httpclient.wire.content             ] - << "    var m2_x="1120";[\r][\n]"
2017-08-10 11:07:44.022 [DEBUG] [httpclient.wire.content             ] - << "    var m2_y="0";[\r][\n]"
2017-08-10 11:07:44.022 [DEBUG] [httpclient.wire.content             ] - << "    var m2_w="160";[\r][\n]"
2017-08-10 11:07:44.023 [DEBUG] [httpclient.wire.content             ] - << "    var m2_h="160";[\r][\n]"
2017-08-10 11:07:44.023 [DEBUG] [httpclient.wire.content             ] - << "    var m2_sensitivity="50";[\r][\n]"
2017-08-10 11:07:44.024 [DEBUG] [httpclient.wire.content             ] - << "    var m2_threshold="0";[\r][\n]"
2017-08-10 11:07:44.025 [DEBUG] [httpclient.wire.content             ] - << "    var m3_enable="0";[\r][\n]"
2017-08-10 11:07:44.025 [DEBUG] [httpclient.wire.content             ] - << "    var m3_x="0";[\r][\n]"
2017-08-10 11:07:44.026 [DEBUG] [httpclient.wire.content             ] - << "    var m3_y="560";[\r][\n]"
2017-08-10 11:07:44.026 [DEBUG] [httpclient.wire.content             ] - << "    var m3_w="160";[\r][\n]"
2017-08-10 11:07:44.027 [DEBUG] [httpclient.wire.content             ] - << "    var m3_h="160";[\r][\n]"
2017-08-10 11:07:44.027 [DEBUG] [httpclient.wire.content             ] - << "    var m3_sensitivity="50";[\r][\n]"
2017-08-10 11:07:44.028 [DEBUG] [httpclient.wire.content             ] - << "    var m3_threshold="0";[\r][\n]"
2017-08-10 11:07:44.029 [DEBUG] [httpclient.wire.content             ] - << "    var m4_enable="0";[\r][\n]"
2017-08-10 11:07:44.029 [DEBUG] [httpclient.wire.content             ] - << "    var m4_x="1120";[\r][\n]"
2017-08-10 11:07:44.030 [DEBUG] [httpclient.wire.content             ] - << "    var m4_y="560";[\r][\n]"
2017-08-10 11:07:44.030 [DEBUG] [httpclient.wire.content             ] - << "    var m4_w="160";[\r][\n]"
2017-08-10 11:07:44.031 [DEBUG] [httpclient.wire.content             ] - << "    var m4_h="160";[\r][\n]"
2017-08-10 11:07:44.031 [DEBUG] [httpclient.wire.content             ] - << "    var m4_sensitivity="50";[\r][\n]"
2017-08-10 11:07:44.032 [DEBUG] [httpclient.wire.content             ] - << "    var m4_threshold="0";[\r][\n]"
2017-08-10 11:07:44.033 [DEBUG] [he.commons.httpclient.HttpMethodBase] - Should close connection in response to directive: close
2017-08-10 11:07:44.034 [DEBUG] [he.commons.httpclient.HttpConnection] - Releasing connection back to connection manager.
2017-08-10 11:07:44.036 [ERROR] [ab.binding.http.internal.HttpBinding] - Transformation 'JS(getOnOff.js)' threw an exception. [response=    var m1_enable="1";
var m1_x="30";
var m1_y="31";
var m1_w="1214";
var m1_h="667";
var m1_sensitivity="50";
var m1_threshold="0";
var m2_enable="0";
var m2_x="1120";
var m2_y="0";
var m2_w="160";
var m2_h="160";
var m2_sensitivity="50";
var m2_threshold="0";
var m3_enable="0";
var m3_x="0";
var m3_y="560";
var m3_w="160";
var m3_h="160";
var m3_sensitivity="50";
var m3_threshold="0";
var m4_enable="0";
var m4_x="1120";
var m4_y="560";
var m4_w="160";
var m4_h="160";
var m4_sensitivity="50";
var m4_threshold="0";
]
org.openhab.core.transform.TransformationException: An error occurred while loading script.
        at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:62)[176:org.openhab.core.compat1x:2.2.0.201707122217]
        at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:189)[202:org.openhab.binding.http:1.11.0.201708050109]
        at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:157)[176:org.openhab.core.compat1x:2.2.0.201707122217]
        at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169)[176:org.openhab.core.compat1x:2.2.0.201707122217]
2017-08-10 11:07:44.039 [DEBUG] [ab.binding.http.internal.HttpBinding] - transformed response is '    var m1_enable="1";
var m1_x="30";
var m1_y="31";
var m1_w="1214";
var m1_h="667";
var m1_sensitivity="50";
var m1_threshold="0";
var m2_enable="0";
var m2_x="1120";
var m2_y="0";
var m2_w="160";
var m2_h="160";
var m2_sensitivity="50";
var m2_threshold="0";
var m3_enable="0";
var m3_x="0";
var m3_y="560";
var m3_w="160";
var m3_h="160";
var m3_sensitivity="50";
var m3_threshold="0";
var m4_enable="0";
var m4_x="1120";
var m4_y="560";
var m4_w="160";
var m4_h="160";
var m4_sensitivity="50";
var m4_threshold="0";
'
2017-08-10 11:07:44.040 [DEBUG] [ab.binding.http.internal.HttpBinding] - Couldn't create state for item 'IPCam01_MDetect' from string '    var m1_enable="1";
var m1_x="30";
var m1_y="31";
var m1_w="1214";
var m1_h="667";
var m1_sensitivity="50";
var m1_threshold="0";
var m2_enable="0";
var m2_x="1120";
var m2_y="0";
var m2_w="160";
var m2_h="160";
var m2_sensitivity="50";
var m2_threshold="0";
var m3_enable="0";
var m3_x="0";
var m3_y="560";
var m3_w="160";
var m3_h="160";
var m3_sensitivity="50";
var m3_threshold="0";
var m4_enable="0";
var m4_x="1120";
var m4_y="560";
var m4_w="160";
var m4_h="160";
var m4_sensitivity="50";
var m4_threshold="0";
'

oh no, forgot to use the var :hushed:

function(i) {
    var re = new RegExp('.*m1_enable=.(.).*');
    var out = i.replace(re, "$1");
    return if(out=="1") ON else OFF;
})(input)

Nope @Udo_Hartmann :’(

Restarted Openhab2 as well.

# cat getOnOff.js
    (function(i) {
    var re = new RegExp('.*m1_enable=.(.).*');
    var out = i.replace(re, "$1");
    return if(out=="1") ON else OFF;
})(input)

Could it possible it ha ssomething to do with the newline of the response or strange characters like ";[\r][\n]" or the " ?

Debug result:

2017-08-10 15:19:51.339 [DEBUG] [he.commons.httpclient.HttpConnection] - Open connection to <CAM-IP>:80
2017-08-10 15:19:51.348 [DEBUG] [httpclient.wire.header              ] - >> "GET /web/cgi-bin/hi3510/param.cgi?cmd=getmdattr HTTP/1.1[\r][\n]"
2017-08-10 15:19:51.350 [DEBUG] [he.commons.httpclient.HttpMethodBase] - Adding Host request header
2017-08-10 15:19:51.351 [DEBUG] [httpclient.wire.header              ] - >> "Authorization: Basic YWRtaW46Yms4NjdzbXhlZmls[\r][\n]"
2017-08-10 15:19:51.352 [DEBUG] [httpclient.wire.header              ] - >> "User-Agent: Jakarta Commons-HttpClient/3.1[\r][\n]"
2017-08-10 15:19:51.353 [DEBUG] [httpclient.wire.header              ] - >> "Host: <CAM-IP>[\r][\n]"
2017-08-10 15:19:51.354 [DEBUG] [httpclient.wire.header              ] - >> "[\r][\n]"
2017-08-10 15:19:51.363 [DEBUG] [httpclient.wire.header              ] - << "HTTP/1.1 200 OK[\r][\n]"
2017-08-10 15:19:51.364 [DEBUG] [httpclient.wire.header              ] - << "HTTP/1.1 200 OK[\r][\n]"
2017-08-10 15:19:51.365 [DEBUG] [httpclient.wire.header              ] - << "Server: Hipcam[\r][\n]"
2017-08-10 15:19:51.366 [DEBUG] [httpclient.wire.header              ] - << "Cache-Control: no-cache[\r][\n]"
2017-08-10 15:19:51.367 [DEBUG] [httpclient.wire.header              ] - << "Content-Type:text/html[\r][\n]"
2017-08-10 15:19:51.368 [DEBUG] [httpclient.wire.header              ] - << "Connection: close[\r][\n]"
2017-08-10 15:19:51.369 [DEBUG] [httpclient.wire.header              ] - << "Content-Length: 545[\r][\n]"
2017-08-10 15:19:51.370 [DEBUG] [httpclient.wire.header              ] - << "[\r][\n]"
2017-08-10 15:19:51.371 [DEBUG] [httpclient.wire.content             ] - << "    var m1_enable="1";[\r][\n]"
2017-08-10 15:19:51.372 [DEBUG] [httpclient.wire.content             ] - << "    var m1_x="30";[\r][\n]"
2017-08-10 15:19:51.373 [DEBUG] [httpclient.wire.content             ] - << "    var m1_y="31";[\r][\n]"
2017-08-10 15:19:51.374 [DEBUG] [httpclient.wire.content             ] - << "    var m1_w="1214";[\r][\n]"
2017-08-10 15:19:51.375 [DEBUG] [httpclient.wire.content             ] - << "    var m1_h="667";[\r][\n]"
2017-08-10 15:19:51.375 [DEBUG] [httpclient.wire.content             ] - << "    var m1_sensitivity="50";[\r][\n]"
2017-08-10 15:19:51.376 [DEBUG] [httpclient.wire.content             ] - << "    var m1_threshold="0";[\r][\n]"
2017-08-10 15:19:51.377 [DEBUG] [httpclient.wire.content             ] - << "    var m2_enable="0";[\r][\n]"
2017-08-10 15:19:51.377 [DEBUG] [httpclient.wire.content             ] - << "    var m2_x="1120";[\r][\n]"
2017-08-10 15:19:51.378 [DEBUG] [httpclient.wire.content             ] - << "    var m2_y="0";[\r][\n]"
2017-08-10 15:19:51.379 [DEBUG] [httpclient.wire.content             ] - << "    var m2_w="160";[\r][\n]"
2017-08-10 15:19:51.380 [DEBUG] [httpclient.wire.content             ] - << "    var m2_h="160";[\r][\n]"
2017-08-10 15:19:51.380 [DEBUG] [httpclient.wire.content             ] - << "    var m2_sensitivity="50";[\r][\n]"
2017-08-10 15:19:51.381 [DEBUG] [httpclient.wire.content             ] - << "    var m2_threshold="0";[\r][\n]"
2017-08-10 15:19:51.382 [DEBUG] [httpclient.wire.content             ] - << "    var m3_enable="0";[\r][\n]"
2017-08-10 15:19:51.390 [DEBUG] [httpclient.wire.content             ] - << "    var m3_x="0";[\r][\n]"
2017-08-10 15:19:51.393 [DEBUG] [httpclient.wire.content             ] - << "    var m3_y="560";[\r][\n]"
2017-08-10 15:19:51.394 [DEBUG] [httpclient.wire.content             ] - << "    var m3_w="160";[\r][\n]"
2017-08-10 15:19:51.395 [DEBUG] [httpclient.wire.content             ] - << "    var m3_h="160";[\r][\n]"
2017-08-10 15:19:51.395 [DEBUG] [httpclient.wire.content             ] - << "    var m3_sensitivity="50";[\r][\n]"
2017-08-10 15:19:51.396 [DEBUG] [httpclient.wire.content             ] - << "    var m3_threshold="0";[\r][\n]"
2017-08-10 15:19:51.396 [DEBUG] [httpclient.wire.content             ] - << "    var m4_enable="0";[\r][\n]"
2017-08-10 15:19:51.397 [DEBUG] [httpclient.wire.content             ] - << "    var m4_x="1120";[\r][\n]"
2017-08-10 15:19:51.399 [DEBUG] [httpclient.wire.content             ] - << "    var m4_y="560";[\r][\n]"
2017-08-10 15:19:51.399 [DEBUG] [httpclient.wire.content             ] - << "    var m4_w="160";[\r][\n]"
2017-08-10 15:19:51.400 [DEBUG] [httpclient.wire.content             ] - << "    var m4_h="160";[\r][\n]"
2017-08-10 15:19:51.401 [DEBUG] [httpclient.wire.content             ] - << "    var m4_sensitivity="50";[\r][\n]"
2017-08-10 15:19:51.401 [DEBUG] [httpclient.wire.content             ] - << "    var m4_threshold="0";[\r][\n]"
2017-08-10 15:19:51.402 [DEBUG] [he.commons.httpclient.HttpMethodBase] - Should close connection in response to directive: close
2017-08-10 15:19:51.403 [DEBUG] [he.commons.httpclient.HttpConnection] - Releasing connection back to connection manager.
2017-08-10 15:19:51.405 [ERROR] [ab.binding.http.internal.HttpBinding] - Transformation 'JS(getOnOff.js)' threw an exception. [response=    var m1_enable="1";
var m1_x="30";
var m1_y="31";
var m1_w="1214";
var m1_h="667";
var m1_sensitivity="50";
var m1_threshold="0";
var m2_enable="0";
var m2_x="1120";
var m2_y="0";
var m2_w="160";
var m2_h="160";
var m2_sensitivity="50";
var m2_threshold="0";
var m3_enable="0";
var m3_x="0";
var m3_y="560";
var m3_w="160";
var m3_h="160";
var m3_sensitivity="50";
var m3_threshold="0";
var m4_enable="0";
var m4_x="1120";
var m4_y="560";
var m4_w="160";
var m4_h="160";
var m4_sensitivity="50";
var m4_threshold="0";
]
org.openhab.core.transform.TransformationException: An error occurred while loading script.
        at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:62)[176:org.openhab.core.compat1x:2.2.0.201707122217]
        at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:189)[202:org.openhab.binding.http:1.11.0.201708050109]
        at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:157)[176:org.openhab.core.compat1x:2.2.0.201707122217]
        at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169)[176:org.openhab.core.compat1x:2.2.0.201707122217]
2017-08-10 15:19:51.407 [DEBUG] [ab.binding.http.internal.HttpBinding] - transformed response is '    var m1_enable="1";
var m1_x="30";
var m1_y="31";
var m1_w="1214";
var m1_h="667";
var m1_sensitivity="50";
var m1_threshold="0";
var m2_enable="0";
var m2_x="1120";
var m2_y="0";
var m2_w="160";
var m2_h="160";
var m2_sensitivity="50";
var m2_threshold="0";
var m3_enable="0";
var m3_x="0";
var m3_y="560";
var m3_w="160";
var m3_h="160";
var m3_sensitivity="50";
var m3_threshold="0";
var m4_enable="0";
var m4_x="1120";
var m4_y="560";
var m4_w="160";
var m4_h="160";
var m4_sensitivity="50";
var m4_threshold="0";
'
2017-08-10 15:19:51.411 [DEBUG] [ab.binding.http.internal.HttpBinding] - Couldn't create state for item 'IPCam01_MDetect' from string '    var m1_enable="1";
var m1_x="30";
var m1_y="31";
var m1_w="1214";
var m1_h="667";
var m1_sensitivity="50";
var m1_threshold="0";
var m2_enable="0";
var m2_x="1120";
var m2_y="0";
var m2_w="160";
var m2_h="160";
var m2_sensitivity="50";
var m2_threshold="0";
var m3_enable="0";
var m3_x="0";
var m3_y="560";
var m3_w="160";
var m3_h="160";
var m3_sensitivity="50";
var m3_threshold="0";
var m4_enable="0";
var m4_x="1120";
var m4_y="560";
var m4_w="160";
var m4_h="160";
var m4_sensitivity="50";
var m4_threshold="0";
'

Thanks for your time :wink:

In addition, shouldnt var out an array?

Isn’t possible to debug what the javascript is doing? With some console.log? It dosn’t work…

I think a possible way to get the first array entry is

var out = i.match(re)[1]

Hello,
I would like to switch a WLAN socket on and off via HttpRequest. My item looks like this.

Switch Lampe "TischLampe" { http=">[ON:GET:http://192.168.2.144/relay?state=1] >[OFF:GET:http://192.168.2.144/relay?state=0]" }

Unfortunately it doesn’t work? What am I doing wrong? For switching I used a normal switch widget. It also does not change the visible status of On->OFF or OFF-ON when clicked. I always have to reload the page completely.

2018-04-02%2023_53_17-HABPanel

Hi

Did you ever get this working?

I’m trying to do something similar with a Robot Electronics ETH484 relay board

These commands work perfectly in a browser, but I get endless error messages in OH2

http://192.168.178.160/io.cgi?DOA1
http://192.168.178.160/io.cgi?DOI1

Instructions for the relay board are here http://www.robot-electronics.co.uk/htm/eth484tech.htm

I’ve seen reference to MAP files, but I’m not sure what to do with them.

None of the instructions for the HTTP binding make direct reference to any kind of transformation for simple ON & OFF commands.

The commands I have in my items file look like this

Switch Eth484Relay1 { http=">[ON:http://192.168.178.160/io.cgi?DOA1] >[OFF:http://192.168.178.160/io.cgi?DOI1]" }

Switch Eth484Relay2 { http=">[ON:http://192.168.178.160/io.cgi?DOA2] >[OFF:http://192.168.178.160/io.cgi?DOI2]" } 

The errors I see in openhab.log are these

2018-11-05 16:26:13.562 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type 'http' of item 'Eth484Relay1' could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: bindingConfig '*:http://192.168.178.160/io.cgi?DOA1' doesn't contain a valid out-binding-configuration. A valid configuration is matched by the RegExp '(.*?):([A-Z]*):(.*)'
        at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:51) ~[?:?]
        at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:397) ~[?:?]
        at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:366) ~[?:?]
        at org.eclipse.smarthome.model.item.internal.GenericItemProvider.processBindingConfigsFromModel(GenericItemProvider.java:229) ~[?:?]
        at org.eclipse.smarthome.model.item.internal.GenericItemProvider.modelChanged(GenericItemProvider.java:432) ~[?:?]
        at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:301) ~[?:?]
        at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:139) ~[?:?]
        at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:227) ~[?:?]
        at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.processWatchEvent(FolderObserver.java:291) ~[?:?]
        at org.eclipse.smarthome.core.service.WatchQueueReader.lambda$3(WatchQueueReader.java:323) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
        at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: org.openhab.model.item.binding.BindingConfigParseException: bindingConfig '*:http://192.168.178.160/io.cgi?DOA1' doesn't contain a valid out-binding-configuration. A valid configuration is matched by the RegExp '(.*?):([A-Z]*):(.*)'
        at org.openhab.binding.http.internal.HttpGenericBindingProvider.parseOutBindingConfig(HttpGenericBindingProvider.java:254) ~[?:?]
        at org.openhab.binding.http.internal.HttpGenericBindingProvider.parseBindingConfig(HttpGenericBindingProvider.java:155) ~[?:?]
        at org.openhab.binding.http.internal.HttpGenericBindingProvider.processBindingConfiguration(HttpGenericBindingProvider.java:119) ~[?:?]
        at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:49) ~[?:?]
        ... 16 more
2018-11-05 16:26:13.663 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type 'http' of item 'Eth484Relay2' could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: bindingConfig 'ON:http://192.168.178.160/io.cgi?DOA2' doesn't contain a valid out-binding-configuration. A valid configuration is matched by the RegExp '(.*?):([A-Z]*):(.*)'
        at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:51) ~[?:?]
        at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:397) ~[?:?]
        at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:366) ~[?:?]
        at org.eclipse.smarthome.model.item.internal.GenericItemProvider.processBindingConfigsFromModel(GenericItemProvider.java:229) ~[?:?]
        at org.eclipse.smarthome.model.item.internal.GenericItemProvider.modelChanged(GenericItemProvider.java:432) ~[?:?]
        at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:301) ~[?:?]
        at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:139) ~[?:?]
        at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:227) ~[?:?]
        at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.processWatchEvent(FolderObserver.java:291) ~[?:?]
        at org.eclipse.smarthome.core.service.WatchQueueReader.lambda$3(WatchQueueReader.java:323) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
        at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: org.openhab.model.item.binding.BindingConfigParseException: bindingConfig 'ON:http://192.168.178.160/io.cgi?DOA2' doesn't contain a valid out-binding-configuration. A valid configuration is matched by the RegExp '(.*?):([A-Z]*):(.*)'
        at org.openhab.binding.http.internal.HttpGenericBindingProvider.parseOutBindingConfig(HttpGenericBindingProvider.java:254) ~[?:?]
        at org.openhab.binding.http.internal.HttpGenericBindingProvider.parseBindingConfig(HttpGenericBindingProvider.java:155) ~[?:?]
        at org.openhab.binding.http.internal.HttpGenericBindingProvider.processBindingConfiguration(HttpGenericBindingProvider.java:119) ~[?:?]
        at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:49) ~[?:?]
        ... 16 more
2018-11-05 16:53:30.711 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'http.items'
2018-11-05 16:53:30.729 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type 'http' of item 'Eth484Relay1' could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: bindingConfig 'ON:http://192.168.178.160/io.cgi?DOA1' doesn't contain a valid out-binding-configuration. A valid configuration is matched by the RegExp '(.*?):([A-Z]*):(.*)'
        at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:51) ~[?:?]
        at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:397) ~[?:?]
        at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:366) ~[?:?]
        at org.eclipse.smarthome.model.item.internal.GenericItemProvider.processBindingConfigsFromModel(GenericItemProvider.java:229) ~[?:?]
        at org.eclipse.smarthome.model.item.internal.GenericItemProvider.modelChanged(GenericItemProvider.java:432) ~[?:?]
        at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:301) ~[?:?]
        at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:139) ~[?:?]
        at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:227) ~[?:?]
        at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.processWatchEvent(FolderObserver.java:291) ~[?:?]
        at org.eclipse.smarthome.core.service.WatchQueueReader.lambda$3(WatchQueueReader.java:323) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
        at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: org.openhab.model.item.binding.BindingConfigParseException: bindingConfig 'ON:http://192.168.178.160/io.cgi?DOA1' doesn't contain a valid out-binding-configuration. A valid configuration is matched by the RegExp '(.*?):([A-Z]*):(.*)'
        at org.openhab.binding.http.internal.HttpGenericBindingProvider.parseOutBindingConfig(HttpGenericBindingProvider.java:254) ~[?:?]
        at org.openhab.binding.http.internal.HttpGenericBindingProvider.parseBindingConfig(HttpGenericBindingProvider.java:155) ~[?:?]
        at org.openhab.binding.http.internal.HttpGenericBindingProvider.processBindingConfiguration(HttpGenericBindingProvider.java:119) ~[?:?]
        at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:49) ~[?:?]
        ... 16 more
2018-11-05 16:53:30.830 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type 'http' of item 'Eth484Relay2' could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: bindingConfig 'ON:http://192.168.178.160/io.cgi?DOA2' doesn't contain a valid out-binding-configuration. A valid configuration is matched by the RegExp '(.*?):([A-Z]*):(.*)'
        at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:51) ~[?:?]
        at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:397) ~[?:?]
        at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:366) ~[?:?]
        at org.eclipse.smarthome.model.item.internal.GenericItemProvider.processBindingConfigsFromModel(GenericItemProvider.java:229) ~[?:?]
        at org.eclipse.smarthome.model.item.internal.GenericItemProvider.modelChanged(GenericItemProvider.java:432) ~[?:?]
        at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:301) ~[?:?]
        at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:139) ~[?:?]
        at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:227) ~[?:?]
        at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.processWatchEvent(FolderObserver.java:291) ~[?:?]
        at org.eclipse.smarthome.core.service.WatchQueueReader.lambda$3(WatchQueueReader.java:323) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
        at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: org.openhab.model.item.binding.BindingConfigParseException: bindingConfig 'ON:http://192.168.178.160/io.cgi?DOA2' doesn't contain a valid out-binding-configuration. A valid configuration is matched by the RegExp '(.*?):([A-Z]*):(.*)'
        at org.openhab.binding.http.internal.HttpGenericBindingProvider.parseOutBindingConfig(HttpGenericBindingProvider.java:254) ~[?:?]
        at org.openhab.binding.http.internal.HttpGenericBindingProvider.parseBindingConfig(HttpGenericBindingProvider.java:155) ~[?:?]
        at org.openhab.binding.http.internal.HttpGenericBindingProvider.processBindingConfiguration(HttpGenericBindingProvider.java:119) ~[?:?]
        at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:49) ~[?:?]
        ... 16 more

I assume that the key to my downfall has something to do with this line

doesn't contain a valid out-binding-configuration. A valid configuration is matched by the RegExp '(.*?):([A-Z]*):(.*)'

I just don’t have a clue what it means.

@Udo_Hartmann @rlkoshak

Can you shed any light on this?

I guess you forgot the http method:

Switch Eth484Relay1 { http=">[ON:http://192.168.178.160/io.cgi?DOA1] >[OFF:http://192.168.178.160/io.cgi?DOI1]" }
Switch Eth484Relay2 { http=">[ON:http://192.168.178.160/io.cgi?DOA2] >[OFF:http://192.168.178.160/io.cgi?DOI2]" } 

vs.

Switch Eth484Relay1 { http=">[ON:POST:http://192.168.178.160/io.cgi?DOA1] >[OFF:POST:http://192.168.178.160/io.cgi?DOI1]" }
Switch Eth484Relay2 { http=">[ON:POST:http://192.168.178.160/io.cgi?DOA2] >[OFF:POST:http://192.168.178.160/io.cgi?DOI2]" } 
1 Like

Thanks

According to the docs, I thought I was using the GET method, which didn’t need to be stated?

But as it turns out, adding POST did fix it all.

My items file now looks like this and works :smile:

Switch Eth484Relay1 { http=">[ON:POST:http://192.168.178.160/io.cgi?DOA1] >[OFF:POST:http://192.168.178.160/io.cgi?DOI1]" }

Switch Eth484Relay2 { http=">[ON:POST:http://192.168.178.160/io.cgi?DOA2] >[OFF:POST:http://192.168.178.160/io.cgi?DOI2]" }

Switch Eth484Relay3 { http=">[ON:POST:http://192.168.178.160/io.cgi?DOA3] >[OFF:POST:http://192.168.178.160/io.cgi?DOI3]" }

Switch Eth484Relay4 { http=">[ON:POST:http://192.168.178.160/io.cgi?DOA4] >[OFF:POST:http://192.168.178.160/io.cgi?DOI4]" }

If I can get my head around how to send a HEX command via the TCP binding, I can query the relay and set the remaining outputs.

But that’s for another day… or month… or even a different year

See https://www.openhab.org/addons/bindings/http1/#item-configuration for reference.

Take a look at outgoing message:

http=">[<command>:<httpmethod>:<url>:<postcontent>]"

<httpmethod> is not optional, only <postcontent> is optional and only applies when <httpmethod> is POST