How to duplicate Blockly scripts?

Being a non-programmer, i.e. not very good at editing code, I would like to duplicate a Blockly generated script, to be able to replicate and modify it using Blockly. I have not been able to find any solution for this from my research in the documentation and community posting and trial-and-error testing, unless using text coding. Creating a Blockly editable library item would be great, but whatever I create in the library Blockly editor does not get saved for some reason. It seems only doable through coding. Is there a kind soul to help a newbie?

Many thanks;

  • Platform information:
    • Hardware: Raspberry 3
    • OS: OpenHabian
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version:3.3

When you create a rule out script containing blockly code, the UI will also wow you the yaml code of the rule. You can copy and paste this

Hi - yes, I can copy/paste the code into a new script - but it does then no longer give me the option of editing with Blockly blocks. How can I make that happen?


The code consists of two parts: 1) the actual javascript coffee generated by blockly and 2) code for the blockly visualisation

Make sure to copy both / the entire action or an entire rule

Hi again,
Is the blockly visualisation what is generated in the code window which you can toggle from the blockly editor? Where do I find the actual corresponding javascript? And whereto do I copy it all?
Is there a simpler/safer way of copying the entire action/rule - i.e. duplicating without having to go into copying code text back and forth?

Many thanks,

If you open the rule (not the blockly script!), where you can also configure triggers and rule name, there you can switch to code view at the top of the screen.

Copy the entire code and paste it into a new rule

Thank you for your help - I had configured the rule to run a separate script/rule, but when copying the script to run “inside” the rule, copy/pasting it all indeed worked well for duplicating the rule. Thank you very much for putting me in the right direction!!

Before completely leaving this though, you should be able to save from the Library Blockly editor. do you have more details on this? Errors in the logs?

Note that that editor (Developer Tools → Block Libraries) is a place to invent new Blocks, not a place to create something like. a reusable function. Maybe that’s the problem?

When exiting the Library Blockly editor by clicking “done” - which is the only option that is there, nothing is saved and I can’t retrieve or see what I entered anywhere.
And, excuse my beginner’s ignorance - where should I be able to find any error log? There is no indication of any error whatsoever.

Assuming a Linux install, /var/logs/openhab/openhab.log