Http binding wrong Full Request URI in OH3

I have a device that turns a switch on opening this URL in a browser :
http://schakelaar8x1.andege.local/FF0101 (and closing with http://schakelaar8x1.andege.local/FF0100).

In OH2.5.1 this is the http.items file :

Switch SchakelaarBuiten "Schakelaar Buiten" { http=">[OFF:POST:http://schakelaar8x1.andege.local/FF0100] >[ON:POST:http://schakelaar8x1.andege.local/FF0101]" }

and works fine.

IN OH3.1.0 this is the code for the thing :

UID: http:url:381c2339be
label: Schakelaar Buiten
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: http://schakelaar8x1.andege.local
  delay: 0
  stateMethod: POST
  refresh: 30
  commandMethod: POST
  contentType: text/plain
  timeout: 3000
  bufferSize: 2048
channels:
  - id: Schakelaar8x1Buiten
    channelTypeUID: http:switch
    label: Schakelaar8x1 Buiten
    description: ""
    configuration:
      onValue: FF0101
      offValue: FF0100

In the (tcpdump)capture, I see this :

Hypertext Transfer Protocol
    POST / HTTP/1.1\r\n
    Accept-Encoding: gzip\r\n
    User-Agent: Jetty/9.4.40.v20210413\r\n
    Content-Type: text/html\r\n
    Host: schakelaar8x1.andege.local\r\n
    Content-Length: 6\r\n
    \r\n
    [Full request URI: http://schakelaar8x1.andege.local/]
    [HTTP request 1/1]
    [Response in frame: 45]
    File Data: 6 bytes
Line-based text data: text/html (1 lines)
    FF0101

What I am doing wrong (or is the URI wrongly concatenated), as it does not work with the OH3 http binding ?

You have to add %2$s as commandExtension tobte Channel.

That makes the difference. Thanks (was not clear to me from the documentation).

I notice that at seconds the item goes to UNDEF because the binding reads from the base URI again and that returns somethings else. Is there a way around that ?

If you can‘t read the state, set the channel
mode to write-only.

Thanks once more. Solved the problem !

1 Like