openHAB 4.0.2 Blockly rules not working

Hello everyone,
I was running OH 3.4 on a Raspberry Pi 4. After updating through the openHABian config, my branch was automatically switched to version 4. Is this intended?

Because I was on Buster, the installation of OH was broken, so I started with a fresh install of Bullseye with OH 4.0.2. After importing the configuration from the previous installation, none of my Blockly rules were working. So I checked if JavaScript scripting was installed and opened and saved one of the simple rules, but with no luck. The rules are not working and I get the following error:

[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID '471888a8c7' failed: org.graalvm.polyglot.PolyglotException: TypeError: Light.sendCommand is not a function

Can you please advise what I am missing?

Another strange thing is that all of my items are listed as non-semantic. I do not see them in the model, but that is for another topic. I just mentioned it in case it is connected somehow.

Thank you very much.

without knowing your rule nobody can help

How to ask a good question / Help Us Help You - Tutorials & Examples - openHAB Community

The correct approach would have been:

  1. on 3.4 updating to bullseye first
  2. start update procedure of within openhabian-config as there will be running a script which prepares your config to be used for OH4
  3. update to OH4
  4. do another backup :slight_smile:

If you have a backup of your 3.4 config, I recommend setting up OH3.4 from a fresh image, restore your config and start with step 2.
Please read carefully the upgrade docs

Thank you for answer,
I think the issue is not connected with the rule itself, but anyway:

var Light;

// Pick Relay output
Light = 'Lights_Workshoplight';
if (items.getItem(Light).state == 'OFF') {
} else {

Rule is saved with scripting language ECMAScript 262 Edition 11

Thank you for your answer.
I started with a fresh install of openHABian 1.8, which installs openHAB 4 by default.
The issue is that I do not know how to revert back to 3.4.5 as you suggested.

Download v3.4 from here:

There is a breaking change in blockly.

In OH3.4 the sendCommand block required the item name as string as input.
In OH4 instead of the name of the item an item object is required.

You can use the getItem block to solve this.

Please have a look here:

Have a look at OH3 → OH4 ( backup; new install with initial restore; upgrade afterwards ) ( the original title of that entry is different; but steps are listed there )

The openhabian menu entry internally uses openhab-cli backup and openhab-cli restore these commands create and use a zip file that includes all necessary OH configuration files including bindings and their setup. Stuff like external databases and their content, additional services that you added besides OH are not part of the backup.

Thats it, thank you very much for the hint.

Thank you very much for all the informations, at the end I installed the openHABian 1.8 with “clonebranch=openHAB3” and “java_opt=11”.

1 Like