Help needed: send http command http binding OH2->OH3

Hello,
sorry, I searched and tried a lot and I don’t find a way to transfer my http commands I have to send to open/close and so on to external systems.
I have now OH3.0.2 installed with the http binding.
With OH2.x the command was the following:
I created under OH2 an Item
Switch xx “xx” { http=">[*:POST:http://192.xxx.xxx.xxx/relay_control?1=on]" }

I tried a lot and it don’t worked…
Could everyone help me and give me the infromation what must be configured with the OH3 http binding?

Thanks a lot and best regards
Stefan

What did you try? Please show the thing configuration. (Right tab „Code“).

Hi Jan,
here is the code:

label: URL_TorEinfahrt_Test
thingTypeUID: http:url
configuration:
authMode: BASIC
ignoreSSLErrors: false
baseURL: http:///
refresh: 10
commandMethod: POST
contentType: text/plain
timeout: 3000
bufferSize: 2048
channels:

  • id: URL_TorEinfahrt
    channelTypeUID: http:string
    label: TorEinfahrt_Betaetigen
    description: “”
    configuration:
    commandExtension: /relay_control?1=on
  • id: ON
    channelTypeUID: http:switch
    label: ON
    description: “”
    configuration:
    onValue: on
    mode: WRITEONLY
    offValue: off
    commandExtension: relay_control?1=on

Hi,

thanks. Why do you have two channels? And which of the channels did you link to the item? Another thing: I guess the baseUrl contains the ip-address, correct? It looks empty in your posted condifuration.

Hi Jan,
I deleted only the ip adress here.
I have 2 bindings only made for testing, because I was not sure, witch works…
I added here it complete again

UID: http:url:20c6f206df
label: URL_TorEinfahrt_Test
thingTypeUID: http:url
configuration:
authMode: BASIC
ignoreSSLErrors: false
baseURL: http://192.168.xx.xx/
refresh: 10
commandMethod: POST
contentType: text/plain
timeout: 3000
bufferSize: 2048
channels:

  • id: ON
    channelTypeUID: http:switch
    label: ON
    description: “”
    configuration:
    onValue: on
    mode: WRITEONLY
    offValue: off
    commandExtension: relay_control?1=on

Thanks a lot for your help !!

In general that looks very good. Maybe you should set the binding to TRACE logging (Logging | openHAB and see what exactly is send and what the response is. Coud it be that the content (which is the command) of the POST request is the problem?

Thanks a lot Jan. Sorry for late reponse, coudn’t test it.

In the log I get the following:
[WARN ] [p.internal.http.HttpResponseListener] - Requesting ‘http://192.168.xx.xxx/relay_control?1=on’ (method=‘POST’, content=‘org.eclipse.jetty.client.util.StringContentProvider@35174cc8’) failed: 400 Bad request

I also set to “ignore SSL failures”.

If I send the command over the browser, it works…

Thanks for your help!!

If this works, why not use a GET instead of a POST?

I will try.
does get not wand to have specific return?
What I mean, is, that over the internet browser it works, so the http cmmand itself is ok…

It could be that the server does not allow content to be sent. By default the command is set as content. Can you try if you get the same error if you send something in the content in OH2?

Hi Jan,
with the HTTP Binding I don’t get it to work…
I now have done this with the “sendHttpPostRequest” out of a rule and it works.
Don’t know why, but for this issue solved. I I had time, I will try to get it done with http binding, I think for other things it would be nice…
Thanks and best regards
Stefan

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.