Feeding external data into custom widgets

Hello Node-RED community.
I started my first Node-RED project and so far i am loving it!

I am having troubles feeding some external values into some widgets:

Using the stoptimer-varidelay from hamsando i want to inject the timer value from outside.
Same problem with the ui-artless-gauge from hotnipi. Here i need to override the min and max values of the configuration from outside the widget. For this widget the author added an example but i cant get it to work.

var newSectors = [{t:"min",val:5,col:"#00ff00",dot:3},{t:"sec",val:8,col:"#ff0000",dot:3},{t:"max",val:30,col:"#0000ff",dot:3}]
msg.control = {unit:"degrees",label:"Temperature",icon:"fa-thermometer",center:4, decimals:1, sectors:newSectors}

Any chance one of you knows how to do that?
greets Max

Welcome to the forum @AldaSoggn

What version of node-red are you using (This is shown at the bottom of the hamburger menu) and what version of the dashboard (Manage Palette will show you that).

Is the widget showing ok, so it is just that msg.control is not working for you?

Hey Colin, thanks for your reply.

I am using Node-RED v1.2.2 and Dashboard 2.23.4
The widget is showing fine. When i try a slider as an input it works aswell.

Here is a sample of what I tried:

[{"id":"3bad8e98.004cf2","type":"ui_artlessgauge","z":"b5854e8b.36e59","group":"cc1b923d.14259","order":4,"width":"6","height":"6","name":"Test Widget","icon":"","label":"Time Left","unit":"Seconds","layout":"radial","decimals":0,"differential":false,"minmax":true,"colorTrack":"#555555","colorFromTheme":true,"property":"payload","sectors":[{"val":0,"col":"#ff9900","t":"min","dot":8},{"val":10,"col":"#ff9900","t":"max","dot":8}],"lineWidth":"5","bgcolorFromTheme":true,"diffCenter":"","x":850,"y":540,"wires":[]},{"id":"5849124.48bbfec","type":"function","z":"b5854e8b.36e59","name":"","func":"var newSectors = [{t:\"min\",val:5,col:\"#00ff00\",dot:3},{t:\"sec\",val:8,col:\"#ff0000\",dot:3},{t:\"max\",val:30,col:\"#0000ff\",dot:3}]\nmsg.control = {unit:\"degrees\",label:\"Temperature\",icon:\"fa-thermometer\",center:4, decimals:1, sectors:newSectors}\nmsg = {payload : msg.control};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":480,"y":580,"wires":[["71e0451c.c6824c"]]},{"id":"76c0352d.61544c","type":"debug","z":"b5854e8b.36e59","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"controls","targetType":"msg","statusVal":"","statusType":"auto","x":850,"y":620,"wires":[]},{"id":"d2ae9ffd.0456d","type":"inject","z":"b5854e8b.36e59","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":320,"y":580,"wires":[["5849124.48bbfec"]]},{"id":"71e0451c.c6824c","type":"change","z":"b5854e8b.36e59","name":"","rules":[{"t":"set","p":"controls","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":580,"wires":[["76c0352d.61544c","3bad8e98.004cf2"]]},{"id":"cc1b923d.14259","type":"ui_group","name":"Default","tab":"28f4e723.1c8a68","order":1,"disp":true,"width":"6","collapse":false},{"id":"28f4e723.1c8a68","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

The fundamental problem is that you are setting msg.controls instead of msg.control.
There is no need for the change node, take that out and change your function node back to what you showed in the first post and it works fine, for me anyway

var newSectors = [{t:"min",val:5,col:"#00ff00",dot:3},{t:"sec",val:8,col:"#ff0000",dot:3},{t:"max",val:30,col:"#0000ff",dot:3}]
msg.control = {unit:"degrees",label:"Temperature",icon:"fa-thermometer",center:4, decimals:1, sectors:newSectors}
return msg;

const newSectors would ideally be better, though in this case it doesn't make any difference.


Awesome! Thank you. I tried that in the beginning but somehow i alway thought it would be msg.controls.

And regarding the stoptimer-varidelay widget, is it possible to inject the duration time with a control msg aswell even though the author did not specify it in the description?

Isnt' that what "If the input contains msg.delay, then the delay will be 'msg.delay' units of time" means in the readme - https://flows.nodered.org/node/node-red-contrib-stoptimer-varidelay.
Does that node provide something you need that the core Trigger node does not? It is best to use core nodes when you can as contrib nodes may get abandoned and stop working.

True :slight_smile: I just tried it out and it works great.
You are right regarding the core nodes, I will try to implement a countdown timer with trigger nodes.
Thanks again!

You can set the trigger node to send nothing then after a delay send the message, extending the delay if a new message arrives, which looks close to what the varidelay node provides.

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