I have different input fields and I want to read out the content each second.
I used the "get state" node to trigger the reading for each second together with a "function node".
With the following content this works perfect for the my "switch nodes"
var state = context.get('state') || false;
if (msg.topic == 'switch11') {
state = msg.payload;
context.set('state', state);
}
if (msg.payload == 'get state') {
return {payload: state};
}
return;
But for my "numeric input" node and also for the "dopdown" node , I could not found a corresponding solution for the content of the "function node" until now.
Put a debug node on the outputs of the 'switch11', the 'get state', the 'ui_numeric' and the ui_dropdown' nodes and look at what msg.payload looks like coming from each one.
Next compare that with your function node to see how the function will work with that data.
ui_switch sends nothing out, but content is e.g. true.
get state sends out "get state" each second
state function sends out true each second
Not working numeric input
ui_numeric sends nothing out, but content is e.g. 30
get state sends out "get state" each second
state function should send out 30 each second but I until now have not found the correct function code to have access to the numeric value
If you did copy the function node, have you checked what is the topic you sending from ui_numeric or from ui_dropdown nodes. Cos if those are different, the function will not save new value to context.