Design Pattern: Proxy Item

See

KLTimer_5m_OFF is an Item configured with the Expire binding to receive an OFF command five minutes after it received the last ON command.

KLTimer_10s_OFF is an Item configured with the Expire binding to receive an OFF command five minutes after it received the last ON command.

There is a rule that gets triggered when either of these Timer Item changes to OFF (I would have used received command OFF instead of changed to OFF so that the rules do not trigger when the Timer is canceled but Bob is really deliberate in his Rules so expect there is a reason he wants the rule to fire even when the Timer is cancelled with an update).

When the 5m timer goes to OFF, the 10s timer gets set to ON. When the 10s timer goes OFF, the kitchen motion sensor is checked. If it is ON then the 10s timer is reset to fire in another 10 seconds. If not then the light is turned OFF.

The Rule that uses the Timers gets fires when the motion sensor changes from ON to OFF. If I remember correctly, his motion sensors remain ON for a period of time after detecting motion so this rule gets triggered some minutes after the last motion detected. If the light was ON when the motion sensor went OFF then if the 5m timer is still running then it gets turned OFF. In either case the 10s timer get set to turn off the Light in 10 seconds (assuming there isn’t another motion event).

If the light is OFF then the timers are canceled with a postUpdate(OFF).

So, at a high level, he has a 5-minute timer that gets set somewhere (probably his lights proxy rule). When that timer expires he sets a 10-second timer that when it expires turns off the lights.

3 Likes