Lights activate on motion piston don't reset wait condition


#1

1) Give a description of the problem
HI I’m new with webcore , I’m having an issue with a very simple piston that I don’t understand. Obviously I’m missing something here.

I simplified this piston example to replicate the issue in the best possible way.

If motion is detected the second time right after the dimmer goes to 10% it doesn’t execute the if condition. only works if motion is detected few seconds after else condition is executed.

2) What is the expected behaviour?
1)Motion is detected in the sensor then turns the light ON and dimmer is set level to 50%

2)If motion is no detected for 20 sec then dimmer set level to 10% (eventually turn off but I removed that part because that’s not part of the problem)

3)if motion is detected again while wait it will set the level back to 50%

3) What is happening/not happening?
This piston works ! the problem only happens when the motion is detected “immediately” after the 20 sec and set level to 10%, the IF is showing true again( motion sensor active) but it doesn’t execute that part of the piston to go back to set level 50%.

It seems that it is too fast and the piston is not ready and miss the motion active condition. Therefore, I have to wait until motion is inactive and then active again. (witch forces us to wait with the lights at 10% waving on the sensor for other 10 secs or more)

If motion is detected after 3 o more seconds of set level to 10% it works … the issue is only happening when motion is detected right after the else statement.

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)

FromExampleLightsRev002
Status

This piston is currently active and humming happily.

Piston Category
Quick Facts

Piston state: false

Last executed: 4/24/2020, 11:16:24 AM

Next scheduled: 4/24/2020, 11:16:25 AM

Subscriptions: 1 event, 1 control

Devices used: 2

Memory used: 15% (15483 bytes)

External URL: (click to open/execute)
Automatic Backup

You do not have automatic backup enabled for this piston.
Script
/**************************************************************/
/* FromExampleLightsRev002                                    */
/**************************************************************/
/* Author     : Martin                                        */
/* Created    : 4/24/2020, 11:08:55 AM                        */
/* Modified   : 4/24/2020, 11:12:35 AM                        */
/* Build      : 2                                             */
/* UI version : v0.3.110.20191009                             */
/**************************************************************/
 
+0msstart
/* Trace started on 4/24/2020, 11:16:24 AM (about 5 minutes ago) */
 
execute
+310ms27ms
if /* #1 */
Test_Motion's motion is active /* #2 */
then
with /* #8 */
WebKitchen Dimmer
do
Set level to 50%; /* #9 */
Turn on; /* #10 */
end with;
else
+315ms22ms
with /* #3 */
WebKitchen Dimmer
do
+318ms? ? ?
Wait 20 seconds; /* #4 */
+319ms18ms
Set level to 10%; /* #5 */
end with;
end if;
+337msdone
end execute;
 
+348msstop
/* Trace ended on 4/24/2020, 11:16:24 AM */
Logs
4/24/2020, 11:16:24 AM +80ms
+1ms 	+Received event [Sage].time = 1587748585830 with a delay of -1750ms
+303ms 	¦RunTime Analysis CS > 30ms > PS > 256ms > PE > 16ms > CE
+305ms 	¦Runtime (37096 bytes) successfully initialized in 256ms (v0.3.110.20191009) (303ms)
+306ms 	¦+Execution stage started
+335ms 	¦¦Executed physical command [WebKitchen Dimmer].setLevel([10]) (13ms)
+336ms 	¦¦Executed [WebKitchen Dimmer].setLevel (15ms)
+338ms 	¦+Execution stage complete. (33ms)
+340ms 	+Event processed successfully (339ms)
4/24/2020, 11:16:05 AM +720ms
+2ms 	+Received event [Test_Motion].motion = inactive with a delay of 1532ms
+87ms 	¦RunTime Analysis CS > 22ms > PS > 47ms > PE > 17ms > CE
+89ms 	¦Runtime (37089 bytes) successfully initialized in 47ms (v0.3.110.20191009) (86ms)
+90ms 	¦+Execution stage started
+97ms 	¦¦Comparison (enum) inactive is (string) active = false (1ms)
+99ms 	¦¦Cancelling condition #2's schedules...
+100ms 	¦¦Condition #2 evaluated false (5ms)
+101ms 	¦¦Cancelling condition #1's schedules...
+101ms 	¦¦Condition group #1 evaluated false (state changed) (7ms)
+103ms 	¦¦Cancelling statement #3's schedules...
+108ms 	¦¦Executed virtual command [WebKitchen Dimmer].wait (0ms)
+110ms 	¦¦Requesting a wake up for Fri, Apr 24 2020 @ 11:16:25 AM MDT (in 20.0s)
+113ms 	¦+Execution stage complete. (23ms)
+115ms 	¦Setting up scheduled job for Fri, Apr 24 2020 @ 11:16:25 AM MDT (in 19.996s)
+122ms 	+Event processed successfully (122ms)
4/24/2020, 11:16:00 AM +64ms
+1ms 	+Received event [Sage].time = 1587748561183 with a delay of -1119ms
+114ms 	¦RunTime Analysis CS > 31ms > PS > 67ms > PE > 16ms > CE
+117ms 	¦Runtime (37087 bytes) successfully initialized in 67ms (v0.3.110.20191009) (114ms)
+117ms 	¦+Execution stage started
+118ms 	¦+Execution stage complete. (1ms)
+120ms 	+Event processed successfully (120ms)
4/24/2020, 11:15:46 AM +826ms
+1ms 	+Received event [Test_Motion].motion = active with a delay of 78ms
+53ms 	¦RunTime Analysis CS > 13ms > PS > 27ms > PE > 13ms > CE
+55ms 	¦Runtime (37092 bytes) successfully initialized in 27ms (v0.3.110.20191009) (53ms)
+56ms 	¦+Execution stage started
+63ms 	¦¦Comparison (enum) active is (string) active = true (2ms)
+64ms 	¦¦Cancelling condition #2's schedules...
+65ms 	¦¦Condition #2 evaluated true (5ms)
+66ms 	¦¦Cancelling condition #1's schedules...
+67ms 	¦¦Condition group #1 evaluated true (state changed) (8ms)
+69ms 	¦¦Cancelling statement #8's schedules...
+80ms 	¦¦Executed physical command [WebKitchen Dimmer].setLevel([50]) (7ms)
+81ms 	¦¦Executed [WebKitchen Dimmer].setLevel (9ms)
+85ms 	¦¦Skipped execution of physical command [WebKitchen Dimmer].on([]) because it would make no change to the device. (1ms)
+85ms 	¦¦Executed [WebKitchen Dimmer].on (3ms)
+88ms 	¦+Execution stage complete. (32ms)
+89ms 	+Event processed successfully (88ms)
4/24/2020, 11:15:41 AM +100ms
+0ms 	+Received event [Test_Motion].motion = inactive with a delay of 101ms
+62ms 	¦RunTime Analysis CS > 18ms > PS > 35ms > PE > 10ms > CE
+64ms 	¦Runtime (37088 bytes) successfully initialized in 35ms (v0.3.110.20191009) (63ms)
+65ms 	¦+Execution stage started
+72ms 	¦¦Comparison (enum) inactive is (string) active = false (1ms)
+73ms 	¦¦Cancelling condition #2's schedules...
+74ms 	¦¦Condition #2 evaluated false (5ms)
+75ms 	¦¦Cancelling condition #1's schedules...
+76ms 	¦¦Condition group #1 evaluated false (state changed) (7ms)
+78ms 	¦¦Cancelling statement #3's schedules...
+82ms 	¦¦Executed virtual command [WebKitchen Dimmer].wait (0ms)
+83ms 	¦¦Requesting a wake up for Fri, Apr 24 2020 @ 11:16:01 AM MDT (in 20.0s)
+86ms 	¦+Execution stage complete. (21ms)
+88ms 	¦Setting up scheduled job for Fri, Apr 24 2020 @ 11:16:01 AM MDT (in 19.996s)
+98ms 	+Event processed successfully (98ms)
4/24/2020, 11:15:11 AM +504ms
+1ms 	+Received event [Test_Motion].motion = active with a delay of 95ms
+175ms 	¦RunTime Analysis CS > 24ms > PS > 137ms > PE > 15ms > CE
+177ms 	¦Runtime (37095 bytes) successfully initialized in 137ms (v0.3.110.20191009) (175ms)
+178ms 	¦+Execution stage started
+185ms 	¦¦Comparison (enum) active is (string) active = true (1ms)
+187ms 	¦¦Cancelling condition #2's schedules...
+188ms 	¦¦Condition #2 evaluated true (5ms)
+189ms 	¦¦Cancelling condition #1's schedules...
+189ms 	¦¦Condition group #1 evaluated true (state changed) (7ms)
+191ms 	¦¦Cancelling statement #8's schedules...
+201ms 	¦¦Skipped execution of physical command [WebKitchen Dimmer].setLevel([50]) because it would make no change to the device. (5ms)
+202ms 	¦¦Executed [WebKitchen Dimmer].setLevel (6ms)
+206ms 	¦¦Skipped execution of physical command [WebKitchen Dimmer].on([]) because it would make no change to the device. (1ms)
+207ms 	¦¦Executed [WebKitchen Dimmer].on (3ms)
+209ms 	¦+Execution stage complete. (31ms)
+210ms 	+Event processed successfully (210ms)
4/24/2020, 11:15:10 AM +166ms
+1ms 	+Received event [Sage].time = 1587748511015 with a delay of -849ms
+143ms 	¦RunTime Analysis CS > 58ms > PS > 74ms > PE > 11ms > CE
+147ms 	¦Runtime (37093 bytes) successfully initialized in 74ms (v0.3.110.20191009) (143ms)
+148ms 	¦+Execution stage started
+174ms 	¦¦Executed physical command [WebKitchen Dimmer].setLevel([10]) (8ms)
+175ms 	¦¦Executed [WebKitchen Dimmer].setLevel (11ms)
+179ms 	¦+Execution stage complete. (32ms)
+181ms 	+Event processed successfully (180ms)
4/24/2020, 11:14:50 AM +935ms
+1ms 	+Received event [Test_Motion].motion = inactive with a delay of 87ms
+59ms 	¦RunTime Analysis CS > 14ms > PS > 36ms > PE > 9ms > CE
+61ms 	¦Runtime (37086 bytes) successfully initialized in 36ms (v0.3.110.20191009) (59ms)
+62ms 	¦+Execution stage started
+69ms 	¦¦Comparison (enum) inactive is (string) active = false (1ms)
+70ms 	¦¦Cancelling condition #2's schedules...
+71ms 	¦¦Condition #2 evaluated false (5ms)
+72ms 	¦¦Cancelling condition #1's schedules...
+73ms 	¦¦Condition group #1 evaluated false (state changed) (8ms)
+75ms 	¦¦Cancelling statement #3's schedules...
+79ms 	¦¦Executed virtual command [WebKitchen Dimmer].wait (0ms)
+80ms 	¦¦Requesting a wake up for Fri, Apr 24 2020 @ 11:15:11 AM MDT (in 20.0s)
+83ms 	¦+Execution stage complete. (21ms)
+84ms 	¦Setting up scheduled job for Fri, Apr 24 2020 @ 11:15:11 AM MDT (in 19.996s)
+140ms 	+Event processed successfully (140ms)
4/24/2020, 11:14:33 AM +598ms
+1ms 	+Received event [Test_Motion].motion = active with a delay of 91ms
+76ms 	¦RunTime Analysis CS > 20ms > PS > 43ms > PE > 14ms > CE
+78ms 	¦Runtime (37092 bytes) successfully initialized in 43ms (v0.3.110.20191009) (76ms)
+79ms 	¦+Execution stage started
+85ms 	¦¦Comparison (enum) active is (string) active = true (1ms)
+87ms 	¦¦Cancelling condition #2's schedules...
+87ms 	¦¦Condition #2 evaluated true (5ms)
+88ms 	¦¦Cancelling condition #1's schedules...
+89ms 	¦¦Condition group #1 evaluated true (state changed) (7ms)
+91ms 	¦¦Cancelling statement #8's schedules...
+112ms 	¦¦Executed physical command [WebKitchen Dimmer].setLevel([50]) (17ms)
+113ms 	¦¦Executed [WebKitchen Dimmer].setLevel (18ms)
+118ms 	¦¦Skipped execution of physical command [WebKitchen Dimmer].on([]) because it would make no change to the device. (3ms)
+119ms 	¦¦Executed [WebKitchen Dimmer].on (5ms)
+121ms 	¦+Execution stage complete. (43ms)
+122ms 	+Event processed successfully (122ms)
4/24/2020, 11:14:23 AM +55ms
+1ms 	+Received event [Sage].time = 1587748464080 with a delay of -1025ms
+60ms 	¦RunTime Analysis CS > 17ms > PS > 32ms > PE > 11ms > CE
+63ms 	¦Runtime (37093 bytes) successfully initialized in 32ms (v0.3.110.20191009) (62ms)
+65ms 	¦+Execution stage started
+290ms 	¦¦Executed physical command [WebKitchen Dimmer].setLevel([10]) (210ms)
+291ms 	¦¦Executed [WebKitchen Dimmer].setLevel (212ms)
+294ms 	¦+Execution stage complete. (229ms)
+295ms 	+Event processed successfully (295ms)
4/24/2020, 11:14:04 AM +2ms
+1ms 	+Received event [Test_Motion].motion = inactive with a delay of 2825ms
+56ms 	¦RunTime Analysis CS > 14ms > PS > 34ms > PE > 8ms > CE
+59ms 	¦Runtime (37088 bytes) successfully initialized in 34ms (v0.3.110.20191009) (56ms)
+59ms 	¦+Execution stage started
+66ms 	¦¦Comparison (enum) inactive is (string) active = false (1ms)
+68ms 	¦¦Cancelling condition #2's schedules...
+68ms 	¦¦Condition #2 evaluated false (5ms)
+69ms 	¦¦Cancelling condition #1's schedules...
+70ms 	¦¦Condition group #1 evaluated false (state changed) (7ms)
+72ms 	¦¦Cancelling statement #3's schedules...
+76ms 	¦¦Executed virtual command [WebKitchen Dimmer].wait (0ms)
+77ms 	¦¦Requesting a wake up for Fri, Apr 24 2020 @ 11:14:24 AM MDT (in 20.0s)
+81ms 	¦+Execution stage complete. (22ms)
+82ms 	¦Setting up scheduled job for Fri, Apr 24 2020 @ 11:14:24 AM MDT (in 19.996s)
+91ms 	+Event processed successfully (91ms)
4/24/2020, 11:13:44 AM +915ms
+1ms 	+Received event [Test_Motion].motion = active with a delay of 76ms
+52ms 	¦RunTime Analysis CS > 15ms > PS > 30ms > PE > 7ms > CE
+54ms 	¦Runtime (37091 bytes) successfully initialized in 30ms (v0.3.110.20191009) (53ms)
+55ms 	¦+Execution stage started
+62ms 	¦¦Comparison (enum) active is (string) active = true (1ms)
+63ms 	¦¦Cancelling condition #2's schedules...
+64ms 	¦¦Condition #2 evaluated true (5ms)
+65ms 	¦¦Cancelling condition #1's schedules...
+65ms 	¦¦Condition group #1 evaluated true (state changed) (7ms)
+67ms 	¦¦Cancelling statement #8's schedules...
+77ms 	¦¦Executed physical command [WebKitchen Dimmer].setLevel([50]) (6ms)
+78ms 	¦¦Executed [WebKitchen Dimmer].setLevel (8ms)
+85ms 	¦¦Executed physical command [WebKitchen Dimmer].on() (5ms)
+86ms 	¦¦Executed [WebKitchen Dimmer].on (7ms)
+88ms 	¦+Execution stage complete. (33ms)
+89ms 	+Event processed successfully (89ms)
Logging level 
Variables
Local variables
(no variables defined)
Global variables
(no variables defined)
System variables
dynamic$argsnull
integer$day24
integer$dayOfWeek5
string$dayOfWeekNameFriday
device$deviceLocation
device$devicesLocation
integer$hour11
integer$hour2411
string$httpContentType
integer$httpStatusCode
boolean$httpStatusOk
integer$iftttStatusCode
boolean$iftttStatusOk
dynamic$incidentsnull
decimal$index
dynamic$jsonnull
datetime$localNow1587726756533
device$locationLocation
string$locationModeHome
integer$mediaSize0
string$meridianAM
string$meridianWithDotsA.M.
datetime$midnight4/24/2020, 12:00:00 AM
integer$minute12
integer$month4
string$monthNameApril
string$nameFromExampleLightsRev002
datetime$nextMidnight4/25/2020, 12:00:00 AM
datetime$nextNoon4/24/2020, 12:00:00 PM
datetime$nextScheduledTimeInvalid Date
datetime$nextSunrise4/25/2020, 6:21:00 AM
datetime$nextSunset4/24/2020, 8:49:00 PM
dynamic$nflnull
datetime$noon4/24/2020, 12:00:00 PM
datetime$now4/24/2020, 11:12:36 AM
dynamic$placesnull
decimal$random0.9293624341848755
string$randomColor#FFD700
string$randomColorNameDim Gray
integer$randomHue5
integer$randomLevel43
integer$randomSaturation50
dynamic$responsenull
integer$second36
boolean$shmTrippedfalse
string$state(not set)
datetime$sunrise4/24/2020, 6:21:00 AM
datetime$sunset4/24/2020, 8:49:00 PM
string$temperatureScaleC
string$time11:12 A.M.
string$time2411:12
dynamic$twcweathernull
datetime$utc1587748356574
string$versionv0.3.110.20191009
dynamic$weathernull
integer$year2020
Evaluation Console
Statistics

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

Here is how I would do this. (3 triggers in a single piston)

IF Sensor's motion changes to active
    Then Set Dimmer level to 50%
END IF

IF Sensor's motion stays inactive for 30 sec
    Then Set Dimmer level to 10%
END IF

IF Sensor's motion stays inactive for 5 minutes
    Then Set Dimmer switch to off
END IF

The latter two blocks are cancelled anytime motion is detected.


#3

Hi Dear. I did modify the logic as per your suggestions.

Here is the piston that I tested.

The issue is still happening only when the motion sensor detects motion right after lights dimm to 10% . If I wait 3 to 4 seconds after dimms to 10% the piston works fine.

I also notice that when the lights goes OFF in the last condition they can turn back on immediately , It means this issue doesn’t appear to happen here.

It makes me think that the problem could be in the dimmer itself not i

n the piston I I can see the piston working , but the level just doesn’t change.

I’m using an zooz ZEN27 dimmer . I’ll test this with a different dimmer . Maybe it’s not fast enough to change the level as it is to turn on the lights, and it miss the command to change the level the first time. I experienced the same effect trying to do this with an standard automation in smartthings , that is why I tried with webcore.

Let me know if this makes sense to you .

Thank you


#4

You may be able to add a short wait before setting the level to 10%


This is good, right?
We just need to get this quick reaction time for the 10%.

This slight variation may do the trick:


Side Note:

You may want to clear your logs, and set the level to Full for future troubleshooting.
(the log in your first post shows that all commands were sent properly)


#5

Hi Thank you for you replay!

I have tried that, It didn’t work because it was like adding 3 sec to the IF condition, (wait 33 instead of 30) but the issue’s still occur after set level changes.

I think I need to find the way to delay the sensor in sending a motion to the first IF.

Maybe adding a variable that I can delay the sensor for few seconds giving time for the dimmer to be ready. Maybe play with executions methods could it help here? Or execution policies? I’m not too familiar with the implications of changing those.

In a real life when the lights dim to 10% in the kitchen sometimes you move right after and that triggers this weird condition that keep you in the dark.

Thank you very much for helping me with this.!

Martin


#6

For what it’s worth, the easiest solution would be to increase your “inactive” alert to something longer… (2 or 3 minutes seems to be the “norm”) This should give ample time for the sensor to detect additional motion (if you are walking around in the kitchen), yet will still shut off shortly after the room is vacated.

If you are determined to get to the bottom of this, you can also try a different Device Handler (controlling your current bulb), or even another brand’s bulb entirely. (with snappier response times)


SmartThings & webCoRE are “event driven”, so whenever the sensor’s motion changes to either active or inactive, then all pistons that are subscribed to that device will execute immediately.

Now you can make the sensor trigger a piston that adds a wait and then turns on the lights to 50%, but this is a separate piston, and it means removing the triggers from this piston. (which kind of defeats the whole purpose) It also means when you first enter a room, it will stay dark for a bit.


Alternatively, your first block can be changed to this:

IF Sensor's motion changes to active
Then
    Turn on
    Wait 1 sec
    Turn on
END IF

This is just a safety net in case there is too much commotion in your household for the first command to get thru. (although, I think my first paragraph in this post is a better route to take)


Speaking of commotion:

If you have other pistons with a lightning bolt next to:
pic
it may be worth checking those pistons as well… If too many pistons are trying to execute in the same millisecond, there are bound to be some commands that don’t get thru.

(remember, every log I have looked at so far, was 100% accurate and doing exactly what you want)


#7

Hi Thank you for your help with this issue.

I have tested different options and here are the results of my test

I believe your suggestion to re sending the ON command multiple times to ensure the lights are still on is the solution, very simple workaround that solve the problem. It delays the process a little but it’s acceptable for a kitchen logic.

“IF Sensor's motion changes to active
Then
Turn on
Wait 1 sec
Turn on
“END IF

This is definitely a hardware issue. I am using zooz ZEN27 dimmer. I have tested the same piston with a Leviton dimmer and it worked just fine, no issues no special logic needed. I don’t have any other brands to test.

I have attached the final piston for reference. I did try multiple combinations of your idea and found that the best was adding multiple “short waits” this increased responsiveness and ensured that command is always received.

Thank you very much for your help

Martin

Preformatted text


#8