Piston notifying outside of conditions


#1

1) Give a description of the problem
I’m using a piston I found here on the community to notify if my garage or front door has been left open. After the duration period, I’m notified along with my room mates, how long the specific instance has been open, and then continually notified until the sensor is closed again. I’d like to do the same with the back door, but its a bit different. I’m so new at this its hard to wrap my head around it.

2) What is the expected behavior?
I’d like the back door to function like the others. We often leave the back door open for the dog most of the day, so the duration for notification is 8 hours open. After eight hours, I’d like to be notified, and then notified again once the door is closed.

3) What is happening/not happening?
Instead, after a certain amount of time leaving the door open we’ll be notified that the door has been closed. But, since 8 hours hasn’t gone by, this behavior is annoying. I’d only like to receive the notification if the door has already been open for the time specified.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
12/17/2017, 2:59:59 PM +45ms +1ms ╔Received event [Back Door Sensor].contact = closed with a delay of 280ms +108ms ║RunTime Analysis CS > 17ms > PS > 26ms > PE > 64ms > CE +110ms ║Runtime (41695 bytes) successfully initialized in 26ms (v0.2.100.20171211) (108ms) +112ms ║╔Execution stage started +123ms ║║Comparison (enum) closed is (string) open = false (2ms) +124ms ║║Cancelling condition #6's schedules... +150ms ║║Calculating (long) 379843 / (long) 60000 >> (long) 6.3307166667 +154ms ║║Comparison (integer) 8 is_less_than (decimal) 6 = false (1ms) +155ms ║║Cancelling condition #10's schedules... +156ms ║║Condition #10 evaluated false (28ms) +157ms ║║Cancelling condition #7's schedules... +158ms ║║Condition group #7 evaluated false (state changed) (31ms) +160ms ║║Condition #6 evaluated false (41ms) +161ms ║║Cancelling condition #1's schedules... +161ms ║║Condition group #1 evaluated false (state changed) (44ms) +164ms ║╚Execution stage complete. (53ms) +166ms ╚Event processed successfully (166ms) 12/17/2017, 2:53:39 PM +634ms +2ms ╔Received event [Back Door Sensor].contact = open with a delay of 286ms +129ms ║RunTime Analysis CS > 30ms > PS > 34ms > PE > 64ms > CE +131ms ║Runtime (41697 bytes) successfully initialized in 34ms (v0.2.100.20171211) (129ms) +132ms ║╔Execution stage started +144ms ║║Comparison (enum) open is (string) open = true (2ms) +146ms ║║Cancelling condition #6's schedules... +146ms ║║Condition #6 evaluated true (7ms) +148ms ║║Cancelling condition #1's schedules... +148ms ║║Condition group #1 evaluated true (state changed) (10ms) +151ms ║║Cancelling statement #2's schedules... +154ms ║║Executed virtual command wait (0ms) +156ms ║║Requesting a wake up for Sun, Dec 17 2017 @ 10:53:39 PM PST (in 28800.0s) +161ms ║╚Execution stage complete. (29ms) +163ms ║Setting up scheduled job for Sun, Dec 17 2017 @ 10:53:39 PM PST (in 28799.994s) +174ms ╚Event processed successfully (173ms) 12/17/2017, 1:16:50 PM +996ms +1ms ╔Received event [Back Door Sensor].contact = closed with a delay of 461ms +95ms ║RunTime Analysis CS > 16ms > PS > 24ms > PE > 56ms > CE +98ms ║Runtime (41694 bytes) successfully initialized in 24ms (v0.2.100.20171211) (96ms) +99ms ║╔Execution stage started +110ms ║║Comparison (enum) closed is (string) open = false (2ms) +112ms ║║Cancelling condition #6's schedules... +133ms ║║Calculating (long) 8634080 / (long) 60000 >> (long) 143.9013333333 +137ms ║║Comparison (integer) 8 is_less_than (decimal) 143 = true (1ms) +138ms ║║Cancelling condition #10's schedules... +139ms ║║Condition #10 evaluated true (25ms) +140ms ║║Cancelling condition #7's schedules... +141ms ║║Condition group #7 evaluated true (state changed) (27ms) +143ms ║║Cancelling statement #8's schedules... +268ms ║║Executed virtual command sendPushNotification (120ms) +286ms ║║Executed virtual command sendSMSNotification (10ms) +305ms ║║Executed virtual command sendSMSNotification (11ms) +307ms ║║Condition #6 evaluated false (202ms) +308ms ║║Cancelling condition #1's schedules... +309ms ║║Condition group #1 evaluated false (state changed) (204ms) +312ms ║╚Execution stage complete. (213ms) +313ms ╚Event processed successfully (313ms) 12/17/2017, 10:52:57 AM +552ms +1ms ╔Received event [Back Door Sensor].contact = open with a delay of 506ms +100ms ║RunTime Analysis CS > 23ms > PS > 24ms > PE > 54ms > CE +103ms ║Runtime (41697 bytes) successfully initialized in 24ms (v0.2.100.20171211) (101ms) +104ms ║╔Execution stage started +115ms ║║Comparison (enum) open is (string) open = true (1ms) +116ms ║║Cancelling condition #6's schedules... +117ms ║║Condition #6 evaluated true (7ms) +118ms ║║Cancelling condition #1's schedules... +119ms ║║Condition group #1 evaluated true (state changed) (10ms) +122ms ║║Cancelling statement #2's schedules... +125ms ║║Executed virtual command wait (1ms) +126ms ║║Requesting a wake up for Sun, Dec 17 2017 @ 6:52:57 PM PST (in 28800.0s) +131ms ║╚Execution stage complete. (28ms) +133ms ║Setting up scheduled job for Sun, Dec 17 2017 @ 6:52:57 PM PST (in 28799.995s) +143ms ╚Event processed successfully (143ms)

REMOVE BELOW AFTER READING


#2

Your duration is in hours, but your comparison is in minutes

Try previousAge([door : contact])/3600000


#3

Great, thank you!

So the wiki definitely says the function previousAge specifies milliseconds. I can see that 3600000=1hr, but don’t actually grasp what the comparison does, and would like to know if you have the time.


#4

The way i read it, when the door is closed the piston checks to see if the door had been open longer than {duration}, and will send a notification only if that’s true. Thus, in your example, if the door is left open just six hours, you won’t receive a notice that has been left open, nor will you receive a notice when it is closed.


#5

That helps clear it up. Sometimes it makes sense to have someone confirm what you’re thinking. thanks!