Using Just One of Multiple, Successive Events


#1

I’d like to get some thoughts from the gang on this. I am using a reed switch connected to a contact sensor on my doorbell chime to capture when the doorbell is pressed. This is working very well overall.

I have a piston that detects when there’s activity on the contact sensor and then does various things. Here’s the minor rub … when the doorbell is pushed it is possible that multiple strikes of the chime happen due to the striker bouncing and this can translate to more than one open/close event on the contact sensor in very close succession.

Because of the above I am getting multiple executions of the piston so, for example, I get multiple text messages, multiple images captured on camera, etc.

Any ideas for just identifying one of the multiple, quick fire events?


#2

Use a variable…

define
Boolean buttonPressed

IF
buttonPressed is false
and
Contact is closed
THEN
with location (TCP never cancel)
set variable buttonPressed = True
do other stuff
wait 20 seconds
set variable buttonPressed = False


#3

Thanks Robin. Sometimes I just can’t think through the logic from scratch. What you suggested makes perfect sense.


#4

Another way:

IF
contact IS closed
AND
previousAge([contact name : contact]) IS Greater Than 20000
THEN
do stuff


#5

Just wanted to report back that this is working great. Thanks again.