Perhaps I just can’t see the forest for the trees, but is there a tutorial somewhere on how to use the new rules with scripts? I never used scripted rules except some JS-transformations, so I don’t seem to get, how I can use variables like channels or variables in jython or JS - and how I start the rules and whatnot…
I’m lost and need some intro to using UI-based OH3 script rules which not only change items’ states but use complex logic to achieve something like shutters or the likes!
To be honest we’re a bit behind with those docs.
I am trying to collect the informations where they are available.
Probably there is already some content in the documentation area.
Currently we are finishing the beginner tutorials which are getting moved from the documentation area too.
But you and all others are invited to start with some tutorial/docs page while exploring it and contribute that to the docs.
Thanks for the heads up!
If I can fight my way through, I’m happy to contribute! I’ll give it a try this afternoon…
If github is the problem don’t mind to start here in the docs area with a wiki post.
Copy/paste at a later state to get it in the website is done quick and easy.
There is a good deal of content around but not much in the Getting Started Tutorial yet.
Note that the above is all focused on creating rules through the UI. If you will be writing rules in text files the Helper Libraries docs, in particular the But How Do I… page is great. Note that I don’t think the Helper Libraries are ready for OH 3 yet.
Ok cool, thx. Python were sufficient for me. seams to be this one
A last (maybe stupid) question
When I want to write my own rules where is the entry point for the documention? An example:
The “Example rules for a first impression” example.
"cronExpression": "0 * * * * ?"
where can I find TypeUID definition (timer.GenericCronTrigger) for GenericCronTrigger and the regarding configuration object, the Syntax “cronExpression” string itself and its parameter, for example when I want to create a channel trigger, without deep diving into the Java Source code.
API parameter for the Configuration constructor is just a map/Hashtable in case of the timer.GenericCronTrigger two strings for key and value. Where I have to look for the correct parameters…
Update: Found this is defined in the trigger handler. Is this the only way to determine those parameters?
That stuff is why I strongly recommend using the Helper Library. Then defining a rule is as simple as:
from core.rules import rule
from core.triggers import when
@rule("My rule name")
@when("Item MyItem changed")
# your rule's code goes here
If you don’t want to use the Helper Libraries, than at least look at the library code for how it does various things like this.
Hopefully the helper-scripts gets soon the oh3 compatibility…Are there plans to integrate such a “lowcode” API directly into openhab?
There is already a PR that makes it work with OH 3.
I believe the plan is to make it available as an add-on.
There is also plans to (just in the discussion stage at this point) to have marketplace where add-ons, rules libraries, and widgets could be distributed. But that’s long term.
With the pull request the helper scripts are working Thank you
git clone https://github.com/openhab-scripters/openhab-helper-libraries
git fetch origin pull/376/head:oh3comp
git branch -a
git checkout oh3comp
cp -r automation/* /opt/openhab-fresh/conf/automation/
@Race666 Your 3 git commands in the middle can be condensed into a single command:
git checkout oh3-patch