I have a device that I currently manage with the exec binding and curl commands. I’d like to convert my script to use this http binding instead, but I’m having two issues:
My device only answers POST requests. I’ve made several tests with the HTTP binding and it seems that it always uses GET to obtain status from the device. Is it possible to use POST to obtain status ? How ?
Authentication for my device is made in the form of https://<userid>:<password>@<ip>:<port>. Is this supported by the HTTP binding ?
According to the docs there is a commandMethod parameter on the Thing where you can tell it to use one of GET, PUT, and POST. There are also a username and password parameters. The port would be a part of the baseURL.
True, but this seems to apply to commands only, not to status. How can I obtain the status using POST instead of GET ? Is this supported by this binding ?
This may be poor form and I’m happy to delete it if is. I am having some problems with configuring the HTTP binding and originally posted here:
The always helpful Rich was able to get me halfway there so I can now view the status of the device, but I am still unable to send commands using the binding and was hoping someone on this thread who may be using the binding can help me.
Essentially I am trying to replicate the following in the HTTP binding:
Actually I got in contact with the developer of the binding and he further developed it for Generation 2. This we did already during openHAB 2.X and I used the final development version for almost 2 years now.
Currently I´m supporting him in testing the 3.X binding. In that it will be included by default. It works already for reading all parameters as well as even writing, except the Smart Battery control. On that we are working on.
Please try update org.openhab.binding.http https://janessa.me/esh/org.openhab.binding.http-3.0.0-SNAPSHOT.jar, you’ll probably need to delete and re-add the thing. There is a new “advanced” config option for the buffer size. The default is 2048 kB (which was the default before). Increase that to 4096 and see if your situation improves.
First of all, also thanks from my side to all the guys having participated by developing this binding. It is great to have a successor of the 1.X binding.
Now to the question. Are there anywhere examples or instructions available how it can be used via configuration files. Somehow I would like to stick to the config files for now.
Actually I need it only for simple purposes, like sending a command via http. In the 1.x binding the following did the job:
I succeeded already in sending one of the commands by configuring it via the UI, but one the one side I have up to now everything setup in config files, on the other side I believe that it would allow me to easier and faster switch my productive openHAB instance from 2.x to 3.x when I have sooner or later everything prepared.
If someone wants to add that to the documentation, I’ll happily merge it. I won’t write that documentation because IMO textual configuration is complex, error-prone and a pain-in-the-a**. Sorry.
Hi Jan
thanks for this update. It solved something strange. A while ago i made it to connect my Kostal inverter via the new http binding which runs with a longer JSON string. I got all values into the items, they were visible. But the entries in the sitemap did not show any values, just empty space. Strange thing, havent had the time yet to look into it.
Now i downloaded your changed binding and immediately the values popped up in the sitemap.
Is the buffer size the only thing you changed compared to the M5 binding? I have a similar issue at another binding so it would be an idea to look into the same topics…
No other changes. I doubt that there is a connection between the two issues. The default buffer size is still the same, so if you didn’t configure something, there is no change at all.
I migrated my mobile alerts setup from OH 2.5.2 / http binding 1.14 to OH3 M5 with http OH3 M5 binding.
I have some troubles with the presentation of humidity values on the sitemap.
OH2 using [%d %%]:
OH3 using [%d %%] -> 5800% instead of 58%:
OH3 using [%d %unit%]
I use the following JS (same in OH2 and OH3):
(function(i) {
var re = new RegExp('xxxxxxxxxxxx[\\s\\S]*?Luftfeuchte Innen[\\s\\S]*?<h4>([0-9]+)%');
var out = i.match(re)[1];
return parseFloat(out);
})(input)
I’m getting this partially solved by dividing the output from the JS by 100:
(function(i) {
var re = new RegExp('xxxxxxxxxxxx[\\s\\S]*?Luftfeuchte Innen[\\s\\S]*?<h4>([0-9]+)%');
var out = i.match(re)[1];
return parseFloat(out/100);
})(input)
My questions are:
How to show the % values for MA Indoor/Outdoor on the picture above?
Need for division by 100: Is this caused by changes from OH2 / http 1.14 to OH3?