Thanks for testing; my point is that the same procedure doesn’t work for openHAB Scripts: you can’t switch to XML code view because there is no “Code” tab for openHAB Blockly Scripts. I’m sure you can extract the XML code for openHAB Blockly Scripts from the openHAB configuration file, but that would be a bit too cumbersome (and error prone) for the average user …
tl;dr
Do not use openHAB Blockly Scripts if you plan to copy part of them to Blockly scripts within openHAB Rules at a later time.
In the mean time, you can use the API explore to remove the “script” tag and the script will appear as a normal rule.
But this use case seems like you are looking for more of a library call. Under Developer Tools is a place where you can create Blockly Libraries which basically means creating your own blocks which can be reused in your Blockly scripts.
Also, there is the ability to call other rules. So you could create your Script (which is just a special case of a rule) and directly call that from your other rules.
Using API Explorer, I managed to extract the Blockly source code from my Script and paste it into the code window of my Rule. The Blocky parser/renderer doesn’t seem to like duplicate variable names (Blockly ids were different though), so I had to remove the duplicate variable from the XML code and fix the ids - it works, but it’s an error-prone mess.
@stefan.hoehn : I just stumbled over the copy&paste plugin of blockly (@blockly/plugin-cross-tab-copy-paste Demo). Maybe you already know it? What do you think about integrating it in openhab?
With this plugin you can copy&paste blocks between different tabs. Maybe even copying blocks from the marketplace could be possible in the future?
Quick feedback: Unfortunately it requires blockly 9.0.0 and we are still on 6.x. Upgrading is major topic as it requires other dependencies as well where I definitely need to have support from @ysc
Actually it wasn’t one day but four but I hope that’s okay?
I had created a little animated gif to show it in action but it is too big to upload it here, though I can tell you it really works - unfortunately the pictures are not as impressive as if it would be shown animated: