After migration to OH3, the executecommandline function is not doing it anymore. I decided to rewrite my rules using the code editor of the webUI as ECMA script. Hope I get the terminology all right here. I had to do some digging, but the code below is supposed to do it.
Note, the script I had in OH2 executed the i2cset command without problems on exactly the same PI. Further, when I run the following command, the attached relais switches off, as expected.
sudo -u openhab /usr/sbin/i2cset -y 1 0x11 0x10 0x00
There is no relevant output in the logs after executing the rule, unfortunately. Here the relevant part of the rule:
var hex="0"
var Exec = Java.type("org.openhab.core.model.script.actions.Exec");
var Duration = Java.type("java.time.Duration");
var res = Exec.executeCommandLine(Duration.ofSeconds(5),"/usr/bin/sudo","/usr/sbin/i2cset -y 1 0x11 0x10 0x0"+hex)
same for this:
var res = Exec.executeCommandLine(Duration.ofSeconds(5),"/usr/sbin/i2cset","-y 1 0x11 0x10 0x0"+hex)
- Platform information:
- Hardware: RPI3
- OS: Debian
- Java Runtime Environment: OpenJDK Runtime Environment (build 11.0.9.1+1-post-Raspbian-1deb10u2)
- openHAB version: openhab/stable,now 3.0.0-1 all [installed]