New rule language in OH3 ? What to prefer?

after three years with OH 2.x I plan to make a compelte new installation from my OH 2.5.11 system (than with OH 3).
including re-naming all the items, variables, …in a uniformly way (my mistake).
(i.e. actuall an item was named to: switch_livingroom, next one: sleeproom_switch)

In a german newspaper I read there is a new feature:
Rules can be defined in different languages like:

  • Groovy
  • Java Script
  • Python Jython

I know only the old “standard”, which was not so easy to understand …

createTimer(now.plusSeconds(30), [|
        if (Speedtest_Summary.state == NULL || Speedtest_Summary.state == "") Speedtest_Summary.postUpdate("unknown")

Is there a overview about the new possibility so I can easy decide if I will change to another rule “language” ?
Or should the old standard still used because of to much limitations from the “new” ones?

Scripts can be created with Googles: Blockly
Is this a good option to use?

thx for hints,

Please check out JRuby OpenHAB Rules System
It is: simple, elegant, easy to read, very powerful, just plain awesome

I started out using Rules DSL, then Jython, then when I found JRuby, I’m in love. Prior to finding it, I knew nothing about Ruby programming. It’s easy to learn if you have any programming background.

In JRuby that code would look like this:

after(30.seconds) do
  Speedtest_Summary.update("unknown") if !Speedtest_Summary.state? || Speedtest_Summary.empty?
1 Like

See this wonderful breakdown by rlkoshak:

There is a big update to the Blockly integration coming soon that will make it much more usable. I don’t know when that will reach a stable version of OH though.

Not really new. It’s just part of the core of OH now and not something that has to be installed separately.

There are additional languages to those too. And in most cases you have two options, building rules through the UI and building them in text files.

Except for Blockly, none of the other languages are going to be any easier to understand. Coding is coding and you will have to memorize special characters and formatting and stuff like that no matter the language.

In general the other languages are more capable than Rules DSL except for Blockly though, as JustinG mentions, there is about to be a big drop of new capabilities added to Blockly which makes it much more capable and feature complete. If should be available in the full 3.2 release that is coming in December (if they stick to the usual release schedule) or the next 3.2 milestone release if you don’t want to wait that long.

But don’t feel like you need to throw out the knowledge you’ve built and the library of rules you’ve written. You can continue on using Rules DSL or move gradually if that is what you prefer.

We implement ‘blank?’ for string items (just like activestate does for rails) which returns true if the item has no state or the string field is empty.

So you can do it like this.

after 30.seconds do
  Speedtest_Summary.update("unknown") if Speedtest_Summary.blank?
1 Like