Does the Dashboard button support sending a buffer as Hex?

Guys,

Steadily progressing with my home battry automation project.

As an intermediate step to fully automatic operation i am building a manual control dashboard

I have a function node that i have been using an inject from within the editor to fire off - the function node works fine and has the following code in it

msg.payload = Buffer.from("aa55b07f02390b07010406001100fff6ff7f060a", "hex");
return msg;

Which is sent to the UDP out node and does what i expect - set the battery to 10% charge rate

However what i would like to do is take that same code an implement it as a dashboard button

image

So if i put that same Hex string into the Dashboard button and then link the output to the UDP out node i get some strange things happening

  1. If i set it as a string - it does not work to change anything with the inverter - no errors etc just nothing happens
  2. If i set the button type to be a buffer and paste the string without any quotes then i get an immediate message in the right hand corner of my browser - connection lost - i also lose connection to the Editor and have to reload that in my browser window.
  3. If i put the quotes nothing seems to happen either.

So the question - is there a way to tell the dashboard button to output a buffer as Hex or do i just need to link this to function nodes ?

Craig

Start by just connecting the button to a debug node (through your function node if necessary) and make sure you are getting the correct result.

You appear to have found a bug in the button that crashes node-red if invalid data is entered in Buffer mode. I will investigate a bit further then submit an issue.

The two versions work below for me. The first specifies a Buffer type with contents ["0xaa","0x55"] and the second specifies the String type with contents aa55 then converts it with a function.

[{"id":"602cfb94efe73a8e","type":"debug","z":"84405ff5.25fa6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":2600,"wires":[]},{"id":"fc26afbcb7739df7","type":"ui_button","z":"84405ff5.25fa6","name":"","group":"a8e4a3.d31edb6","order":1,"width":0,"height":0,"passthru":false,"label":"Buffer button","tooltip":"","color":"","bgcolor":"","icon":"","payload":"[\"0xaa\",\"0x55\"]","payloadType":"bin","topic":"topic","topicType":"msg","x":210,"y":2580,"wires":[["602cfb94efe73a8e"]]},{"id":"7e9e642b8479d579","type":"ui_button","z":"84405ff5.25fa6","name":"","group":"a8e4a3.d31edb6","order":1,"width":0,"height":0,"passthru":false,"label":"Buffer button 2","tooltip":"","color":"","bgcolor":"","icon":"","payload":"aa55","payloadType":"str","topic":"topic","topicType":"msg","x":200,"y":2660,"wires":[["d71f43aa95c6fc4c"]]},{"id":"d71f43aa95c6fc4c","type":"function","z":"84405ff5.25fa6","name":"To Buffer","func":"msg.payload = Buffer.from(msg.payload, \"hex\");\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":2660,"wires":[["602cfb94efe73a8e"]]},{"id":"a8e4a3.d31edb6","type":"ui_group","name":"Chart","tab":"8032fe72.980b98","order":3,"disp":false,"width":"12","collapse":false},{"id":"8032fe72.980b98","type":"ui_tab","name":"PnH","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

I have submitted an issue for the button crashing node-red if invalid data is entered in Buffer mode. ui-button crashes node-red if invalid json entered in Buffer mode · Issue #726 · node-red/node-red-dashboard · GitHub

Thanks Colin, Much appreciated.

regards

Craig