# Adding hysteresis - how to? \[SOLVED\]

**URL:** <https://discourse.nodered.org/t/adding-hysteresis-how-to-solved/67977>\
**Category:** General\
**Created:** [20 September 2022 14:08 UTC](https://discourse.nodered.org/t/adding-hysteresis-how-to-solved/67977 "2022-09-20T14:08:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![homonto](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/homonto/32/68035_2.png) [@homonto](https://discourse.nodered.org/u/homonto)\
**Post date:** [20 September 2022 14:08 UTC](https://discourse.nodered.org/t/adding-hysteresis-how-to-solved/67977/1 "2022-09-20T14:08:35Z")

</div>

Hi, I am super fresh to Node Red and as I am using it in Home Assistant I need to learn more 😉  
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:

 ![Screenshot 2022-09-20 at 15.02.32](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/e/ae2f8c8ef65c7631aa88451b2bf42feb3c53351a.jpeg)

The 2 switch nodes look like this:  
Lower than:

 ![Screenshot 2022-09-20 at 15.04.45](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/2/82f40f62ff9f9308b9c08d0539955df9c489004d.png)

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 😉  
Ciao

zyga

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [20 September 2022 15:06 UTC](https://discourse.nodered.org/t/adding-hysteresis-how-to-solved/67977/2 "2022-09-20T15:06:17Z")

</div>

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

 ![chrome_screenshot_1663686315507](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/6/1655b9fa174b6ff7d2a8fac8d0b6cf2753882aa3.png)

---

<div class="post-metadata">

**Author:** ![homonto](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/homonto/32/68035_2.png) [@homonto](https://discourse.nodered.org/u/homonto)\
**Post date:** [20 September 2022 15:38 UTC](https://discourse.nodered.org/t/adding-hysteresis-how-to-solved/67977/3 "2022-09-20T15:38:26Z")

</div>

thank you very much - that was the bit I was missing 😉  
ciao

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [4 October 2022 15:38 UTC](https://discourse.nodered.org/t/adding-hysteresis-how-to-solved/67977/4 "2022-10-04T15:38:45Z")

</div>

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