Eli.Roz
(Eli Roz)
February 8, 2020, 9:47am
1
Platform information:
Hardware: RP3
OS: openhabian
openHAB version:2.5
Issue of the topic: tried to configure a light to turn on at Sun set (astro binding) and turn off at 1:00 with no success.
What should be the correct configuration for this?
I can’t understand the difference between status changed, status updated, trigger channel fired, etc…
Any guide is available?
sihui
(SiHui)
February 8, 2020, 10:24am
2
Eli.Roz:
Any guide is available?
EDIT: This is getting too long for one posting. I’ve split it up (thanks @ysc ’s write-up for HABot for giving me the idea).
This is a series of postings to start writing and gathering what we know works and what doesn’t yet work in the Rules that can be created through PaperUI. In particular I’m interesting in what we have access to and not in self written scripts.
I’m making all of these a wiki so please add your contributions to the OP instead of in comments if you have something that works…
Installation
In PaperUI select “Add-ons” and the “MISC” tab.
Install “Rule Engine (Experimental)”
Once installed you should see a new Rules option on the left panel in PaperUI.
[image]
NOTE: Yes I know the image is fuzzy, I’ll take new screenshots before creating the PR to the Docs.
If you plan on using Jython or Groovy to write your Rules, see the JSR223 Rules documentation for your language of choice. Don’t lose this link. We will be referring to it for the JavaScript as well. Currently, …
Your First Rule
Prerequisites
Create a Switch Item named Test. We will use this to trigger our Rule. Give the Item a label because the Items are listed alphabetically by label. If you skip the label, the Item ends up at the bottom of the list.
Create the Rule
In PaperUI, select Rules from the left.
Press the big + to create a new Rule.
[image]
You will find several fields to fill out.
[image]
Field
What to fill in
Name
Give the Rule a unique and meaningful name.
Description
Expla…
[Edit: Moved the Actions to their own
Writing Scripts
As you can see a lot can be accomplished in the NGRE without writing scripts at all. Much more than is possible with just Items. However at some point writing a script will be required. We know that the scripts entered into the Script box need to be JavaScript but how do we do all the stuff we are used to in Rules DSL like creating Timers, calling Actions, working with Groups and Items?
JSR223
Remember when I wrote that users of JSR223 Rule…
Other Functions and Actions
OH supports a number of functions which allow one to cause something to occur in a script such as sending an email or scheduling something to occur at a later date. There are a number of built in functions and a number of add-ons called Actions that can be installed and used.
createTimer
Schedules a function to execute sometime in the future.
// Native Quartz version
var ScriptExecution = Java.type("org.eclipse.smarthome.model.script.actions.ScriptExecution");
var D…
or use Jython:
I just submitted a PR that adds a core feature for a JythonScriptEngineFactory and it would be great to have some testers! Basically, this will allow for the installation of Jython including the core and community helper libraries through Paper UI, once the PR is merged. If you’d like to test it, you’ll need to…
Have OH 2.5.x (S1778) or newer
Shutdown OH
Backup OH
Download the bundle that matches your OH version to OPENHAB_CONF/addons/. The jar contains the core and community helper libraries…
1 Like
5iver
(Scott Rushworth)
February 8, 2020, 11:05am
3
Welcome to the forum! The UI rule editor is a great place to start for people new to openHAB, but it is still being developed and has some quirks. It will be revamped in OH 3.0. You’re welcome to try it, but by far most people are using text based rules using either scripted automation with helper libraries (new rule engine) or the rules DSL (old rule engine). There is not much support in the forum for UI rules, but there’s not much to them either!
Install the Astro binding (ask if you need help), create Things, create Items, and link the Items to the Channels in the Things. Install the new rule engine. Open Paper UI and create a new rule that looks like this…
Then create another rule like this…
There are some cron expression calculators listed in the Trigger documentation (see below).
Eli.Roz:
I can’t understand the difference between status changed, status updated, trigger channel fired, etc…
The documentation for triggers is here…
3 Likes
Eli.Roz
(Eli Roz)
February 8, 2020, 1:46pm
4
Ok, seems I totally missed the channels and virtual switches logic.
Will try this out.
Thanks a lot.
5iver
(Scott Rushworth)
February 8, 2020, 1:57pm
5
No virtual switches needed… that was just a test Item I had laying around. Replace Virtual_Switch_1 with the Item linked to your light.
Eli.Roz
(Eli Roz)
February 8, 2020, 1:59pm
6
Ok, so basically in my case I had to use trigger channel instead of status changed or updated.
And what’s the reason to use cron trigger?
Thanks
5iver
(Scott Rushworth)
February 8, 2020, 3:09pm
8
The one rule will turn the light ON at sunset. The other one will turn the light OFF at 1:00AM. Isn’t that what you were looking to implement?
Eli.Roz
(Eli Roz)
February 8, 2020, 3:43pm
9
Exactly, and it actually works, thanks a lot!!!
1 Like