Adding hysteresis - how to? [SOLVED]

Hi, I am super fresh to Node Red and as I am using it in Home Assistant I need to learn more :wink:
Sometimes it is difficult to even ask google the question if I am not sure what to really ask.
So here is my question: I have 2 sensors: one provides the light in lux, second is the input sensor where I set up minimum light - once I have them to I have a node that acts accordingly depending on which value is bigger (turns on or off the light). So far all is ok but for obvious reason I would like to implement hysteresis, i.e. when set up light value is 50lx, I don't want to turn ON the light until sensor is not below 45 and don't turn OFF the light until sensor is not above 55 (to avoid flickering).
And now I have a question: how to?
Right now the flow looks like this:

The 2 switch nodes look like this:
Lower than:

and this: higher than is the same but ">=" instead of "<" - I cannot add more than 2 pictures ;(

Where to put the hysteresis (i.e. "-5" to the "lower than" and "+5" to the "higher than")?
Do I need another node to do this or I can modify the switch node?

Thank you if you could help :wink:


You could add it by selecting JSONata J: in the rule.

1 Like

thank you very much - that was the bit I was missing :wink:

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