OH3 Rules / Scripts and CommandLine

  • Platform information:
    • Hardware: Intel i9 9900 with 32GB of memory
    • OS: Arch Linux
    • Java Runtime Environment: Zulu Embedded 8 Java 11 OpenJDK
    • openHAB version: OH3 3.10 Snapshot
  • Issue of the topic: Executing command-line from a Rule/Script.

I am creating a rule that is supposed to execute a command when a switch changes status.

I’ve created a switch item to control my Roku. The switch seems to work just fine as it is toggling across all devices and updating.

I created a rule that is supposed to execute a command when the state changes however, nothing happens when I flip the switch.

I have tried creating the rule in /etc/openhab3/rules/home.rules and creating the script on the web UI. Both cases don’t work.

Here is what I have tried in /etc/openhab3/rules/home.rules:

rule "Roku On"
            Item rokuPower received command ON
            executeCommandLine(Duration.inSeconds(5), "curl -d ''")

In the rule creator UI web tool, I create the rule like the following:

  - id: "1"
      itemName: rokuPower
    type: core.ItemStateChangeTrigger
conditions: []
  - id: "2"
      type: application/javascript
      script: executeCommandLine(Duration.inSeconds(5), "curl -d ''")
    type: script.ScriptAction

Here is a screenshot of the UI:

Are there any known issues with sending commands to command line or am I completely doing this wrong? Thanks, and any help is appreciated.

First of all OH3 requires Java 11

I would have guessed it needed to be under /etc/openhab/rules

no more conf folder?

Thanks for the responses, I am not sure how I got the wrong Java version, but zulu-embedded-8 was wrong because OH3 wouldn’t even start with that (I had that installed for OH2)… I am running Java 11 OpenJDK.

[root@banshee openhab3]# archlinux-java status
Available Java environments:
  java-11-openjdk (default)

As for the configuration folder/location; /etc/openhab/rules doesn’t exist nor does it work, however, when I add to /etc/openhab3/rules/home.rules, the rules populate in the web UI.

To further clarify, other switches and rules are working, just not rules with command line execution.

Problem solved. The commands weren’t whitelisted.

Sorry typo. I thought they got rid of the version number in the folders.