I intend to use ui-switches to set certain states/options on the fly from within the UI.
Now the flow (partly automated through timers) should behave differently according to these settings.
For this purpose, I would need to check the switches states right before the workflow starts.
... how can this be done ?
I have fiddled with a context store, but accessing the UI-elemts states would be way more intuitive.
If it cannot be done,
maybe there is an object-tree or "Master list" of elements/objetcs, and properties could be "get".
maybe there is an implementation(node of a state "object" ?
as node-red is event based & the UI is client side (node-red is server side) there is no real way to "query" the ui state. You simply store the state of the ui switch in context & read that state whenever you need to know its value.
You may also want to remember that there can be multiple browsers active on the dashboard, so there may well be multiple instances of "that switch" out there. You need to think a bit about message flow and state so they're all consistent, unless you don't want that.
thank you ... but can you pls. elaborate a little bit more on your "read state" answers ...
inject/other
change node
... as in: "My other automated flow is triggered via a timer, calls a change node to read to read the variable, which then gets injected to message that is sent to the final workflow function ...,
... there is nothing wrong, reading the variable programmatically within a function ?
(or is this bad style, and not the "node red" way of doing things ?)
The function node has a bit of overhead so if you are using it just to get values from context it's a bit overkill but nothing to write home about.
However if you are doing other things in the function node then it makes sense not to use a change node & simply use the get functions within the function note to grab the context values.
As for the "node-red" way, doing everything in a function node is obviously going to hide cues and clues away vs a visual flow.