A loop in function with x time output

Hello
if i have a function, can i write a for next or loop loop there, which reads a number of global data at each start, calculates it and then writes it with a new topic and payload?
E.g.
read all global values
go into the loop and edit the first value,
give the first value a new topic and the result into payload
send this to iobroker/influxdb
start the loop again with the second value
edit the second value with a new topic and the result intp payload
send this to iobroker/influxdb
..
..
..
24 times, then the process is finished for 24 hours.

Of course I can also write 24 functions which are triggered one after the other and read their values, edit them, create a topic and send it.
However, a single process would be simpler for extensions, adjustments and the overview.

However, as soon as I have written return once in my attempts, the function terminates, which was probably the intention of the inventor.

Does that mean you have exactly 24 global variables?

What are these variables that you want to loop through?
Also, are you doing the same thing to each of them when you edit them?

I have 48 variables which I load.
electricity meter yesterday 1-24 electricity meter today 1-24

,
calculate new electricity meter reading yesterday and write back
Now I want to send the new calculated meter reading today to iobroker/grafana
and continue with the next value.
it is all numbers and almost always the same, but
there are values where I have to divide the value by to 2 consumers
or subtract a value from a chain (total consumption heating, but there is the feed pump connected which I measure heating consumption is total consumption minus feed pump).

This is all no magic, I'm just trying to figure out if I can make a return msg.payload multiple times in a function

Sure you can , the docs tell you all about node.send()

1 Like

Thank you and I learned something new again.
I will try it out at the weekend.
there are soooo many great things in nodered.
So far all my ideas could be implemented, very impressive.
THX
EDSTOBI

1 Like

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