Hi guys!
I'm having some problems with the sendHttpPostRequest action but I don't know what I'm doing wrong, so I need your help :(
My idea is to post my power consumption values (I get them from a Zwave GreenWave Reality PowerNode) to emoncms (a local installation in my server) and for that I'm using the input API with json. The API command for uploading a value works like this:
"power" is the name of the feed, "200" the value and "xxxxxxxxxxxxxxxxxxxxxxx" is my api key. If I enter this url on my web browser, everything works correctly.
To use this on OpenHab I've thought of using the sendHttpPostRequest action in a rule. Here you have what I've tried:
rule "Post to EmonCMS"
when
Item mediaserver_consumption changed
then
var String url
var double value = new Double(mediaserver_consumption.state.toString())
sendHttpPostRequest(url)
end
For testing purposes I'm sending a predefined feed and value (power:200) and not the correct information (mediaserver_consumption:value), but obviously I will change that once I get this working. The problem is that everytime the rule is executed I see the following error in the openhab.log file:
What does "Invalid query" mean? Is there any syntax error in my URL? If the URL is working correctly in the browser, why doesn't it behave correctly in sendHttpPostRequest? Do you know any alternative method to post the information to EmonCMS without using external scripts? I don't want to use the commandLine action and a python script for doing this, the perfect solution would be to use a native rule...
Many thanks for your replies and help, I appreciate them a lot.
Best regards,
Aitor