Moving Blockly Script betwen OH3.4.2 Installation

I have 2 OH3.4.2 installation, one for development and one for automate my home.
I need to move some Blockly script between 2 site. It is possible?
ITEM used in blockly rules in dev are not available on production site, but Items have other names


It’s not so easy to move just one or two rules but not impossible. You have two options.

The first option is to open the Code tab of the rule, copy the YAML you fine there. Then on the new instance create a new rule, fill in the proforma (name, id, description, tags, etc.), click the code tab and paste the YAML there.

You’ll need to manually change the Item names. Given it’s Blockly and it needs to be changed in two places in the YAML (the XML and the JavaScript) I recommend changing them on the Design tab instead of the Code tab.

For the second approach, you’ll need to use the API Explorer. Under Rules use the end point to query for the rule you want to move. Copy the JSON that gets returned. Then on the other OH instance use the API Explorer to POST the JSON to create the rule on the new instance.

Again, you’ll have to manually change the Item names prior to copying it or after you paste it into the new instance.

In the future, you’ll save some effort if you use the same Item names in both instances.

1 Like

Hi @rlkoshak
as usual thanks for full explanation.
Is there in plan to have import/export funtionality of rules in future release?

Not that I’m aware of. As with text based config files, it’s copy/paste/edit.

1 Like

Openhab 4.0 will have blockly 9.0 which has a cross-copy function. With that you can copy a blockly tree between multiple tabs. @stefan.hoehn posted some screenshots about the feature.

1 Like