Inserting characeter before payload is sent

just wondering if anyone can point me in the right direction, all i want to do is use the color picker to give me the hex value but i want to add a # to the payload before the hex number as its being sent out. cheers

Hi @patrolin

I assume you are referring to the Node-RED Dashboard colour picker?

There are many possible ways... but each will require adding a node after the dashboard node to modify the message it sends. Take you pick from the following core nodes:

Template Node

Configure a Template node (not UI-Template) with the template: #{{payload}}

Change Node

Configure a Change node to Set msg.payload to the expression type '#' & payload

Function Node

Configure a Function node with the code:

msg.payload = "#"+msg.payload;
return msg;

thanks alot man!!! ive been doing node-red for about a month now, just when i think im gettin somewhere this stumps me. :grinning:

1 more thing not sure wether to start a new topic or not may be a simple,
using the same RGB picker i need to send the hex value as json to hue bridge. i can use a inject node and inject {"hex": "00000"} and it changes the light colour. the output from the light after state change looks like this 1
i can use the color picker and change node to set the payload msg.hex to the hex value but i cant work out how to get it as a json and send under msg.payload.hex

If you can see what you need in the debug window.
Take a look at
https://nodered.org/docs/user-guide/messages
which explains how you can use the debug tool tips to copy the path to a data item.It should help you work out how you can change the path to do what you want.

cheers mate ive read that page a million times, couldnt get anything to display payload.blahblah but i realised i had to delete the payload to start with to then create a new one.
well i worked it out. anyone can tell me if this is a long way to do it, seems like the wrong way but it works.

        [{"id":"b7642d3e.87515","type":"ui_colour_picker","z":"d526b179.2a93f","name":"","label":"","group":"bfb412ab.18adc","format":"hex","outformat":"string","showSwatch":true,"showPicker":false,"showValue":false,"showHue":false,"showAlpha":false,"showLightness":true,"dynOutput":"false","order":0,"width":0,"height":0,"passthru":true,"topic":"","x":200,"y":100,"wires":[["43b8ef.a509171"]]},{"id":"b0fb3979.ef22e8","type":"debug","z":"d526b179.2a93f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1170,"y":100,"wires":[]},{"id":"d253b0ac.1b9d8","type":"change","z":"d526b179.2a93f","name":"","rules":[{"t":"set","p":"payload.hex","pt":"msg","to":"(hex)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":100,"wires":[["c32415f4.201488"]]},{"id":"a5429590.2f17d8","type":"change","z":"d526b179.2a93f","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":100,"wires":[["d253b0ac.1b9d8"]]},{"id":"43b8ef.a509171","type":"change","z":"d526b179.2a93f","name":"","rules":[{"t":"set","p":"hex","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":100,"wires":[["a5429590.2f17d8"]]},{"id":"c32415f4.201488","type":"change","z":"d526b179.2a93f","name":"","rules":[{"t":"delete","p":"hex","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":100,"wires":[["b0fb3979.ef22e8","5b753f36.bf6fe"]]},{"id":"5b753f36.bf6fe","type":"link out","z":"d526b179.2a93f","name":"rgbcomputer","links":["739d8083.fbf1e"],"x":1160,"y":180,"wires":[]},{"id":"bfb412ab.18adc","type":"ui_group","z":"","name":"Colour Control","tab":"52f9efff.91cbb","order":11,"disp":true,"width":"4","collapse":false},{"id":"52f9efff.91cbb","type":"ui_tab","z":"","name":"Color Control","icon":"dashboard","order":3}]