Node-red-contrib-blockly 1.0.0 available


#1

Hi folks,

The godfather of all Blockly nodes (alias @cymplecy) has given his blessing to publish version 1.0.0 on NPM. So here it is finally.

@knolleary: I assume you still have to add it manually to the pallette manager index? Thanks for doing that !

Thanks for all feedback and support from the community !

Bugs can be registered on the github repository, and new functionalities or doubts can be discussed here on the forum. The tutorials on the wiki need to be reworked in the next week(s), but they give you a first impression already.

Have fun!,
Bart


[ANNOUNCE] Visual programming a function node with Blockly - Feedback request
#2

YIPPEE!!!!!! :grinning::airplane:


#3

Great work and an excellent addition to Node-RED. Well done Bart.


#4

Confirming that it is now available to easily install from the Node-RED Manage palette menu option :slight_smile:


#5

This is a really cool custom node ! I'm trying it right now and I'm impressed ! It's like joining two worlds !
A suggestion ? Would it be possible to have an expand button like the function node in 0.19.x ?


#6

ok this is maybe a stupid question (I don't know much about blockly) but is there a blockly equivalent to setTimeout() and setInterval() ?


#7

I didn't notice that this has been added in Node-Red v0.19. Indeed I have been wondering from the beginning, if users would have enough space in their Blockly editor. Especially since the blocks take much more space, compared to their Javascript code counterpart.

I assume that nobody is against such a button. If somebody doesn't want to use it, he just don't has to click it :smirk:. So I like the idea. Just need to know how it should look like:

  • I assume that such a button needs to be available above both editors (the Blockly editor and the Javascript editor)? And not a single button above the tabsheets somewhere.
  • When such a button is pressed, I assume that the tabsheets need to be hidden? Or is the editor expanded inside the tabsheet?

Hopefully I get it managed, because I'm not a CSS expert ...

Not yet. I wanted to have timers, but got stuck on a number of questions. And afterwards I had some extra feedback from the Blockly forum, and had not enough time to experiment with it.

As soon as I have time again, I will make some proposals and discuss them here (by comparing multiple animated gifs). But I would like to have timers soon in this node. Think that a lot of Node-RED users wan't to execute actions on fixed intervals ...

Thanks for the usefull feedback!!
Bart


#8

You can probably steal appropriate borrow it straight from the function node. Great idea. I'd also missed that tweak, been wanting something like it for a long time.


#9

@tilleul: I have created an 'enhancement' issue on Github, for the 'expand' button.
@TotallyInformation: I also registered an issue to create new list_push and list_pop blocks, like you and Simon had proposed.

We will discuss all those issues here, but then at least I have a complete todo list at Github...


#10

hi,
nice work. there is a mode for calling a function or a method object with some params?


#11

Yes there is - this one will double the value of the msg.payload


#12

I have created a new branch on Github for the next 1.1.0 release:
image

You can test this experimental version by installing it directly from Github:
npm install bartbutenaers/node-red-contrib-blockly#release-1.1.0

This version contains following changes:

  • The language dropdown is now triggering code to load the selected language file from the server. And all dropdown values in the custom blocks are now also translated. I have added a dutch translation myself and François (@tilleul) has been so kind to provide a french translation. Other users can translate the en.js file in their own language, and share it with me (preferably via a pull request).
    blockly_multilanguage
    P.S. perhaps later I could set the default language (currently english) to the default language that is being used in Node-RED??

  • Julian (@TotallyInformation) and Simon (@cymplecy) had requested a list-push and list-pop block. When I was testing those blocks, I found out that Google has already provided this functionality:
    blockly_list_pushpop
    Is it ok if I remove my both new blocks again?

  • I added an expand button to the Javascript editor, and afterwards I want to add a similar button to the Blockly editor. The expand button works fine, but it displayed at the wrong location. Indeed it is located at the top of the config screen, while I expected it to be at the top of the Javascript editor:
    image
    Don't know much about CSS, so don't know what is wrong in my blockly.html. Copied to expand button from Node-RED's function node:
    ... right:0; bottom:calc(100% + 3px); ...
    I thought this means that the bottom of the button is 100% of the parent div + 3 pixels. Perhaps my 'resize' function is not good enough. No clue, so would appreciate if somebody could assist me to get this fixed ...

Bart


#13

I wrote pull request https://github.com/bartbutenaers/node-red-contrib-blockly/pull/20 to add Japanese resource.

日本語のblocklyを試したい場合は、
npm install utaani/node-red-contrib-blockly#utaani-patch-1
でできます。


#14

Yes

I don't think there is any need to ask if its a feature in the development version - only if its a breaking change in the master branch


#15

Cool, of course - DRTW (Don't reinvent the wheel) :slight_smile:


#16

Hard to know. I think you are right but then your HTML isn't quite like the function node. For example, you don't have position:relative on the parent.


#17

That is indeed a necessary feature. But I haven't added a separate delete-block. Instead I have integrated the delete functionality inside the get-block, since Google does it also like that in their basic blocks (and I want keep it consistent).

The version 1.1.0 branch on Github now contains a node_object_get block with following behaviour:

  • You can select 'get' or 'remove' from a dropdown
  • Depending on the selection, the tooltip will change
  • Depending on the selection, the shape of the block will change. For 'get' it will be a 'value' block (which means it has an output that can be chained to other blocks inputs), and otherwise it will be a 'statement' block (with a previous and next statement indication).
  • Depending on the selection, the code will generate a value (without ';\n') or a statement (with ';\n').
  • Depending on the input value, the generated code will be e.g. 'delete msg['payload']' or 'flow.set('myVariable')' (seems that you need to set NO value in the Node-RED memory to delete a variable from that memory ...).

Summarized:
blockly_delete_property

P.S. in the animation you see that the blocks sometimes get suddenly another position in the editor. I registered an issue for it, and I will try to solve it as soon as I'm retired one day ...

@tilleul: I had to separate your french translation into parts to allow a dropdown. Are these texts ok?

Blockly.Msg.NODE_OBJECT_GET_JSON = "%1 %2 la propriété %3";
Blockly.Msg.NODE_OBJECT_GET_JSON_GET_TOOLTIP = "Obtenir la propriété d'un objet.";
Blockly.Msg.NODE_OBJECT_GET_JSON_REMOVE_TOOLTIP = "Supprimer la propriété d'un objet.";
Blockly.Msg.NODE_OBJECT_GET_JSON_GET = "obtenir de";
Blockly.Msg.NODE_OBJECT_GET_JSON_REMOVE = "supprimer de";

@utaani: Sorry but splitting the Japanese was a bit to hard for my brain :weary:. Could you please translate them for me? Remark: are you aware that you are allowed that you can rearrange the placeholders? For example : 'first &1 then &2' could be in another language (that is being read from left to right) '&2 then &1 first'. Blockly knows which widgets needs to be at locations of &1 and &2, and will rearrange them automatically for you.


#18

Need to train my brain to reach for the blockly node instead of a function node and google (to look up the JavaScript syntax that I can never remember)!


#19

I've converted nearly all my JSONata and JS nodes (didn't have many of them) to Blockly ones

(Although, to be honest, its is quicker/easier to use JSONata just to pre-fix/append text to a payload)

But I'm trying not to use Blockly for everything but keep to just using standard Node-RED where nothing fancy is required (or use contrib nodes like Simpletime where appropriate)

Otherwise I'd effectively just end up back using the blockly equivalent of my ScratchGPIO for my house #IoT :slight_smile:


#20

I'd probably like to use it for occasions where my memory fails me when I'd normally be writing function nodes. Typically I have a good overview of the logic required and that logic is quite functional.

I've already noticed that Blockly may require some different logic thinking than raw JS. And it needs some expansion still on the blocks such as something that will do "does property x exist in object y" if ( 'x' in y ) ...

Then there is the issue of trying to access a deep property such as msg.payload['Room Name'].Heating - I haven't managed to work that one out yet.

In case you are wondering, I was trying to covert the following JavaScript logic to Blockly:

if ( !('previous' in msg) ) msg.previous = msg.payload

for(let room in msg.payload) {
    if ( msg.payload[room].Heating !== msg.previous[room].Heating ){
        let msg1 = {
            topic:"Room Change",
            payload: {
                change: msg.payload[room].Heating, 
                time: (new Date())
            }
        }
        msg1.payload[room] = msg.payload[room]
        node.send( [null,msg1] )
    }
}

return [msg,null]

"room" is a property that may have a space in it.