Hi
I want to read sensor-data, store these values in iobroker and later i want to sum the variables in a function-node.
My function code:
var dcPower = env.get("msg.dc.power");
var wallbox1Power = env.get("msg.wallbox1.power");
var wallbox2Power = env.get("msg.wallbox2.power");
var sum = dcPower;
msg.payload;
return msg;
On the bottom flow, is a debug node to determine where the value arrives. Assuming it is msg.payload, use a change node to copy or move this to their own msg property e.g. msg.val1msg.val2. When the msg arrives at the function node, you will be able to access all the values at the same time from the msg properties you set in the change nodes.
Thanks for your answer.
I set the attribute i the "ioBroker get"-node. In the picture you can see that the variables are stored in the function node, but the sum or payload are empty.
It looks like the values are already in some other msg property. Use the copy path button to grab the path to the value and use that with msg. instead of env.get (env.get is for environment vars not for accessing msg properties)
There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.
Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.