openHAB 3.0 Milestone 2 discussion

Some highlights on the frontend side for this release:

Scripts

You can now use the UI to write “scripts”, which are rules that don’t have any triggers or conditions but a simple script action to execute your own code. When you create a script you’re just asked for an ID, label, description, and the language you prefer:

image

openHAB has support for ECMAScript (aka. JavaScript) and its Rule DSL by default but you can now add more languages by installing automation add-ons - a new add-on category; Groovy is the first language you can install but I’m sure there will be more.

Since Scripts are actually Rules, you can trigger them from other (UI-based) rules with the ‘Run Rules’ action. You can also run them on-demand, either while editing them, or with the ‘run rules’ action in widgets that support it.

The Settings menu has been modified a bit to carve out the automation-related menu entries into a new “Automation” group.

image

When you’re editing a Script (or an inline Script of a rule condition or action) you have several keyboard shortcuts that you can use:

  • Ctrl-D: disable/enable the rule
  • Ctrl-S: save the rule
  • Ctrl-R: run the rule (ignoring the eventual triggers and conditions)
  • Ctrl-B: switch back and forth to the Blockly view and the Code view (only for Blockly rules, see below)

You might see more options in that Automation area in the future, like Scenes - just set the desired items to the state you want and easily reset these items to these predefined states in bulk - it will still be a rule but with a separate UI to configure it.

Blockly

openHAB 3.0.0.M2 has experimental support for Blockly as an alternative way to write your JavaScript script conditions and actions in rules (and now standalone “Scripts”) that you edit via the UI.

There are a number of limitations:

  • Blockly is only available in Script rules, actions and conditions when you select ECMAScript as your language of choice;
  • when you start writing your own JS code, you cannot switch to Blockly - you have to start from scratch to build your rule with Blockly. Just erase the code and you will see the button appearing again;
  • when you start designing a rule with Blockly, you can have a preview of the JavaScript code that will be generated, but you cannot edit it - the only way you can go back to writing your own code is to delete everything in the Blockly view and switch back to the Code view (with Ctrl-B or the button on the lower-right corner).

There are only a few blocks in the openHAB category currently to interact with your system, so it’s quite limited - but in many cases reading and writing items will be enough at least for now!

image

It’s bound to be expanded, but there are only so many hours in a day. I can imagine being able to call thing actions or making HTTP requests, and more, and there is much to do in that area - if you’re willing to contribute new blocks, and can understand a little JavaScript, please step up, contributors especially in that area would be appreciated! I’ll be glad to assist you in how to write them.

Autocompletion Everywhere

Many of the Code views you see throughout the UI now have “smart” autocompletion to help you write your code - whether it’s Things (a new way of configuring them in the UI), rules, pages or widgets, you can hit Ctrl-Space on your keyboard and chances are, you will get some hints:

image

It’s not perfect, and there are still ongoing issues with it, but overall it works pretty well and will help you configure stuff way easier when you choose to edit a little bit of YAML instead of clicking through the UI - just hit Ctrl-Space when in doubt and you might get the insight you need.

By the way - previously the errors in a YAML code editor would be displayed in an area below which would take a lot of screen real estate; now the errors are shown with wavy underlines and tooltips:

image

Widget Variables

Using variables and expressions has been expanded to sub-properties, like classes or CSS attributes, and there are now “input” widgets in the System, Standard (standalone), System (list item) libraries that can be used to receive text, numbers, dates and the like. For example have a look at the Keypad widget as a first example of what these facilities combined together can do:

@RGroll is also making a Weather widget that you’ll want to check out too:

Misc

There are a lot of other improvements, check them out here!
Hope you like this release - next one will likely focus on giving you a nice home page!

24 Likes