Saving a status and using it in a function node

Hi,

node-red looks so simple and does already a lot for me.
But now things get complicated.

I have a window which should be opened and closed in relation to the temperature in the room.
So i have a function node which checks the temperature and sends accoring commands to the window like this:

temperature = msg.payload.AM2301.Temperature
if (temperature < 24){
msg.payload.TargetPosition = 0
}else if (temperature > 25){
msg.payload.TargetPosition = 100
}
return msg;

But the temperature is transmitted every 10 minutes and therefore the command for the window is also sent every 10 minutes, which is of course unnecessary.
So if the window is already open (Status Open) the message should be suppressed. The same of course also in case of a window that is already closed.
So I need something like a status function or a global variable with the state of the window.
What is the easiest way to do this in red-node?
(Sorry, but the documentation is somehow confusing for me).

Thanks

Have a look at the RBE node, read the description too.

Great!
This is what i need.
Thanks a lot!

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