Hi folks,
After getting no where with zone2 with the yamaha binding I decided to try my luck with the execbinding, however im still running into an issue where the rule triggers and says my command is executed, but nothing happens. If I copy and paste the command form the log file it works, so i would assume the formatting is correct. I’ve read through the several related topics out there but couldnt seem to come to a solution and was concerned not all applied to my oh2 installation.
Output from Log after using my virtual switch
17:47:14.959 [INFO ] [marthome.event.ItemStateChangedEvent] - vAV_Power_Zone2 changed from OFF to ON
17:47:14.960 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine '/usr/bin/curl -X POST -H "Content-Type: text/xml" -H "Accept: text/xml" -H "Cache-Control: no-cache" -d '<YAMAHA_AV cmd="PUT"><Zone_2><Power_Control><Power>On</Power></Power_Control></Zone_2></YAMAHA_AV>' "http://192.168.1.100/YamahaRemoteControl/ctrl"'
Rule file
rule "Zone2"
when
Item vAV_Power_Zone2 changed
then
executeCommandLine("/usr/bin/curl -X POST -H \"Content-Type: text/xml\" -H \"Accept: text/xml\" -H \"Cache-Control: no-cache\" -d '<YAMAH$
end
Ive tried adding in @@ between the spaces, ive tried executing a script using callscript from within the rule, nothing seems to work. However if I copy the command from the logging output and run it in my usershell as myself it runs correctly. Not sure if that means permission issue, but was hoping someone could help me nail down the issue.
Where should I be looking to see the outputs of this logInfo? in the Karaf console with log:tail I see the following… the only new output is the script.test - line.
20:36:27.526 [INFO ] [marthome.event.ItemStateChangedEvent] - vAV_Power_Zone2 changed from OFF to ON
20:36:27.530 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine '/usr/bin/curl -X POST -H "Content-Type: text/xml" -H "Accept: text/xml" -H "Cache-Control: no-cache" -d '<YAMAHA_AV cmd="PUT"><Zone_2><Power_Control><Power>On</Power></Power_Control></Zone_2></YAMAHA_AV>' "http://192.168.1.100/YamahaRemoteControl/ctrl"'
20:36:27.531 [INFO ] [.eclipse.smarthome.model.script.test] -
This is what my Rules file looks like now:
rule "Zone2"
when
Item vAV_Power_Zone2 changed
then
val results = executeCommandLine("/usr/bin/curl -X POST -H \"Content-Type: text/xml\" -H \"Accept: text/xml\" -H \"Cache-Control: no-cache\" -d '<YAMAHA_AV cmd=\"PUT\"><Zone_2><Power_Control><Power>On</Power></Power_Control></Zone_2></YAMAHA_AV>' \"http://192.168.1.100/YamahaRemoteControl/ctrl\"")
logInfo("test", results)
end
You can also try and add the -v (verbose) argument to the curl. It will show what the headers are that are returned so you can tell what sort of error you are getting.
So weird, If I run the exact command using ‘sudo -u openhab’ from the command line the command works as expected, when I ran the verbose option i didnt see any additional logging in karaf.
given the above is it still worth trying to run openhab as root? if so how would I do that under a linux installation?
Just got it working! I saw another post where you had suggested to use the execcommand with a timeout value. As soon as I added that the command now works.
But when put this in the rule, the line is executed, but no message will send.
Also no error on log, also loginfo/results for the curl comamnd is empty.
(logInfo “ALARM !!!” is written)
You have to give executeCommandLine a second parameter telling it the maximum number of milliseconds to wait for the command to finish executing. The command must return within that amount of time or there will be no result.
Without the timeout, it runs the script in the background, the call immediately returns, and there will be no result returned from the command.
Hello,
I add at thhe end:
… et/1/messages.json",5000)
but still the same:
No error in log, also the logInfo “resultes” is still empty.
When sending the curl-command from Linux shell (as user openhab) the message was send successfully in less than 1 second: (I receive the message on the smartphone),
and on the shell there is the message (output):
{"status":1,"request":"cec6xxxxxxxxxxx16}
Wondering, why from openHAb - rules / executeCommandLine it will not work.
Maybe a (stupid) beginner mistake form my side, because new in opeHAB and new with “executeCommandLine” …
However, will be interest, why “my” curl will not work as exepected in the rule.
I can test further if new hints received (actuall the curl-code is only commented out).