Trying to turn on 3 different lights, but turn them off at different intervals based on the time of day


#1

1) Give a description of the problem
I’ve got the “turn on then wait then turn off” app down, so I wanted to up it a level. Right now, none of the lights turn on, and mostly it seems like the app fights itself

2) What is the expected behavior?
From 645 to 745, all the lights turn on for 10 minutes, then if there’s no motion it turns off.
From 745 to 9PM, 2 of the three lights turn on, one stays on for 10 minutes, the other for 5
From 9PM to 645AM, 2 lights turn on, one for 2 minutes, the other for 4.

3) What is happening/not happening?
For the most part, none of the lights turn on when I move.

**4) Post a Green Snapshot of the piston![image|45x37]
https://cdn1.imggmi.com/uploads/2019/3/7/b35a57bb0a124e95a9cbdb8aee3733e7-full.png

5) Attach any logs (From ST IDE and by turning logging level to Full)
3/6/2019, 8:06:32 PM +67ms
+0ms ╔Received event [Home].test = 1551924392066 with a delay of 0ms
+53ms ║RunTime Analysis CS > 30ms > PS > 6ms > PE > 17ms > CE
+55ms ║Runtime (40592 bytes) successfully initialized in 6ms (v0.3.10a.20190223) (54ms)
+57ms ║╔Execution stage started
+75ms ║║Comparison (enum) inactive is (string) active = false (3ms)
+77ms ║║Condition #2 evaluated false (13ms)
+79ms ║║Condition group #1 evaluated false (state did not change) (14ms)
+81ms ║║Skipping execution for statement #4 because condition state did not change
+94ms ║╚Execution stage complete. (37ms)
+97ms ║Setting up scheduled job for Wed, Mar 6 2019 @ 9:00:00 PM CST (in 3207.837s), with 2 more jobs pending
+108ms ╚Event processed successfully (107ms)


#2

That piston is illegible.

Please post the green snapshot via this highlighted button.

temp


#3

https://imggmi.com/full/2019/3/7/b35a57bb0a124e95a9cbdb8aee3733e7-full.png.html
How’s this?


#4

this


#5

I just set up something very similar. Mine is based on the ST modes, but you could easily set it up for time of day. Essentially, you’re creating variables that read out through an if/then statement. If it reads true (your time of day) it’ll call your preset timing variable.

You can check out my code here:


#6

What does canceling all pending tasks do for it? I think i’m close - it’s now turning on, but only for 30 seconds. SO progress! But I wonder if the canceling pending tasks causing issues?


#7

SO I"ve changed some formatting - now it looks like when the motion sensor turns to inactive, it turns on lights. HOWEVER, when i use the test function, it operates as expected. I think it’s getting caught up with on of the initial timing if’s.

Any tips would be greatly appreciated!


#8

So now I’ve moved the “turn off” functions of 2/3rds of my lights up to the “turn on” lines, so hopefully there will be more efficiency. Now, I just want the last light to stay on for either 3 minutes, 7 minutes or 15 minutes, depending on the time of day.

Would I set a global variable to determine what time of day it is or can I make it a local variable?

, it seems like when the motion sensor goes inactive, but it decides to turn ON a light (which happens to be the right time for) rather than going to the “else” portion and just waiting X minutes and turning off…?

I’m sure I have it miswired!

Here’s the log
3/17/2019, 1:14:07 PM +38ms
+2ms ╔Received event [Master bathroom motion Sensor].motion = inactive with a delay of 632ms
+99ms ║Runtime (40652 bytes) successfully initialized in 10ms (v0.3.10a.20190223) (96ms)
+101ms ║╔Execution stage started
+168ms ║║Executed [Master Bath Mirror Lights].on (4ms)
+172ms ║║Executed virtual command [Master Bath Mirror Lights].wait (1ms)
+174ms ║║Requesting a wake up for Sun, Mar 17 2019 @ 1:21:07 PM CDT (in 420.0s)
+181ms ║╚Execution stage complete. (80ms)
+183ms ║Setting up scheduled job for Sun, Mar 17 2019 @ 1:21:07 PM CDT (in 419.993s)
+195ms ╚Event processed successfully (195ms)
3/17/2019, 1:13:44 PM +598ms
+1ms ╔Received event [Master bathroom motion Sensor].motion = active with a delay of 632ms
+75ms ║Runtime (40658 bytes) successfully initialized in 7ms (v0.3.10a.20190223) (73ms)
+76ms ║╔Execution stage started
+118ms ║║Executed [Master Bathroom Overhead].on (17ms)
+166ms ║║Executed [Master Bath Mirror Lights].on (5ms)
+171ms ║║Executed virtual command [Master Bath Mirror Lights].wait (1ms)
+173ms ║║Requesting a wake up for Sun, Mar 17 2019 @ 1:20:44 PM CDT (in 420.0s)
+179ms ║╚Execution stage complete. (103ms)
+181ms ║Setting up scheduled job for Sun, Mar 17 2019 @ 1:20:44 PM CDT (in 419.993s)
+191ms ╚Event processed successfully (191ms)


#9

Currently, your ELSE block (lines 52-66) should only fire when there is not a change to Motion Sensor 7. And if there is not a change, then there is no trigger.

I think you want your ELSE moved to the ELSE section right after line 27.

temp


#10

James

Sorry for not seeing this post. To answer your question about having a global ‘Time of Day’ question, you can absolutely do that with a separate piston. I have mine save out and link to the SmartThings Mode (@locationMode), but I’m sure you could make it whatever you want.

Take a look at this to see if it helps. I’m not a pro, by any means, at Webcore, but to me this would make it a bit cleaner for what you want. You’ll see I make a bunch of variables to start things off. The reason I do this is so that I can potentially change things down the road very quickly (time outs/lights & switches/etc). But from there I create a compound if statement that says “If motion is detected AND its between two times THEN do this.”