Bounceless sensor

I’m attempting to use a Aeon Labs DSB29 sensor on my garage door. I’ve found these devices to work well on regular doors, so I gave it a shot. The problem is that opening and closing my garage door involves a bit more trauma – shaking and jarring – so I often get an extra open/close tripped pair event.

Has anyone figured a good way to program a Lua trigger event as a bounceless switch?

First thought is to put a delay in the trigger – 1 sec sounds about right – then explicitly read the current sensor state in Lua code.

More info: the problem is that I send these trigger events to a separate endpoint that handles logging, notifications, Twitter, etc. I want to avoid solving rapid sequences of events from a single source in that code (think vector clock…), and instead accept some latency from the source to just get one event.

Thanks - Joel

I could fix this in PLEG, but I know nothing about LUA.

There is an example showing how to ignore rapid re-triggering of a scene here.

RexBeckett – thanks, that is working for me. It’s simply using a global variable to record the time of the last tripped event, after it is debounced. The same check is in both the tripped and non-tripped triggers:

EDIT: corrected code, based on feedback from RexBeckett (see below).

local bounce = 3
local now = os.time()
local last = debounce_garage_bay_left or 0
if ((now - last) < bounce) then
    luup.log("debounce: " .. (now - last))
    return false
end
debounce_garage_bay_left = now

-- any additional work here...

return true

For this to code to be able to inhibit the scene actions, it needs to return false for the bounced state:

local bounce = 3 local now = os.time() local last = debounce_garage_bay_left or 0 debounce_garage_bay_left = now if ((now - last) < bounce) then luup.log("debounce: " .. (now - last)) return false else return true end

Thanks RexBeckett, that makes sense; I corrected code snippet above.

I was actually doing all work in the triggers’ luup, since I have context to whether the door was opening or closing. So I never hit the bug in my case. Good catch!

in the code above I’d remove the else part of the if statement, otherwise debounce_garage_bay_left will never be set to the new value.