First piston - Garage Door Notification - is the programming correct?


#1

1) Give a description of the problem
No real problem, as what I have seems to be working. But… its my first time diving into this, with the help from several different examples. The ‘problem’ is that I’m curious if I could do this in a simpler way, or perhaps a ‘more correct’ way.

2) What is the expected behavior?
Send a notification via ST app to both user’s Android phones if the garage door is left open. Then repeat the message if it stays open. Current timing is open for 13 minutes initially, then every hour again after that until it is closed.

3) What is happening/not happening?
Again, seems to be working OK, just looking for streamlined or ‘correct’ programming. (I’m also sure there are MANY different ways to do this, and I’ve seen some rather complicated ones, I’m looking to keep it as simple as possible). I’m a bit concerned about my loop at the end to Execute the same piston again.

**4) Post a Green Snapshot of the piston

5) Attach any logs
1/22/2018, 1:11:10 PM +679ms
+1ms ╔Received event [Garage].contact = closed with a delay of 965ms
+129ms ║Setting up scheduled job for Mon, Jan 22 2018 @ 2:11:10 PM PST (in 3599.997s)
+141ms ╚Event processed successfully (141ms)
1/22/2018, 1:10:00 PM +684ms
+1ms ╔Received event [Garage].contact = open with a delay of 654ms
+130ms ║Setting up scheduled job for Mon, Jan 22 2018 @ 1:23:00 PM PST (in 779.98s), with 1 more job pending
+137ms ╚Event processed successfully (137ms)
1/22/2018, 12:18:44 PM +504ms
+1ms ╔Received event [Home].execute = :217f9676693fe70943bf7314e9dd13bd: with a delay of 47ms
+94ms ║Setting up scheduled job for Mon, Jan 22 2018 @ 1:18:44 PM PST (in 3599.997s)
+101ms ╚Event processed successfully (101ms)
1/22/2018, 12:18:44 PM +324ms
+1ms ╔Received event [Home].time = 1516652325679 with a delay of -1355ms
+142ms ╚Event processed successfully (142ms)
1/22/2018, 11:18:45 AM +591ms
+0ms ╔Received event [Home].execute = :217f9676693fe70943bf7314e9dd13bd: with a delay of 44ms
+92ms ║Setting up scheduled job for Mon, Jan 22 2018 @ 12:18:45 PM PST (in 3599.997s)
+100ms ╚Event processed successfully (99ms)
1/22/2018, 11:18:45 AM +437ms
+2ms ╔Received event [Home].time = 1516648726554 with a delay of -1302ms
+118ms ╚Event processed successfully (118ms)
1/22/2018, 10:18:46 AM +312ms
+2ms ╔Received event [Garage].contact = closed with a delay of 491ms
+247ms ║Setting up scheduled job for Mon, Jan 22 2018 @ 11:18:46 AM PST (in 3599.996s)
+310ms ╚Event processed successfully (310ms)
1/22/2018, 10:17:59 AM +196ms
+0ms ╔Received event [Garage].contact = open with a delay of 561ms
+100ms ║Setting up scheduled job for Mon, Jan 22 2018 @ 10:30:59 AM PST (in 779.989s), with 1 more job pending
+109ms ╚Event processed successfully (109ms)
1/22/2018, 9:41:32 AM +489ms
+0ms ╔Received event [Home].execute = :217f9676693fe70943bf7314e9dd13bd: with a delay of 49ms
+117ms ║Setting up scheduled job for Mon, Jan 22 2018 @ 10:41:32 AM PST (in 3599.997s)
+124ms ╚Event processed successfully (124ms)


#2

Personally I use a ‘WHILE’ statement.
This way WHILE the contact sensor is open the piston just keeps cycling through.
Ignore a lot of the dross in there but I’m sure it gives you an idea of what I’m talking about.
EDIT: Every 15 minutes the notification is sent while door is open.

image


#3

I agree that using one of the built-in loops is better than recursively calling your piston over again.

Also, where you have the Wait command and the Execute Piston command ensure that those parts of the piston run every time. So you could conceivably have multiple instances of this piston running using this structure.

You’ll notice from the logs that even the garage door being closed sends an event to the piston (default behavior) which will then cause it to wait for an hour and run itself again.

image


#4

OK, I do like the While Loop better. I was a bit concerned with getting the piston stuck in a loop by executing itself.

Here’s what I’ve come up with. I’m not home to test it, but looks like this should send a first message at 15 minutes, a second message 45 minutes later, and then messages every hour after that.

Would be nice to have the intervals at 15, 60, 60, etc…, but I like the simplicity of this one.


#5

Looks like what you have will work just fine.

A couple more steps and that’s easily possible. Rarely does setting a value for a variable at the top work out…but in this case it does.