I came across several threads mentioning the thermostat node.
Do I miss the obvious solution?
I didn’t think the RBE node had the ability to specify a setpoint, I thought it was only for changes relative to previous values.
The node node-red-contrib-ramp-thermostat will do a simple thermostat with hysteresis and you can set it to ignore the ramp feature if you don’t want it. The fact that it is documented to refer to temperature is irrelevant, it can be any measurable process value. You might also like to look at node-red-contrib-pid which should be capable of providing much better control than a setpoint with hysteresis but is more complex to setup. PID control may well be overkill for your process in which case just go for the thermostat mode. Even if you want to use PID I would suggest getting it going with the t/stat first as that will iron out the basic issues.
I forgot to comment on that. If the output is the wrong way up for your system (so ON when it should be OFF) you can insert a simple node to invert it.
If you need simple hysteresis and a setpoint then a simple switch node should be ok. Eg if greater than 26 send off, less than 24 send on, otherwise send nothing.
Whats the difference in using function node as in compared to change node with jasonata expression?
Maybe a function is easy to define otherwise I tend to avoid functions for simple stuff.
In extremis the change node should be faster as the function node runs in a sandbox - but unless you are operating in the region 1000s of messages per second area then it really won’t be noticeable.
It isn’t just about the message rate though - the change node uses much less memory at runtime which can often be a more important factor than raw throughout.
node-red-contrib-pid gets my vote. I’m using it for an irrigation system (albeit in my greenhouse!).
It is more difficult to set up, but there is an excellent demo setup which really helps.
The advantage to using a PID is that it will provide more accurate control, by reducing it’s output as it nears the setpoint, to avoid overrun, and also intervene to reduce the rate of change.
My greenhouse heating system smooths out the values from the temperature sensor with a rolling average over the last 10 (one a minute) using node-red-node-smooth. I found that it stopped rapid switch around ‘on’ and ‘off’ temperatures.