(Solved) Http binding for Homepilot

Hi Openhab Community,

i might have not configured my openhab for a while and might have to forgot something basic.

I have had a couple of homepilot rolershutters inegrated with a HTTP binding. Now i upgraded the firmware of the HP - and the interface changed. Grrr.

A bit of “F12” in google chrome and some trying and i know i can control a sutter with a

curl -X PUT -d '{"name":"GOTO_POS_CMD","value":"35"}' http://homepilot/devices/10001

So:

  • hostame resolves (i run it on my OH machine)
  • no auth needed
  • no fancy header or tokeneither

Now i want to setup a mathcig http binding correctly. No, i do not want se excec, since i will poll the status of all rollershutters every minute, and therefore like to have the caching…

My best guess:

Rollershutter RollladenWZSL "Süd Links" (GRollAll,GRollWZ,GRollWZSL) {http=">[*:PUT:http://homepilot/devices/10001:{\"name\":\"GOTO_POS_CMD\",\"value\":%2$s}]"}

(That is the stripped down version, w/o the reading, sitemap etc worked with the old url)

If i tail -f the openhab log i see no errors or save of the item or setting the slider in the basic ui. But nothing happened either…

Did i do some obvious fault? What would should i do?

Thanks
Michael

In the HTTP binding, the colon character : is used as a parameter separator.
So you have to hide any colons included in your plain text by URL encoding as %3A.
There’s a problem with that though … % is itself an escape character. So you have to escape the %3A and use %%3A

There might be another way to escape with \ but I don’t know it.

I think you might need to URL encode your curly braces too.

1 Like

Thats a great tipp! Thanks! I gave it a quick try with

{http=">[*:PUT:http://homepilot/devices/10001:%%7B%%22name%%22%%3A%%22GOTO_POS_CMD%%22,%%22value%%22%%3A%2$s%%7D]"}

But it did not help yet. I’ll try to set logging to verbose or something tonight; did not think about that yesterday…

1 Like

The data you are trying to POST is JSON, by the way.
You might look to see how others send JSON by HTTP

1 Like

Well, i need to PUT, not POST :-). Thanks for pointing this out; so yes, i could definitely do it with a rule…

well, setting the log for the http binding on trace, reveals the not so helpful 2 entries:

> 2019-09-11 20:41:46.861 [DEBUG] [ab.binding.http.internal.HttpBinding] - Executing url 'http://homepilot/devices/10001' via method PUT
> 2019-09-11 20:41:46.864 [TRACE] [ab.binding.http.internal.HttpBinding] - Couldn't find matching binding provider [itemName=RollladenWZSL, command=CHANGED]

The first one is calming, since i would expect that; the second one might be not relevant (says google) but no info of the provided payload.

any idea on the binding is greatly appriciated; otherwise i have t write that rules :-/

looking for the debug message in the source code, i found https://github.com/openhab/openhab1-addons/blob/c14c872c25f68d28de7024f0414445a6c57ee6df/bundles/binding/org.openhab.binding.http/src/main/java/org/openhab/binding/http/internal/HttpBinding.java#L282

The binding does not support the posting of body content for PUT.

WTF?

Well, I’ll try to file a bug/feature request.

Edit: did already exist… https://github.com/openhab/openhab1-addons/issues/5845?_pjax=%23js-repo-pjax-container

1 Like

In case somebody finds this lokking for HomePilot integration: My solution with the latest Firmware for HP (5.0.xx). Thanks to @rossko57 for directing my nose to the working solution…

Items:

Rollershutter RollladenWZSL "Süd Links"  (GRollAll,GRollWZ,GRollWZSL)        {http="<[homepilotCache:20000:JSONPATH($.devices[?(@.did==10001)].statusesMap.Position)] "}
Rollershutter RollladenWZSR "Süd Rechts" (GRollAll,GRollWZ,GRollWZSR)        {http="<[homepilotCache:20000:JSONPATH($.devices[?(@.did==10002)].statusesMap.Position)] "}
Rollershutter RollladenWZSML "Süd Mitte Links" (GRollAll,GRollWZ,GRollWZSL)  {http="<[homepilotCache:20000:JSONPATH($.devices[?(@.did==10004)].statusesMap.Position)] "} 
Rollershutter RollladenWZSMR "Süd Mitte Rechts" (GRollAll,GRollWZ,GRollWZSR) {http="<[homepilotCache:20000:JSONPATH($.devices[?(@.did==10005)].statusesMap.Position)] "}
Rollershutter RollladenWZWR "West Rechts" (GRollAll,GRollWZ,GRollWZW)        {http="<[homepilotCache:20000:JSONPATH($.devices[?(@.did==10006)].statusesMap.Position)] "}
Rollershutter RollladenWZWL "West Links" (GRollAll,GRollWZ,GRollWZW)         {http="<[homepilotCache:20000:JSONPATH($.devices[?(@.did==10007)].statusesMap.Position)] "}
Rollershutter RollladenSZR "Schlafzimmer Rechts" (GRollAll,GRollOG,GRollSZ)  {http="<[homepilotCache:20000:JSONPATH($.devices[?(@.did==10008)].statusesMap.Position)] "} 
Rollershutter RollladenSZL "Schlafzimmer Links" (GRollAll,GRollOG,GRollSZ)   {http="<[homepilotCache:20000:JSONPATH($.devices[?(@.did==10009)].statusesMap.Position)] "}
Rollershutter RollladenSZA "Schlafzimmer Alex" (GRollAll,GRollOG)            {http="<[homepilotCache:20000:JSONPATH($.devices[?(@.did==10010)].statusesMap.Position)] "}

Rule:

//send updates to Home Pilot
rule "GetRollershutterUpdate"
when
  Member of GRollAll received command
then
   logDebug("rolershutter","rolershutter " + triggeringItem.name + " recieved update" + receivedCommand )
   var String myUrl = ""
   switch(triggeringItem.name) {
    case "RollladenWZSL": { myUrl = "http://homepilot/devices/10001"} 
    case "RollladenWZSR": { myUrl = "http://homepilot/devices/10002"} 
    case "RollladenWZSML": { myUrl = "http://homepilot/devices/10004"} 
    case "RollladenWZSMR": { myUrl = "http://homepilot/devices/10005"}     
    case "RollladenWZWR": { myUrl = "http://homepilot/devices/10006"} 
    case "RollladenWZWL": { myUrl = "http://homepilot/devices/10007"} 
    case "RollladenSZR": { myUrl = "http://homepilot/devices/10008"} 
    case "RollladenSZL": { myUrl = "http://homepilot/devices/10009"} 
    case "RollladenSZA": { myUrl = "http://homepilot/devices/10010"} 
   }
  
  var String myData = '{"name":"GOTO_POS_CMD","value":"' + receivedCommand  + '"}'
  logDebug("rolershutter","Sending put "+ myData + " to " + myUrl)
  sendHttpPutRequest(myUrl, "application/x-www-form-urlencoded", myData)
end

Service config in http.cfg

#Homepilot
homepilotCache.url=http://homepilot/v4/devices
homepilotCache.updateInterval=20000
2 Likes

My error code of using from the HTTP binding:

 2020-01-27 14:09:17.609 [ERROR] [org.openhab.io.net.http.HttpUtil    ] - Fatal transport error: java.net.UnknownHostException: http
 2020-01-27 14:09:17.609 [ERROR] [ab.binding.http.internal.HttpBinding] - No response received from 'homepilotCache'
 2020-01-27 14:11:47.050 [ERROR] [.smarthome.model.script.actions.HTTP] - Fatal transport error: java.util.concurrent.ExecutionException: java.net.UnknownHostException: homepilot

You have to fill your homepilot IP-Address

in http.cfg e.g:

#Homepilot
homepilotCache.url=http://172.21.10.182/v4/devices
homepilotCache.updateInterval=20000

I put the IP instead of #Homepilot

Error message:

2020-01-27 14:25:08.584 [WARN ] [g.dispatch.internal.ConfigDispatcher] - Could not parse line '172.21.10.182'

So if i control the device from the actual Rademacher UI, openHAB shows the actual position but i can´t control it.

http.cfg

172.21.10.182
homepilotCache.url=http://172.21.10.182//v4/devices
homepilotCache.updateInterval=20000

GetRollershutterUpdate.rules

rule "GetRollershutterUpdate"
when
  Member of GRollAll received command
then
   logDebug("rolershutter","rolershutter " + triggeringItem.name + " recieved update" + receivedCommand )
   var String myUrl = ""
   switch(triggeringItem.name) {
    case "RollladenWZSL": { myUrl = "http://homepilot/devices/1010013"} 
   }
  
  var String myData = '{"name":"GOTO_POS_CMD","value":"' + receivedCommand  + '"}'
  logDebug("rolershutter","Sending put "+ myData + " to " + myUrl)
  sendHttpPutRequest(myUrl, "application/x-www-form-urlencoded", myData)
end

test.items

Rollershutter RollladenWZSL "Süd Links" (GRollAll,GRollWZ,GRollWZSL) {http="<[homepilotCache:20000:JSONPATH($.devices[?(@.did==1010013)].statusesMap.Position)] "}

test.sitemap

sitemap test label="test ui"

{ Slider item=RollladenWZSL label="test" }

Shouldn’t it be:

case "RollladenWZSL": { myUrl = "http://172.21.10.182/devices/1010013"}

should be:

homepilotCache.url=http://172.21.10.182/v4/devices
1 Like

you are amazing. Is it possible to make a addon for it? or do I have to ask rademacher first

Sorry, I’m not a lawyer. It is reverse engineered. So, why not? Better ask the community in a new topic?

1 Like

For sure it is possible. We would just need somebody able to do it :slight_smile:

I think all Rest services needed are available…

The Addons are programmed in Java right? I am interested to do it, but i don´t know if my Java Skills are good enough

For the Addon I can acess the HTTP binding?

I don’t know whether the http1 binding (it is still OH 1) will get obsolete in OH 3.0 or not, better ask the OH 3.0 developers.

Where I can find the OH3 Developer? Can you paste some Usernames?