Two garage gate sensors as a triggers


#1

1) Give a description of the problem
My piston worked perfectly when I was using only one garage gate sensor. When I added second it gives me 2 wrong notifications at the same time.

2) What is the expected behaviour?
Sometimes my garage gate opens by itself after a second it was closed. I created a piston which checks if this situation happened and gives me a notification. Everything worked great until I added second gate sensor as a trigger. Now I get 2 notifications at same time after every garage gate closing.

3) What is happening/not happening?
See above

**4) Post a Green Snapshot of the piston!

5) Attach logs after turning logging level to Full
16.10.2024, 16:55:46 +395ms
+3ms ╔Working queued event [Czujnik bramy garażowej 2].contact = closed with a delay of 621ms, canQueue: false, calledMyself: true
+8ms ║RunTime initialize > 7 LockT > 0ms > r9T > 3ms > pistonT > 1ms (first state access 1 m:4 3 4)
+14ms ║Runtime (6844 bytes) initialized in 3ms (v0.3.114.20231008_HE)
+16ms ║╔Execution stage started
+193ms ║║Found matching value, duration 1031ms for is < 3000ms threshold = true
+194ms ║║Comparison (enum) closed was (string) closed = true (170ms)
+196ms ║║Condition #2 evaluated true (175ms)
+197ms ║║Condition group #1 evaluated true (condition did not change) (177ms)
+216ms ║║Executed device command [Paulina].deviceNotification(Brama garażowa sama się otworzyła!) (15ms)
+233ms ║║Executed device command [Seba].deviceNotification(Brama garażowa sama się otworzyła!) (14ms)
+240ms ║║Comparison (enum) off is (string) on = false (1ms)
+242ms ║║Condition #6 evaluated false (6ms)
+243ms ║║Condition group #5 evaluated false (condition did not change) (7ms)
+248ms ║╚Execution stage complete. (232ms)
+252ms ╚Event processed successfully (251ms)
16.10.2024, 16:55:45 +593ms
+3ms ╔Received event [Czujnik bramy garażowej].contact = closed with a delay of 39ms, canQueue: true, calledMyself: false
+32ms ║RunTime initialize > 31 LockT > 1ms > r9T > 3ms > pistonT > 1ms (first state access 24 m:27 4 27)
+38ms ║Runtime (6880 bytes) initialized in 3ms (v0.3.114.20231008_HE)
+40ms ║╔Execution stage started
+303ms ║║No matching value, duration 0ms for is < 3000ms threshold = false
+304ms ║║Comparison (enum) closed was (string) closed = false (244ms)
+496ms ║║Found matching value, duration 298ms for is < 3000ms threshold = true
+497ms ║║Comparison (enum) open was (string) closed = true (191ms)
+523ms ║║Condition #2 evaluated true (456ms)
+526ms ║║Condition group #1 evaluated true (condition changed) (482ms)
+701ms ║║Executed device command [Paulina].deviceNotification(Brama garażowa sama się otworzyła!) (170ms)
+740ms ║║Executed device command [Seba].deviceNotification(Brama garażowa sama się otworzyła!) (37ms)
+748ms ║║Comparison (enum) off is (string) on = false (2ms)
+751ms ║║Condition #6 evaluated false (6ms)
+753ms ║║Condition group #5 evaluated false (condition did not change) (10ms)
+759ms ║╚Execution stage complete. (719ms)
+765ms ╚Event processed successfully (763ms)
16.10.2024, 16:55:45 +855ms
+4ms ╔Received event [Czujnik bramy garażowej 2].contact = closed with a delay of 81ms, canQueue: true, calledMyself: false
+18ms ╚Event queued (15ms)
16.10.2024, 16:55:19 +198ms
+3ms ╔Working queued event [Czujnik bramy garażowej].contact = open with a delay of 852ms, canQueue: false, calledMyself: true
+8ms ║RunTime initialize > 7 LockT > 0ms > r9T > 3ms > pistonT > 0ms (first state access 0 m:4 3 4)
+14ms ║Runtime (6835 bytes) initialized in 3ms (v0.3.114.20231008_HE)
+15ms ║╔Execution stage started
+114ms ║║Found matching value, duration 1494564ms for is < 3000ms threshold = false
+116ms ║║Comparison (enum) open was (string) closed = false (91ms)
+240ms ║║No matching value, duration 0ms for is < 3000ms threshold = false
+241ms ║║Comparison (enum) open was (string) closed = false (125ms)
+243ms ║║Condition #2 evaluated false (222ms)
+245ms ║║Condition group #1 evaluated false (condition did not change) (225ms)
+248ms ║╚Execution stage complete. (233ms)
+253ms ╚Event processed successfully (251ms)
16.10.2024, 16:55:18 +459ms

REMOVE BELOW AFTER READING


#2

Just for clarification, are the two sensors on the same gate, and you expect them to both trigger an open or close event at the same time?


#3

Yes they are on the same gate.
Second one is just for redundancy.

I want to have a notification if any of the sensors was closed for less than 3 seconds.


#4

I suspect the piston is being triggered twice, once for each sensor. If you read up on task cancellation policy, you may be able to get this to prevent the double trigger, but not sure with two triggers so close.
If you want to check for 3 seconds, maybe set a variable to $now when the event occurs, then when the other event occurs check for if being less than $now -(3601000)