I’ve been tracking down some of my instances of “Piston waited at a semaphore” problems. Sometimes it occurs because I have 2 events that occur very close to each other. I fixed some of them by causing a short 3 sec delay between events when I can control them. In other cases, I know there will be asynchronous events that inevitably will cause 2 events to occur simultaneously. I can’t do anything about those. But I also found this case, where a switch is shut-off and gives an OFF event, but then 1 sec later, I get another OFF event from the same switch. This results in a “Piston waited at a semaphore” condition since the piston is still actively servicing the initial OFF when It gets the 2nd OFF and Webcore gets confused. It’s like the switch is bouncing and communicating multiple messages to Zigbee. Not always but sometimes. This occurs maybe 1 of 25 times, although sometimes it is worse than that. Here is an example of that situation:
2/17/2019, 3:59:12 PM +208ms
+1ms ╔Received event [Water Recirculation].switch = off with a delay of 1164ms
+9729ms ║Piston waited at a semaphore for 9519ms
+10127ms ║Setting up scheduled job for Sun, Feb 17 2019 @ 5:39:00 PM MST (in 5977.666s), with 1 more job pending
+10138ms ╚Event processed successfully (10138ms)
2/17/2019, 3:59:11 PM +551ms
+1ms ╔Received event [Water Recirculation].switch = off with a delay of 437ms
+907ms ║Setting up scheduled job for Sun, Feb 17 2019 @ 5:39:00 PM MST (in 5987.543s), with 1 more job pending
+919ms ╚Event processed successfully (919ms)
My question is, is it the job of the handler to eliminate switch bounces if they occur? (I’m guessing Yes.) If so, is there an example of a switch handler that handles a switch bounce correctly? Maybe to put in a test that if a condition occurs that the same condition cannot occur again until the opposite condition occurs (ie, only communicate an OFF if it was preceded by an ON but never allow 2 OFFs in a row).