Hey there,
I just updated to OH3 and I can‘t get 2 rules working. Other rules are working.
Maybe someone can help?
In OH2 I used a switch to execute something in command line. Unfortunately in OH3 this doesn’t work.
Rule Luftreiniger.rules
rule “luftreiniger einschalten”
when
Item Luftreiniger received command ON
then
executeCommandLine(“/etc/openhab2/rules/luftreiniger_an.sh”,1000)
end
rule “luftreiniger ausschalten”
when
Item Luftreiniger received command OFF
then
executeCommandLine(“/etc/openhab2/rules/luftreiniger_aus.sh”,1000)
end
execureCommandLine changed in OH 3. I see the docs haven’t been updated for that yet. If I recall correctly, the timeout now is the first argument, the command is the second, and reach argument to the command is a separate argument after that.
Hey everyone, just wanted to add something perhaps it saves someone some time, OH3 is only executing my script if I add “bash” like this
var result=executeCommandLine(Duration.ofSeconds(5), “bash”,"/etc/openhab/rules/off.sh")
then the first row does not have the shebang ( Shebang (Unix) - Wikipedia ) which is required to define the script interpreter or execute permission is missing.
Put debugging in your shell script like creating a file with date timestamp and a message every time it is exeucted. Second have a look to syslog messages to check if there is a message about running sudo.
thx for your time , i increment the second to “20”
here is the rules:
var results = executeCommandLine(Duration.ofSeconds(20), "/usr/bin/sudo","sh","/etc/openhab/scripts/BackupCli.sh")
logInfo("exec", "exec result - {}", results)
now in frontail i recieve this :
2021-03-19 13:00:55.891 [INFO ] [org.openhab.core.model.script.exec ] - exec result -
Using '/etc/openhab' as conf folder...
Using '/var/lib/openhab' as userdata folder...
Using '/usr/share/openhab/runtime' as runtime folder...
Writing to '/media/backup/nas/Backup-Openhab-Cli/openhab3_Test-Cli-21_03_19-13_00_46.zip'...
Making Temporary Directory if it is not already there
Using /tmp/openhab/backup as TempDir
#########################################
openHAB backup script
#########################################
Copying configuration to temporary folder...
Removing unnecessary files...
Zipping folder...
Removing temporary files...
Success! Backup made in /media/backup/nas/Backup-Openhab-Cli/openhab3_Test-Cli-21_03_19-13_00_46.zip
where the "var result " as value " exec result - "
thanks a lot for your time , i don’t ave the skills for that , have you a link or target for learning ? is linux learning ? thera arent many languages whe need to know in openhab , and the more difficult now with the 3.0 is what whe need and where to learn