Where are the rules stored ? And can I modify them?

The openHabPaperUI contains a section where I creadted some RULES.
These rules do not appear in the “\openhab2-conf\rules”
Where are the rules stored ? And can I modify them with “VisualStudio” ?

The rules in PaperUI are limited.

To modify rules you will need to create them in a rules file that’s located at /etc/openhab2/rules

In VSCode you should see your rules folder in the menu. Right click on rules and select New file then name it somerule.rules

Here is an example of a rule to remind me to take the trash out on tue and fri at 7:25

rule "trash reminder"
    Time cron "0 25 7 ? * TUE,FRI *"
    Echo_Plus_TTS.sendCommand('Remember to take the trash out')

Just to clear things up a bit. PaperUI and Experimental rules engine is different from plain old textual rules. AFAIK they can’t be mixed.

Only textual rules can be written and modified with VS Code and the openHAB extension.

yes thats clear.

But these rules from PaperUI must be stored somewhere. Where will I find them ?
I wanted to copy them to the xxx.rules file in order to make there some modifications.

Can’t answer that but a if I had to gues I’d say they are saved somewhere and in the internal filesystem/database like all other stuff in PaperUI. @rlkoshak can you enlighten us?

Can you find anything in the docs stating this is possible?

I don’t know where they are stored but they will no be written in DSL so you won’t be able to just copy and paste them into a rules file anyway.

Correct, these Experimental Rules are a complete replacement for Rules DSL. They have almost nothing in common with each other. You will not find anything in the rules folder nor will you find any .rules files when using the Experimental Rules Engine.

They appear to be stored in userdata/jsondb/autmation_rules.json (/var/lib/openhab2/jsondb/automation_rules.json for installed OH).

Yes but only because VSCode is just a text editor and JSON files are just text files. But you will not have any of the IDE like features you would get by using VSCode to write Rules DSL rules.

The Rules written in this language are not very well suited for manual editing, though you can do so if desired. Manually editing complicated JSON is pretty miserable though. The usual warnings apply when manually editing JSONDB files, mainly don’t do so while OH is running.

If you want to manually edit or write your Rules you should use Rules DSL Rules of JSR223 Rules.

This is correct. They are completely different beasts.

This isn’t strictly true as VSCode can edit ANY text file. But you won’t get the nice code syntax checking and highlighting that you get with Rules DSL. And the raw text format of the Experimental Rules Engine is not very human friendly so I would strongly recommend against the attempt to do so, but it is not impossible.

You would need to completely rewrite them. They are two completely different languages.

One reason why it’s called “experimental” is that there are very few docs written yet, not to mention that the capabilities of the Experimental Rules engine are not yet complete.


Superb answer as always :+1: Thanks Rich!