kohlsalem
(Michael Kohl)
September 10, 2019, 9:09pm
1
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
rossko57
(Rossko57)
September 10, 2019, 9:35pm
2
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
kohlsalem
(Michael Kohl)
September 11, 2019, 5:39am
3
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
rossko57
(Rossko57)
September 11, 2019, 11:31am
4
The data you are trying to POST is JSON, by the way.
You might look to see how others send JSON by HTTP
I need to send a Post command with a payload, and see that the HTTP binding doesn’t support payloads but maybe a Curl can do it with the Exec binding.
Can someone talk me through how to do this please?
I have it working from a chrome addon but my knowledge of Curl is zero
The payload is:
{
“acState”: {
“on”: false,
“mode”: “heat”,
“fanLevel”: “auto”,
“targetTemperature”: 22
}
}
1 Like
kohlsalem
(Michael Kohl)
September 11, 2019, 12:54pm
5
Well, i need to PUT, not POST :-). Thanks for pointing this out; so yes, i could definitely do it with a rule…
kohlsalem
(Michael Kohl)
September 11, 2019, 6:46pm
6
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 :-/
kohlsalem
(Michael Kohl)
September 11, 2019, 6:59pm
7
1 Like
kohlsalem
(Michael Kohl)
September 15, 2019, 6:10pm
8
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
markymark
(Mark Baumann)
January 27, 2020, 1:19pm
9
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
Celaeno1
(Alex)
January 27, 2020, 1:23pm
10
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
markymark
(Mark Baumann)
January 27, 2020, 1:28pm
11
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.
markymark
(Mark Baumann)
January 27, 2020, 1:35pm
12
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" }
Celaeno1
(Alex)
January 27, 2020, 1:47pm
13
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
markymark
(Mark Baumann)
January 27, 2020, 3:35pm
14
you are amazing. Is it possible to make a addon for it? or do I have to ask rademacher first
Celaeno1
(Alex)
January 27, 2020, 3:44pm
15
Sorry, I’m not a lawyer. It is reverse engineered. So, why not? Better ask the community in a new topic?
1 Like
kohlsalem
(Michael Kohl)
January 27, 2020, 4:20pm
16
For sure it is possible. We would just need somebody able to do it
I think all Rest services needed are available…
markymark
(Mark Baumann)
January 27, 2020, 4:22pm
17
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
markymark
(Mark Baumann)
January 27, 2020, 4:24pm
18
For the Addon I can acess the HTTP binding?
Celaeno1
(Alex)
January 27, 2020, 4:59pm
19
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.
markymark
(Mark Baumann)
January 27, 2020, 5:55pm
20
Where I can find the OH3 Developer? Can you paste some Usernames?