ETA Boiler: set a switch via http binding

Hello.

I try to set some values for my ETA Boiler using http binding.
In the particular case I like to have switch of the heating loop. Here is the item:

Switch swHeatingLoopOnOff “Heating Loop” { http=">[ON:POST:http://etaboilderurl:8080/user/var/120/10101/0/0/12080:value=1803] >[OFF:POST:http://etaboilderurl:8080/user/var/120/10101/0/0/12080:value=1802]"}

Seems to be ok.
But I just get “Method failed: HTTP/1.1 400 Bad Request” :frowning:

Here the debug message from the binding:
2018-09-23 18:45:16.414 [DEBUG] [.o.b.http.internal.HttpBinding] - Executing url ‘http://etaboilderurl:8080/user/var/120/10101/0/0/12080’ via method POST, with body content ‘value=1803’
2018-09-23 18:45:16.423 [WARN ] [g.openhab.io.net.http.HttpUtil] - Method failed: HTTP/1.1 400 Bad Request

“same” vie curl works flawlessly:
curl -d value=1802 http://etaboilderurl:8080/user/var/120/10101/0/0/12080
<?xml version=“1.0” encoding=“utf-8”?>

<eta version=“1.0” xmlns=“http://www.eta.co.at/rest/v1”>

<success uri="/user/var/120/10101/0/0/12080"/>

</eta>

1 Like

Does it work for the value 1803 like posted above in your items?
ON:POST value=1803
OFF:POST value=1802

Hello.

Yes, if I send the http requests via curl command on terminal, if works.
I got positive response and the boiler switches the switch accordingly.

Looks like the MAP transformation binding and a map file with the values will be needed. If you have already created the map file please post.

If not create the map file in /etc/openhab2/transform and name it something like boiler.map

Inside boiler.map place the following:
1803=ON
1802=OFF

Make sure you have the binding install via PaperUI >addons>transformations>MAP

In your items add map on the end like:

Switch swHeatingLoopOnOff “Heating Loop” { http=">[ON:POST:http://etaboilderurl:8080/user/var/120/10101/0/0/12080:MAP(boiler.map)] >[OFF:POST:http://etaboilderurl:8080/user/var/120/10101/0/0/12080:MAP(boiler.map)]"}

If this doen’t work, in your items, try replacing POST with GET.

1 Like

Hello.
I solved it as:
Put the http POST request into a rule as:

rule heatingLoopSwitch
when
Item swHeatingLoopOnOff changed or
System started
then
var String sHeatingLoopSetState

if ((swHeatingLoopOnOff.state == OFF) || (swHeatingLoopOnOff.state == Uninitialized)) {
	// sendHttpPostRequest(String url, String contentType, String content)
	sHeatingLoopSetState = "value=1802" // off
}
else {
	sHeatingLoopSetState = "value=1803" // on
}

sendHttpPostRequest("http://etaheaterurl:8080/user/var/120/10101/0/0/12080", "application/x-www-form-urlencoded", sHeatingLoopSetState)

end

The missing bit was the content type “application/x-www-form-urlencoded”.
By using the action sendHttpPostRequest with this content type, the request was accepted and executed correctly.

2 Likes
val String url	= "http://eta_pu_11:8080/user/var/40/10021/0/0/12080"
val String typ	= "application/x-www-form-urlencoded"
val int timeout = 5000	// ms
val wert = "value=1802"

val result = sendHttpPostRequest (url, typ, wert, timeout)

if (!result.contains("success")
{
	...
}

This works for me in most cases, but sometimes, I get:

Method failed: HTTP/1.1 400 Bad Request

<?xml version="1.0" encoding="utf-8"?>
<eta version="1.0" xmlns="http://www.eta.co.at/rest/v1">
  <error>Parameter 'value' is missing for this request</error>
</eta>

I couldn’t find out, why. I will turn to curl, if this happens a lot, although curl does not allow the result to be analyzed, does it?

Stefano

Has anyone had success to set it like H102 mentioned inside the item definition without any rule?
I tried but nothing happens, also no log entry that it was not successful?

Directly via CURL works fine.

Many Thanks, Norbert

Have a look at the EXEC binding.

Hi i just checked the exec binding, but i do not see how this would help ?
Do you have any example you could kindly post so its easier to dig into this material.

My intention is to not require to setup rules,…if its possible it would be great within a switch item to set states of the ETA heater.

Disregarding if the solution works in general, I think the boiler.map file has the values swapped.

Correct would be:

ON=1803
OFF=1802

With the solution presented by @H102, I am only getting one of the following errors:

Could not find a mapping for 'ON' in the file 'boiler.map'.
Could not find a mapping for 'OFF' in the file 'boiler.map'.

As recommended, I tried with POST and GET, several forms of the URL, with and without mapping file, but in the best case, I only got this error:

Method failed: HTTP/1.1 400 Bad Request