Help with 1st Piston involving setting light level with motion and resetting to previous level


#1

1) Give a description of the problem
With Stringify going away I needed an app to handle those flows. After Googling I found so many referencing webCoRE. Researching I can see it can do everything I need plus a LOT more. Now it’s just a learning curve. I picked what I thought would be an easy first piston. It involves a Smartthings motion sensor and a Cree Connected Zigbee light.
2) What is the expected behaviour?
Expected behavior is:
Light turns on at sunset to 30%
If motion changes to active then set to 100%
After 60 seconds of no motion set back to 30%
At sunrise turn off light

3) What is happening/not happening?
Light turns on at sunset to 30% - working
If motion changes to active then set to 100% - working
After 60 seconds of no motion set back to 30% - not working
At sunrise turn off light - working
The greenshot I’m posting is the current version after many other failed attempts. What is happening is no matter where I put the 60 second wait or other changes I make the light always goes back to 30% after 20 seconds which is when the motion sensor resets to no motion.
**4) Post a Green Snapshot of the piston![image|45x37]


5) Attach logs after turning logging level to Full
5/22/2019, 8:06:19 PM +251ms
+0ms ╔Received event [Home].time = 1558573580306 with a delay of -1056ms
+146ms ║RunTime Analysis CS > 23ms > PS > 57ms > PE > 67ms > CE
+148ms ║WARNING: Results may be unreliable because the parent app’s version (v0.3.10c.20190522) is newer than the child app’s version (v0.3.10a.20190223). Please consider updating both apps to the same version.
+152ms ║Runtime (41784 bytes) successfully initialized in 57ms (v0.3.10a.20190223) (151ms)
+154ms ║╔Execution stage started
+189ms ║║Cancelling condition #28’s schedules…
+191ms ║║Condition #28 evaluated true (3ms)
+265ms ║║Comparison (time) 75979445 is_between (time) 1558572540000 … (time) 1558520280000 = true (24ms)
+268ms ║║Time restriction check passed
+272ms ║║Condition #29 evaluated true (79ms)
+275ms ║║Cancelling condition #27’s schedules…
+277ms ║║Condition group #27 evaluated true (state changed) (90ms)
+282ms ║║Cancelling statement #30’s schedules…
+299ms ║║Skipped execution of physical command [Porch Light].setLevel([30]) because it would make no change to the device. (8ms)
+301ms ║║Executed [Porch Light].setLevel (11ms)
+339ms ║║Comparison (time) 75979559 is_between (time) 1558520280000 … (time) 1558572540000 = false (24ms)
+343ms ║║Condition #22 evaluated false (34ms)
+345ms ║║Cancelling statement #22’s schedules…
+366ms ║║Requesting time schedule wake up at Thu, May 23 2019 @ 6:18:00 AM EDT
+372ms ║║Condition group #19 evaluated false (state did not change) (64ms)
+380ms ║╚Execution stage complete. (226ms)
+384ms ║Setting up scheduled job for Thu, May 23 2019 @ 6:18:00 AM EDT (in 33100.366s), with 2 more jobs pending
+397ms ╚Event processed successfully (398ms)
5/22/2019, 8:04:50 PM +38ms
+2ms ╔Received event [Porch Sensor].motion = inactive with a delay of 103ms
+121ms ║RunTime Analysis CS > 24ms > PS > 54ms > PE > 42ms > CE
+122ms ║WARNING: Results may be unreliable because the parent app’s version (v0.3.10c.20190522) is newer than the child app’s version (v0.3.10a.20190223). Please consider updating both apps to the same version.
+125ms ║Runtime (41779 bytes) successfully initialized in 54ms (v0.3.10a.20190223) (121ms)
+126ms ║╔Execution stage started
+177ms ║║Comparison (time) 75890170 is_between (time) 1558572540000 … (time) 1558520280000 = true (14ms)
+179ms ║║Time restriction check passed
+181ms ║║Condition #4 evaluated true (48ms)
+182ms ║║Cancelling statement #4’s schedules…
+193ms ║║Requesting time schedule wake up at Thu, May 23 2019 @ 6:18:00 AM EDT
+197ms ║║Condition group #1 evaluated true (state did not change) (65ms)
+199ms ║║Cancelling statement #2’s schedules…
+224ms ║║Executed physical command [Porch Light].setLevel([30]) (17ms)
+225ms ║║Executed [Porch Light].setLevel (20ms)
+234ms ║║Comparison (enum) inactive changes_to (string) active = false (1ms)
+236ms ║║Cancelling condition #11’s schedules…
+238ms ║║Condition #11 evaluated false (7ms)
+239ms ║║Cancelling condition #23’s schedules…
+240ms ║║Condition group #23 evaluated false (state changed) (11ms)
+241ms ║║Cancelling condition #5’s schedules…
+243ms ║║Condition group #5 evaluated false (state changed) (14ms)
+254ms ║║Comparison (integer) 100 is_equal_to (integer) 100 = true (2ms)
+256ms ║║Cancelling condition #33’s schedules…
+257ms ║║Condition #33 evaluated true (11ms)
+265ms ║║Comparison (enum) inactive stays (string) inactive = true (2ms)
+268ms ║║Adding a timed trigger schedule for condition 28
+271ms ║║Cancelling condition #28’s schedules…
+272ms ║║Condition #28 evaluated false (13ms)
+273ms ║║Condition group #27 evaluated false (state did not change) (27ms)
+295ms ║║Comparison (time) 75890315 is_between (time) 1558520280000 … (time) 1558572540000 = false (14ms)
+297ms ║║Condition #22 evaluated false (20ms)
+299ms ║║Cancelling statement #22’s schedules…
+311ms ║║Requesting time schedule wake up at Thu, May 23 2019 @ 6:18:00 AM EDT
+314ms ║║Condition group #19 evaluated false (state did not change) (38ms)
+321ms ║╚Execution stage complete. (195ms)
+324ms ║Setting up scheduled job for Wed, May 22 2019 @ 9:06:20 PM EDT (in 89.945s), with 3 more jobs pending
+337ms ╚Event processed successfully (337ms)
5/22/2019, 8:04:29 PM +327ms
+1ms ╔Received event [Porch Sensor].motion = active with a delay of 139ms
+77ms ║RunTime Analysis CS > 12ms > PS > 31ms > PE > 33ms > CE
+78ms ║WARNING: Results may be unreliable because the parent app’s version (v0.3.10c.20190522) is newer than the child app’s version (v0.3.10a.20190223). Please consider updating both apps to the same version.
+80ms ║Runtime (41782 bytes) successfully initialized in 31ms (v0.3.10a.20190223) (78ms)
+81ms ║╔Execution stage started
+124ms ║║Comparison (time) 75869415 is_between (time) 1558572540000 … (time) 1558520280000 = true (13ms)
+125ms ║║Time restriction check passed
+127ms ║║Condition #4 evaluated true (40ms)
+129ms ║║Cancelling statement #4’s schedules…
+140ms ║║Requesting time schedule wake up at Thu, May 23 2019 @ 6:18:00 AM EDT
+143ms ║║Condition group #1 evaluated true (state did not change) (56ms)
+146ms ║║Cancelling statement #2’s schedules…
+157ms ║║Skipped execution of physical command [Porch Light].setLevel([30]) because it would make no change to the device. (6ms)
+158ms ║║Executed [Porch Light].setLevel (8ms)
+167ms ║║Comparison (enum) active changes_to (string) active = true (1ms)
+169ms ║║Cancelling condition #11’s schedules…
+170ms ║║Condition #11 evaluated true (7ms)
+190ms ║║Comparison (time) 75869499 is_between (time) 1558572540000 … (time) 1558520280000 = true (13ms)
+191ms ║║Time restriction check passed
+193ms ║║Condition #10 evaluated true (22ms)
+195ms ║║Cancelling statement #10’s schedules…
+206ms ║║Requesting time schedule wake up at Thu, May 23 2019 @ 6:18:00 AM EDT
+209ms ║║Cancelling condition #23’s schedules…
+210ms ║║Condition group #23 evaluated true (state changed) (48ms)
+211ms ║║Cancelling condition #5’s schedules…
+212ms ║║Condition group #5 evaluated true (state changed) (51ms)
+215ms ║║Cancelling statement #24’s schedules…
+229ms ║║Executed physical command [Porch Light].setLevel([100]) (10ms)
+230ms ║║Executed [Porch Light].setLevel (11ms)
+242ms ║║Comparison (integer) 30 is_equal_to (integer) 100 = false (1ms)
+244ms ║║Condition #33 evaluated false (9ms)
+245ms ║║Condition group #27 evaluated false (state did not change) (10ms)
+266ms ║║Comparison (time) 75869575 is_between (time) 1558520280000 … (time) 1558572540000 = false (13ms)
+268ms ║║Condition #22 evaluated false (20ms)
+269ms ║║Cancelling statement #22’s schedules…
+280ms ║║Requesting time schedule wake up at Thu, May 23 2019 @ 6:18:00 AM EDT
+283ms ║║Condition group #19 evaluated false (state did not change) (36ms)
+289ms ║╚Execution stage complete. (207ms)
+291ms ║Setting up scheduled job for Thu, May 23 2019 @ 6:18:00 AM EDT (in 33210.383s), with 2 more jobs pending
+303ms ╚Event processed successfully (302ms)


#2

It looks to me that with the first if in place that it will go back to 30% almost immediately as soon as it sees that it’s between sunset and sunrise. (It would never reach the case where it’s 100% and inactive and between sunset and sunrise.) Is it setting back to 30% almost immediately?
How to fix it? My first thought to change the first if to read
If
time is between sunset and sunrise
and
white bulb 2’s level is not equal to 30%
and
Motion Sensor 2’s motion stays inactive for 90 seconds
then
with white bulb 2, set level to 30%
end if;
Then delete the second if with the set to 30%.


#3

Give this a try… I did this on my phone, not tested.


#4

@qoheleth - Thanks for the quick reply with help! I took your idea about the 1st if being sunset to sunrise and changed it to a happens daily at sunset like @eibyer has in his piston example. My porch light is working as desired. Have great holiday weekend!


#5

@eibyer - turns out I was oh so close with my first piston attempt. Your example was spot on the same as mine except the one thing both you and @qoheleth suggested - making the 1st “if” be just daily at sunset. That’s what did the job. The only tweak needed on your example was to set the “with” statement with the setting of the light and timer to Never on the Task Cancellation Policy. Thanks so much for taking the time to put together an example on your phone. Have a good Memorial Day weekend!