Setting default values to UI nodes

#1

Hi, likely this is another FAQ: how to set “default value” or “initial value” to UI elements/nodes?

I’d like to have some switches on and others off when node-red loads.
And numeric/sliders at certain values each.

I could keep the values in a file, read them on boot into the flow… and… still how to apply to UI nodes?

0 Likes

#2

almost there… just pass them into the relevant ui nodes… only thing to note is that the input to the switch must be of the same type as it is set to send out… so if it send a string “1” then you need to send in a string “1” and not a number 1. Likewise just send the values you want into the slider and numeric to pre-load them.

0 Likes

#3

An alternative to using a file is to use inject nodes set to inject once on startup.

0 Likes

#4

This is a great solution to setting initail values when NR starts. What about when the UI connects? I would like to have a set of initial values each time the user connects. Thanks.

0 Likes

#5

th ui_control node emits a message on many events including a connection - which you can use to trigger setting things if you like

0 Likes