Hello,
how must be the http post command to control the device via openHAB2?
Rest API Command
GET http://ip-homepilot/devices/#DeviceId#
Payload: {“name”: “GOTO_POS_CMD”, “value”: #Position#}
Thank you
Hello,
how must be the http post command to control the device via openHAB2?
Rest API Command
GET http://ip-homepilot/devices/#DeviceId#
Payload: {“name”: “GOTO_POS_CMD”, “value”: #Position#}
Thank you
You seem to have answered your own question.
No because of those curly brackets which i don‘t know how to use in the HTTP Addon
The actual position I want is not in the http request URL.
I think you need to be more specific in what exactly it is you are trying to acheive if anyone is going to be able to help you.
The API of Rademacher has been changed.
https://www.imakeyouintelligent.com/rademacher-homepilot-json-api-via-webbrowser-ansteuern/ -> Comment 1 from Marius Czyz.
With the old API i can control my Rademacher Things via HTTP.
Rollershutter example "Text [%d %%]" { http=">[*:GET:http://hp27/deviceajax.do?cid=9&did=1010044&goto=%2$s&command=0]" }
Now with the new API there are curly brackets to control it via the REST API of Rademacher.
So my question is how to control a device where the actual Position Statement from the REST API is in curly brackets?
I’m not sure you can do that with the HTTP binding. I also think you have to sent a POST and not a GET. You can try to solve you issue through a rule using the “sendHttpPostRequest” function:
var output = sendHttpPostRequest("http://ip-homepilot/devices/#DeviceId#", "application/json", '{"name": "GOTO_POS_CMD", "value": "' + positionItem.state + '"}'
Thank you for your answear.
It does not work.
sitemap:
sitemap home2 label="test ui" {
Switch item=test label="test"
}
rule:
rule "testcase"
when
Item test received update ON
then
sendHttpPostRequest("http://172.21.10.182//devices/1010013", "application/json", '{“name”: “GOTO_POS_CMD”, “value”: 50}')
end
item:
Switch test
You have an extra /
in the url (rigth after the ip-address) try removing it.
Thank you Anders!
I removed it, but it does not work.
Read through the web page you posted earlier, apparently it’s supposed to be a PUT-request, not a POST. Change to sentHttpPutRequest()
and see if that works.
Because your payload contains quote marks, you have to try a bit harder to get that passed to the http action. The rules interpreter is looking at those quotemarks, and treating them like it does any other quotemark. “Ooh, a string that starts here and stops there.”
Here’s an example
my new rule file. It does not work.
rule "testcase"
when
Item test received update ON
then
var url = "http://172.21.10.182/devices/1010013"
var contenttype = "application/json"
var POSTrequest = '{“name”: “GOTO_POS_CMD”, “value”: 20}'
var output = sendHttpPostRequest(url, contenttype, POSTrequest)
end
Detail? You’ve looked in openhab.log
?
The double quotemarks you’ve used here
var POSTrequest = '{“name”: “GOTO_POS_CMD”, “value”: 20}'
are not the same as these
var POSTrequest = '{"name": "GOTO_POS_CMD", "value": 20}'
Do you know which sort you really need ?
See also my answer above, PUT not POST.
From the answers above, it should be:
rule "testcase"
when
Item test received update ON
then
var url = "http://172.21.10.182/devices/1010013"
var contenttype = "application/json"
var PUTrequest = '{"name": "GOTO_POS_CMD", "value": 20}'
var output = sendHttpPutRequest(url, contenttype, PUTrequest)
end
2020-01-24 11:02:26.741 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'home2.sitemap' has errors, therefore ignoring it: [2,2]: required (...)+ loop did not match anything at input 'switch'
2020-01-24 11:02:44.822 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'home2.items'
2020-01-24 11:02:53.767 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'home2.sitemap' has errors, therefore ignoring it: [2,2]: required (...)+ loop did not match anything at input 'switch'
2020-01-24 11:02:58.508 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'home2.sitemap' has errors, therefore ignoring it: [2,2]: required (...)+ loop did not match anything at input 'switch'
2020-01-24 11:04:19.930 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'home.sitemap' has errors, therefore ignoring it: [44,1]: no viable alternative at input 'switch'
2020-01-24 11:04:50.326 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.sitemap'
2020-01-24 11:05:26.350 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'home.sitemap'
2020-01-24 11:05:33.630 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home2.sitemap'
Okay, you’ve got two broken sitemaps. This is does not relate to your rule. Unless … what file are you editing your rule into?
testcase.rule
That’s one error then. Rules files need to named like xxx.rules, even if there is only one rule in it.
When you edit a rules file, you can check in openhab.log to see if the system loaded it or complains about it.