Rules are not loading on new install

I am new to openhab, technically i played with it once many years ago but never adopted it. Now i am looking to migrate from smart things due to the new smart things migration and i am honestly tired of a cloud solution and want something centralized. My setup is using virtual box with a fresh latest and the latest and greatest ubuntu install. I am utilizing a Aeotec Z-stick gen 5 for zwave. I used zulu java 8 as the docs require and I have gotten a few things paired so i can test things out before i fully commit all of my devices to this solution. I am able to control them and see them updating inside of the events.log. Where i am having issues is rules. After the install i found that the rules directory under etc did not exist. I have installed it 3 times now and never is it created out of the box. Each time i have tried creating this manually and creating a default.rules file. I have also made the permissions on these as 777. I have of the most simplest rules at this point just trying to get this working. I dont see in the events.log my log entry i have tried creating in the rule and when i look at openhab.log i dont see any log entries pertaining to if the default.rules has even been loaded. i found the org.ops4j.pax.logging.cfg file and went and updated many of the log level entries here to ALL and still nothing in any logs indicating if the rules file is being loaded or that my rule is being executed. Here is the contents of my default.rules at this time.

rule “test”
when
Item zwave_device_84feb206_node23_switch_binary changed
then
sendCommand(zwave_device_84feb206_node23_switch_binary, OFF)
end

I got the device name specifically from my event.log and i do see in the event log where it is updating the status when i turn the device on but it never switches back off. Any help would be appreciated!

Welcome to the forum! Scripts for use with the new rule engine should be placed in $OPENHAB_CONF/automation/jsr223. The automation and jsr223 directories need to be created. Rule files for use with the legacy rules DSL should be placed in $OPENHAB_CONF/rules.

Your posts will look much more readable if you use code fences around logs and code. See #12

Your rule is not logging anything. Try this…

rule "Test rule"
when
    Item zwave_device_84feb206_node23_switch_binary changed
then
    logInfo("Test rule", "zwave_device_84feb206_node23_switch_binary changed to {}", zwave_device_84feb206_node23_switch_binary.state)
end

You’re looking in the wrong place somehow. Exact location depends on your install - something like ../conf/rules It has a readme in it, so you’ll know you found the right folder.

1 Like

Thank you @5iver and @rossko57. @rossko57 had it right on the money. Me coming from primarily windows world i assumed that $OPENHAB_CONF was the /var/lib/openhab2 where what i assumed was the openhab2 install when actuality it turns out this path is /etc/openhab2/rules. I am a .net developer by career with a history in windows server administration. I got this working now that i have been put on the right path. @5iver thank you for mentioning the jsr223 path. I see that it supports groovy and javascript which are 2 things i am more familiar with. Off to start converting my whole house now!

In case you haven’t found them yet, the helper libraries may be useful for you…

https://openhab-scripters.github.io/openhab-helper-libraries/index.html

There is really nothing for Groovy yet, but there are some libraries for JavaScript. The problem is that we are currently stuck with ECMAScript 5.1. If you are a coder, you may want to look into Jython, which is Python for the JVM. The libraries for Jython are light years beyond the other scripting languages. Most of what you find for scripted automation (JSR 223) in the forum will be Jython. I also have a beta add-on that will simplify the installation…

Thanks for the info. Right now priority one is to get all of my things switched over. I have some esp’s running st_anything to control garage doors and act as temp/humidity sensors so i have to find alternatives for those as well. I think espeasy with mqtt should work but haven’t tried it yet. If i find a activity that i need more control i will take a look.

That works… some use Tasmota. I just use PubSubClient for MQTT on my NodeMCUs. You’ll need the MQTT binding and some rules. You will find lots of examples in the forum.

That is because of the filesystem hierarchy standard.