@J-N-K I have a device whose command / status interface is POST only. Here is my thing definition:
label: Lareira - Comandos
- id: switch
And here is the transformation:
var resultado = "idOperacion=1013&on_off=" + i;
This works Ok in OH3.0.0 with http binding updated to 3.1.0.snapshot. I am able to switch the device on and off. What I can’t do is to access the device status. For this I need to access the response to the POST request.
To obtain the status from the device I need to send a POST request with this body
idOperacion=1002 and have access to the result, that comes like this (if I use CURL):
Ideally this POST request should be sent periodically (equivalent to a status), but the HTTP binding only supports GET requests for status. Would it be possible to enhance it to allow POST requests for status ?
The question is how to configure the body. Do you have an idea? Maybe extend the YAML above to show what you think.
Thanks for your reply.
I think that there are two points to consider:
- pick the POST response. This would be a string that can be parsed by a transformation. Currently the binding does not allow to process a POST response
- In my own case all status requests should be handled using POST. But I can’t grant that this is a general case. Currently you have (in thing definitions)
commandMethod: POST and
contentType: text/plain. Adding
statusMethod: POST and
statuscontentType: text/plain would work in my case
Crosslink for github issue #9996
update org.openhab.binding.http https://janessa.me/esh/org.openhab.binding.http-3.1.0-SNAPSHOT.jar
Awesome. It works, although not exactly as I would like. The following section appears in
Thing tab and it should be in the
Channels tab instead because body content depends on the channel.
It works as it is now, but I need to define several things for the same device instead of several channels for the same thing, as I would like.
Now it does not work at all, here is the log
2021-02-01 21:05:04.419 [WARN ] [ttp.internal.http.RefreshingUrlCache] - Creating request for 'idOperacion=1002$https://192.168.129.10:8000/recepcion_datos_4.cgi' failed: no protocol: idOperacion=1002$https://192.168.129.10:8000/recepcion_datos_4.cgi
2021-02-01 21:05:34.421 [WARN ] [ttp.internal.http.RefreshingUrlCache] - Creating request for 'idOperacion=1002$https://192.168.129.10:8000/recepcion_datos_4.cgi' failed: no protocol: idOperacion=1002$https://192.168.129.10:8000/recepcion_datos_4.cgi
2021-02-01 21:06:04.422 [WARN ] [ttp.internal.http.RefreshingUrlCache] - Creating request for 'idOperacion=1002$https://192.168.129.10:8000/recepcion_datos_4.cgi' failed: no protocol: idOperacion=1002$https://192.168.129.10:8000/recepcion_datos_4.cgi
Oops. Dumb mistake. I‘ll fix that tomorrow.
Thanks a lot. In the meantime I’ve seen your blog. Very nice family.
Next try. I fixed the URL issue.
Perfect. Fantastic. Thank you very much.