How to sum 2 msg coming in asynchronously?

Im fairly new to Node Red so the solution may seem obvious, but i just got stuck and can't figure it ou
I want to get a sum of 2 messages - first one comes from a date picker, the second one comes from a dropdown (it let's you choose an hour). I want to sum them to get the exact time of the reading i want to export from a CSV file. Of course the messages come asynchronously so how do i add them after they both change (or when a button is pressed? idk)

Option 1 - Join

Use a join node: See this article in the cookbook for an example of how to join messages into one object.

Flow 1...

input1 --> change-node (set topic "input1") ---+---> join node (set to 3 parts) -->
input2 --> change-node (set topic "input2") ---↑
button --> change-node (set topic "button") ---↑

Option 2 - Context store / retrieve later

Store the values in flow or global context & re-read them when the button is pressed

Flow 1...

input1 --> change node (save payload to flow.input1)

Flow 2...

input2 --> change node (save payload to flow.input2)

Flow 3...

button --> change-node (set msg.input1 to value of flow.input1 & set msg.input2 to value of flow.input2) - now both values are in one message

Okay, I'd like to do the option with the button, but the datepicker and dropdown menu sends a message only when changed. So when I won't change one of them (date or dropdwn because it's already going to be the time want) it will give me an error because the "next" function won't have a message input right? How do i solve that then?

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