Controlling a Tech Boiler controller with curl command

Hi everyone,
i have a boiler controller from TECH (Polish company) which after some internet digging i found out that i can control it through network sending some curl commands.
So when i send from terminal the command :

curl "http://xxx.xxx.xxx.xxx/admin/cgi-bin/edition.cgi" -H "Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxx" --data "st=654_48" -s

It sets my DHW temp (654_) to 48.
How i can intergarte this to openhab so i can set my DHW temps?
I already tried

executeCommandLine("curl@@http://xxx.xxx.xxx.xxx/admin/cgi-bin/edition.cgi@@-H@@Authorization:@@Basic@@xxxxxxxxxxxxxxxxxxxxxxxx"@@--data@@"st=654_48"@@-s)

in a rule but it doesnt seem to be working.
Thank you in advance.

I think you’re missing some double quotes, and probably also need to escape the double quotes, e.g.

executeCommandLine("curl@@http://xxx.xxx.xxx.xxx/admin/cgi-bin/edition.cgi\"@@-H@@\"Authorization:@@Basic@@xxxxxxxxxxxxxxxxxxxxxxxx\"@@--data@@\"st=654_48\"@@-s")

But when I get lost in @@s I just create a simple bash script that can be reliably called by an executeCommandLine. So if the above doesn’t work you could try that.

Use sible quote inside the double quotes. Linux is happy with that
No need for @@ instead of spaces. That’s in the binding only.
Add a timeout at the end.

executeCommandLine("curl 'http://xxx.xxx.xxx.xxx/admin/cgi-bin/edition.cgi' -H 'Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxx' --data 'st=654_48' -s", 5000)

Hi thanks for immidiate replys.
When i try to run the rule i get the error below in the console.

Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "curl 'http://xxx.xxx.xxx.xxx/admin/cgi-bin/edition.cgi' -H 'Authorization: Basic " (in directory "."): error=2, No such file or directory)

Have you tried a direct curl in the command line with single quotes?
Does that work?

Yes it is working with single quotes from cmd.
And from the logs i see

16:58:53.074 [INFO ] [clipse.smarthome.io.net.exec.ExecUtil] - executed commandLine 'curl 'http://xxx.xxx.xxx.xxx/admin/cgi-bin/edition.cgi' -H 'Authorization: Basic am9obnltMzA6cDQ1NXcwcmQ=
' --data 'st=654_54' -s'

when sending the command i realized that at my authorization code i miss some characters.
My auth code is am9obnltMzA6cDQ1NXcwcmQ=\r\n while in the logs it misses \r\n

You need to escape the \r\n in the string

ok one step further but the command doesnt seem to execute

17:44:31.449 [INFO ] [clipse.smarthome.io.net.exec.ExecUtil] - executed commandLine 'curl 'http://192.168.1.53/admin/cgi-bin/edition.cgi' -H 'Authorization: Basic am9obnltMzA6cDQ1NXcwcmQ=\r\n' --data 'st=654_50' -s'

Maybe something with the quotes??

Try extending the time out
and do this:

val String response = executeCommandLine("curl 'http://192.168.1.53/admin/cgi-bin/edition.cgi' -H 'Authorization: Basic am9obnltMzA6cDQ1NXcwcmQ=\r\n' --data 'st=654_50' -s", 10000)
logInfo("TEST", response)

i get this in the logs

23:25:27.920 [INFO ] [g.eclipse.smarthome.model.script.TEST] - 

What does the curl command normally returns?

I tried it with the read command that sends me data back

val String response = executeCommandLine("curl 'http://192.168.1.53/admin/cgi-bin/edition.cgi' -H 'Authorization: Basic am9obnltMzA6cDQ1NXcwcmQ=\r\n' --data 'gt=654' -s", 10000)
logInfo("TEST", response)

if i run this command i get in the terminal 654_40

from the karaf console running the rule i get

11:02:06.716 [INFO ] [g.eclipse.smarthome.model.script.TEST] - 

I am running out of ideas…

Maybe?

val String response = executeCommandLine("curl 'http://192.168.1.53/admin/cgi-bin/edition.cgi' -H 'Authorization: Basic am9obnltMzA6cDQ1NXcwcmQ=\\r\\n' --data 'st=654_50' -s", 10000)
logInfo("TEST", response)

If i dont add a timout i get

12:30:08.455 [INFO ] [g.eclipse.smarthome.model.script.TEST] - null

Is there any way i could do that with a script? for i have some scripts that are working flawlessly with executecommandline.

Possibly, put the curl command in a script and call the script

Ok although i dont have programming skills that would be the easy part, but how i can pass a command to the script.
Right now you can see what i was trying to accomplish with the rules below.


 //Set DHW Temp
rule "Set DHW Temp to Boiler"
when
    Item SetDHWTemp received command
then
	executeCommandLine(" curl 'http://192.168.1.53/admin/cgi-bin/edition.cgi' -H 'Authorization: Basic am9obnltMzA6cDQ1NXcwcmQ=\\r\\n' --data 'st=654_" + receivedCommand + "' -s" , 10000)
	end

If there is another way to do it, i would be more than happy to hear it!!!

ok i made a simple script

#!/bin/bash                                                                                                                                                                                     
DHWTemp=`curl "http://192.168.1.53/user/cgi-bin/edition.cgi" -H "Authorization: Basic am9obnltMzA6cDQ1NXcwcmQ=\r\n" --data "st=654_45" -s`
#

and with the rule

rule "Send DHW Temp to Boiler"
when
    Item DHWSet received command
then
	executeCommandLine(" /etc/openhab2/scripts/setdhwtemp" )
end

My temp changes to the value i set to the script (st=654_45)
if i change 45 to 50 it will change my temp to 50.
How can i work this out now, everytime the item DHWSet receives a command (a number i suppose in my example) to be inserted in the script?