Lux dependent script

Oh, so you want to implement hysteresis which requires a large change from the threshold before it counts. That’s easy enough. There are lots of different approaches you can use:

  1. Threshold Alert and Open Reminder [4.0.0.0;4.9.9.9] : you can set a threshold (e.g. 100 lx) and an amount that it has to change below (e.g. 20 lx) that the sensor would have to read to end the alert. The rule template will call a rule you implement where you provide the “what to do”.

  2. There is a hysteresis profile you can put on the Channel providing the lux linked to a Switch Item. You can specify a threshold (e.g. 100 lx) and a hysteresis (e.g. 20 lx) and the Switch will be ON when the value exceeds the threshold but won’t turn off until the value drops at least 5 below the threshold. There are other properties to control the behavior. You’d then use the Switch to see whether you need to turn ON/OFF the light.

  3. You can create a version of Filter Profile which basically implements a hystersis on the values coming from the Channel before it ever gets to the Item. The new value has to be at least 20 lx greater or lower that the last value sent to the Item in order for the Item to update with the new value.

  4. In your rule, the first time the lux exceeds a threshold, record the lux reading in the cache or in another Item. Then ignore subsequent updates until the change is greater than the hysteresis. It’s basically the same code as you’ll find in 3 only you’d adapt that to a rule instead of a transform.

1 Like