question

mindaugas avatar image
mindaugas asked

Node Red decision flow based on two inputs

Hi

I build some simple flows using Node red. It is great features.

1687532675553.png


But now I can not find how to program action flow based on two inputs parameters. PV power and SOC. I am not programer and already spend several days searching on youtube, nodered.org and this forum. Probably it is very simple and I miss some basic knowledge

My goal is to set Grid point (GP) to 3 values: -1800W, -500W and 0 depending on PV W and SOC.

If SOC > 85% & PV>1500W then GP=-1800

If SOC > 85% & PV<1500 then GP=-500

If 50%<SOC<85% and PV>1500 then GP=-500

If SOC<30% then GP=0

Logic may change and will fix it, but what I am missing if how to manage logic having two inputs and only one msg.payloads value


Thanks

Mindaugas

Node-RED
1687532675553.png (19.2 KiB)
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

2 Answers
derrick thomas avatar image
derrick thomas answered ·

Use a function node. Get the pv output and the SOC, change them to something like msg.soc and msg.pvoutput and send those outputs to the function node, then use the function node to compare those values to desired values and set the msg.payload according to those results, msg.payload gets sent to the grid set point node.

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

mindaugas avatar image mindaugas commented ·
Thanks!
0 Likes 0 ·
Dirk-Jan Faber (Victron Energy) avatar image
Dirk-Jan Faber (Victron Energy) answered ·

two-inputs.pngAs the two inputs won't be generated at exactly the same time, you will need to store them in the context. I've made an example for you here.


two-inputs.png (106.1 KiB)
1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

mindaugas avatar image mindaugas commented ·
Thanks a lot!
0 Likes 0 ·