# Does the Dashboard button support sending a buffer as Hex?

**URL:** <https://discourse.nodered.org/t/does-the-dashboard-button-support-sending-a-buffer-as-hex/50526>\
**Category:** Dashboard\
**Created:** [2 September 2021 05:06 UTC](https://discourse.nodered.org/t/does-the-dashboard-button-support-sending-a-buffer-as-hex/50526 "2021-09-02T05:06:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [2 September 2021 05:06 UTC](https://discourse.nodered.org/t/does-the-dashboard-button-support-sending-a-buffer-as-hex/50526/1 "2021-09-02T05:06:36Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/b/0bcdb12ea09f67ca057d3a14ffc6b0d2742581d5.png)

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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 September 2021 07:16 UTC](https://discourse.nodered.org/t/does-the-dashboard-button-support-sending-a-buffer-as-hex/50526/2 "2021-09-02T07:16:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 September 2021 07:33 UTC](https://discourse.nodered.org/t/does-the-dashboard-button-support-sending-a-buffer-as-hex/50526/3 "2021-09-02T07:33:29Z")

</div>

> [@craigcurtin](#):
>
> 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.

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.

```auto
[{"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}]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 September 2021 08:25 UTC](https://discourse.nodered.org/t/does-the-dashboard-button-support-sending-a-buffer-as-hex/50526/4 "2021-09-02T08:25:57Z")

</div>

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](https://github.com/node-red/node-red-dashboard/issues/726)

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [2 September 2021 09:31 UTC](https://discourse.nodered.org/t/does-the-dashboard-button-support-sending-a-buffer-as-hex/50526/5 "2021-09-02T09:31:01Z")

</div>

Thanks Colin, Much appreciated.

regards

Craig

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 October 2021 09:31 UTC](https://discourse.nodered.org/t/does-the-dashboard-button-support-sending-a-buffer-as-hex/50526/6 "2021-10-02T09:31:36Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
