Turn on/off lights based on motion.. stumped


#1

1) Give a description of the problem
Need to turn on two lights when theres motion on one sensor. Nothing should happen if the lights are already turned or if the TV is on.

I’ve handled all those conditions. Lights turn on when they should and they obey rules regarding swtich being on and TV being on.

The real problem I’m having is turning them off. I need for both of them to be turned off if there hasn’t been any motion in X minutes.

2) What is the expected behavior?
Lights should turn on with motion (WORKS)
Lights should do nothing if the switch is already on or if the TV is on (WORKING)
Lights should both turn off when there’s no motion in X minutes (NOT WORKING)

3) What is happening/not happening?
Can’t find the logic required for the lights to turn on after X minutes. I’ve tried multiple variations of “stays off for x minutes” and adding “wait for x minutes” before the off command.

I’m pretty sure I know what’s going on but can’t find a way to prevent it. Currently I have it so once the motion detector motion changes to inactive to turn them off after waiting 5 minutes. My guess is that once that 5 minutes timer starts it keeps counting down even though motion is detected again. Thus if you leave the area for 30 seconds (time it takes for the sensor to go back to inactive) then return (sensor changes to active) the light still turns off after a while.

**4) Post a Green Snapshot of the piston!

I really love the idea of webcore and the potential behind it but its really frustrating for me. I keep coming with piston ideas that in my mind seem very straight forward but then I turn them into a mess when trying them out; there’s always something that won’t work as expected that I never thought off


#2

Lines 43-51 should be outside the ELSE.


#3

HI @JAAS666
I believe it’s very simple…
instead of ELSE
use that as a second IF
Delete everything you have with ELSE
and add them outside of your first IF (not in)

IF motion sensor changes to active
do this do that (everything you have until line #42
LINE #43 or what ever is next should be :
IF motion sensor 2 motion stays inactive for 5 minutes
Then
With dimmer 2 and RGB bulb 2
Do
Turn OFF

that’s it you are good to go…


#4

hahahahahah did we post this at the same exact time LOL


#5

Beat you by two seconds, LOL


#6

The logic behind this @JAAS666 is an IF Trigger inside an IF Trigger will never fire


#7

Because you wrote it shorter…
umpire, I want to challange this… let’s watch the video pls.


#8

One of the few times my response was short…


#9

Oh yea I totally missed that. It is in fact inside the first if. Wow that was a quick response.

I tried it now and the timing is working correctly and it does get cancelled If I go back to the room… but something I’ve noticed now is that both lights WON’T turn off at the same time.

Here’s what I have now. Dimmer2 is turning off and about 5 seconds after that then the RGB turns OFF.


#10

Then post your logs…
most likely it’s a signal situation but when it comes to reading logs I step aside LOL i am not that good at reading them but no worries @WCmore is around right now:)


#11

I won’t be around for the next 15 hours, but I will be back…

A 1 second delay is normal, but 5 seconds is not.


#12

This time it took more than 5 seconds.

1/23/2019, 9:08:00 PM +180ms
+2ms ╔Received event [Texas].time/recovery = 1548299280178 with a delay of 1ms
+487ms ║RunTime Analysis CS > 188ms > PS > 252ms > PE > 47ms > CE
+491ms ║Runtime (40175 bytes) successfully initialized in 252ms (v0.3.109.20181207) (486ms)
+493ms ║╔Execution stage started
+506ms ║║Cancelling condition #1’s schedules…
+512ms ║║Cancelling condition #1’s schedules…
+554ms ║║Cancelling condition #25’s schedules…
+556ms ║║Condition #25 evaluated true (3ms)
+558ms ║║Cancelling condition #24’s schedules…
+560ms ║║Condition group #24 evaluated true (state changed) (9ms)
+564ms ║║Cancelling statement #26’s schedules…
+574ms ║║Skipped execution of physical command [Living Room Sconces].off([]) because it would make no change to the device. (3ms)
+575ms ║║Executed [Living Room Sconces].off (7ms)
+583ms ║║Skipped execution of physical command [TV LED Lighting].off([]) because it would make no change to the device. (3ms)
+585ms ║║Executed [TV LED Lighting].off (5ms)
+589ms ║╚Execution stage complete. (97ms)
+591ms ╚Event processed successfully (591ms)
1/23/2019, 9:07:23 PM +155ms
+2ms ╔Received event [Living Room Motion].motion = inactive with a delay of 638ms
+123ms ║RunTime Analysis CS > 21ms > PS > 66ms > PE > 37ms > CE
+126ms ║Runtime (40171 bytes) successfully initialized in 66ms (v0.3.109.20181207) (124ms)
+127ms ║╔Execution stage started
+172ms ║║Comparison (time) 76043289 is_between (datetime) 1548287880000 … (time) 14400000 = true (10ms)
+174ms ║║Time restriction check passed
+176ms ║║Condition #9 evaluated true (43ms)
+177ms ║║Condition group #1 evaluated true (state did not change) (44ms)
+183ms ║║Comparison (enum) inactive changes_to (string) active = false (1ms)
+185ms ║║Cancelling condition #3’s schedules…
+186ms ║║Condition #3 evaluated false (7ms)
+188ms ║║Cancelling condition #1’s schedules…
+189ms ║║Condition group #1 evaluated false (state changed) (10ms)
+198ms ║║Comparison (enum) inactive stays (string) inactive = true (2ms)
+201ms ║║Adding a timed trigger schedule for condition 25
+204ms ║║Condition #25 evaluated false (12ms)
+205ms ║║Condition group #24 evaluated false (state did not change) (13ms)
+208ms ║╚Execution stage complete. (81ms)
+210ms ║Setting up scheduled job for Wed, Jan 23 2019 @ 9:07:33 PM CST (in 9.993s)
+219ms ╚Event processed successfully (218ms)
1/23/2019, 9:06:48 PM +893ms
+1ms ╔Received event [Texas].time = 1548299205948 with a delay of 2945ms
+10576ms ║RunTime Analysis CS > 311ms > PS > 10223ms > PE > 41ms > CE
+10577ms ║Piston waited at a semaphore for 9935ms
+10579ms ║Runtime (40241 bytes) successfully initialized in 10223ms (v0.3.109.20181207) (10577ms)
+10580ms ║╔Execution stage started
+10581ms ║╚Execution stage complete. (1ms)
+10583ms ╚Event processed successfully (10583ms)
1/23/2019, 9:06:49 PM +41ms
+2ms ╔Received event [Living Room Motion].motion = active with a delay of 637ms
+122ms ║RunTime Analysis CS > 21ms > PS > 65ms > PE > 35ms > CE
+125ms ║Runtime (40170 bytes) successfully initialized in 65ms (v0.3.109.20181207) (121ms)
+126ms ║╔Execution stage started
+172ms ║║Comparison (time) 76009173 is_between (datetime) 1548287880000 … (time) 14400000 = true (10ms)
+174ms ║║Time restriction check passed
+177ms ║║Condition #9 evaluated true (44ms)
+178ms ║║Cancelling condition #1’s schedules…
+179ms ║║Condition group #1 evaluated true (state changed) (48ms)
+185ms ║║Comparison (enum) active changes_to (string) active = true (1ms)
+187ms ║║Cancelling condition #3’s schedules…
+188ms ║║Condition #3 evaluated true (7ms)
+189ms ║║Condition group #1 evaluated true (state did not change) (9ms)
+201ms ║║Comparison (enum) off is (string) off = true (2ms)
+203ms ║║Condition #23 evaluated true (11ms)
+205ms ║║Condition group #10 evaluated true (state did not change) (12ms)
+216ms ║║Comparison (enum) off is (string) off = true (2ms)
+218ms ║║Condition #11 evaluated true (11ms)
+219ms ║║Condition group #10 evaluated true (state did not change) (12ms)
+222ms ║║Cancelling statement #12’s schedules…
+301ms ║║Executed physical command [Living Room Sconces].setLevel([20]) (74ms)
+302ms ║║Executed [Living Room Sconces].setLevel (76ms)
+317ms ║║Comparison (enum) off is (string) off = true (2ms)
+319ms ║║Condition #16 evaluated true (13ms)
+320ms ║║Condition group #15 evaluated true (state did not change) (14ms)
+323ms ║║Cancelling statement #17’s schedules…
+354ms ║║Executed physical command [TV LED Lighting].on() (28ms)
+355ms ║║Executed [TV LED Lighting].on (30ms)
+366ms ║║Comparison (enum) active stays (string) inactive = false (2ms)
+368ms ║║Cancelling any timed trigger schedules for condition 25
+369ms ║║Cancelling statement #25’s schedules…
+371ms ║║Condition #25 evaluated false (11ms)
+372ms ║║Condition group #24 evaluated false (state did not change) (13ms)
+375ms ║╚Execution stage complete. (250ms)
+376ms ╚Event processed successfully (376ms)


#13

Until someone knows better comes along (i don’t know the ins & outs of webcore)
I can reccomend a couple of tests to see where the problem might be…

1 - get rid of the dimmer and just try it with RBG bulb, see if it’s still 5 sec or more
2 - IF test 1 is good, meaning you get 1 sec or so responce time, add the dimmer after RGB light (sounds meaningles BUT i have seen meaningles work sometimes in smarthomes:))))
3 - Create a simulated switch and test the RGB bulb by it self. (just to make sure that light does or doesn’t have signal issues.


#14

Not sure If I’m reading this correctly but looks like the command to turn off the RGB executes like 8 seconds after the dimmer? Correct?

+1ms ╔Received event [Texas].time = 1548301043081 with a delay of -882ms
+527ms ║RunTime Analysis CS > 63ms > PS > 412ms > PE > 53ms > CE
+530ms ║Runtime (40163 bytes) successfully initialized in 412ms (v0.3.109.20181207) (527ms)
+532ms ║╔Execution stage started
+544ms ║║Cancelling condition #1’s schedules…
+547ms ║║Cancelling condition #1’s schedules…
+579ms ║║Cancelling condition #25’s schedules…
+581ms ║║Condition #25 evaluated true (3ms)
+583ms ║║Cancelling condition #24’s schedules…
+584ms ║║Condition group #24 evaluated true (state changed) (7ms)
+588ms ║║Cancelling statement #26’s schedules…
+640ms ║║Executed physical command [Living Room Sconces].off() (46ms)
+642ms ║║Executed [Living Room Sconces].off (49ms)
+8379ms ║║Executed physical command [TV LED Lighting].off() (7733ms)
+8380ms ║║Executed [TV LED Lighting].off (7735ms)
+8384ms ║╚Execution stage complete. (7853ms)
+8386ms ╚Event processed successfully (8386ms)

Let me try what you said, but this was working fine using the SmartLighing automation from ST. both lights turned on and off at the same time. I’m moving it to WebCore because I needed to incorporate the logic for it to not change the lights if they are already on (some one turns them at 100%, they went back to 20% when someone moved.) and also I’ll be changing that switch for one that supports a way to tell if it was turned on manually so the piston won’t ru if someone turned it on manually.


#15

Oh by the way,
I hope you already stopped any ST (automation) regarding to this RGB


#16

yes, that I made sure I did yesterday


#17

I separated both turn off calls (instead of selecting both devices togheter) and that seems to be working


#18

Wonderful… I am glad it worked…
I have a feeling (as i said i don’t how Webcore works in the background) but maybe just maybe, the system is waiting until the dimmer is done and goes to RGB?
I always use different types in different orders even though they may have SWITCH OFF,


#19

Hopefully someone that knows more than us can take a look and see if there’s something in the logs that’ll tell us why it happened.

Thanks for your help


#20

I awarded the solution to your post. Altough @WCmore was 2 seconds faster I believe your answer is more complete and probably will help explain better for total newbie in the future. Altough I did understand WCmore’s answer right away.