Time & Motion piston


#1

1) Give a description of the problem
You will see from the build i have tried several versions of this and i cant seem to get it to work…so i have come to the guru’s to try and seek some help please.

I have a fibaro 2 set as a non-dimmer an two RGB bulbs.
I want these to come on at 45mins to sunset and technically off at 9pm; unless…
there is movement between 9pm and midnight - in which case i want the fibaro 2 to turn on and the two RGB bulbs to come on at a dim level of 50% and then for these 3 lights to all turn off if there is no movement within 15mins, if there is movement, then reset the timer again until there is no movement for 15mins.

2) What is the expected behavior?
as above

3) What is happening/not happening?
All lights turn on as scheduled, but never seem to turn off unless after 9pm and the motion is activated, then the two RGB lights dim, but again, nothing ever seems to turn off.

4) Post a Green Snapshot of the pistonimage


#2

I have a piston similar to this. Here’s a screenshot of it. It works for me. Try this.


#3

@Eric182 - Can you explain the use/purpose of the Refresh command?


#4

It is probably overkill and not needed but sometimes when a lightbulb is turned on, the smartthings app does not show it as being on right away. It’s status isn’t refreshed. So this just pings the light to see whether it’s on or off so that it is displayed correctly in the Smartthings app


#5

Here’s an example I knocked up to your exact requirements… tested and working :smile:


#6

Thanks all.
I used the one very kindly done by @Robin as he kindly replicated my original attempt.
Tried and tested :laughing: so now very happy thank you.

Now that i have seen a correct version i can see where i went wrong.

One question though…the lights wont come back on again once the movement sensor stays inactive, so if i want the lights to come back on again if motion is sensed and to then start the 15min wait again, would i on line 38 under the IF - change tcp to never cancel tasks?

Also, as the trigger uses a timer i haven’t used in any other pistons i have created, i cant figure out to change the default every day turn on before sunrise so it also only happens when location mode is home…normally there is this option to only run when mode is X but as its a timer i cant see this as an option and as there is no IF at the start i cant add to it there?

Thanks


#7

I’ve added the location mode condition below each timer… also tweaked the restrictions around the motion so motion only effects the lights after 9pm and therefore you don’t need them to come back on unless there is new motion.


#8

and here is an alternative method (bit cleaner) for putting a mode restriction on an action:


#9

Thank you again @Robin

The first one i can get my head around and see the logic in how it runs. The second one does look cleaner it just confuses me.
I can see getting to grips with webcore is going to be fun! I have seen some other pistons you have helped people with and they are very complex…i dont know how you do it…must be magic :grinning:

One thing i didnt realise and i dont think a lot of people do is that you could use the set level to 100% as a trigger by itself to turn on without actually having a seperate turn on trigger within the piston before the set level trigger


#10

I have tried both pistons over the last couple of days and they turn the lights on and off based on time, but they do not turn themselves on again with motion after 9pm.

I.e I can be in the room at 9pm moving around and the lights still turn off at 9pm or I can back into the room after 9pm and the lights are off and they do not turn on with motion.

Do I need to play around with the task execution?

Thanks


#11

It seemed to work for me in testing (rigging the times)… I’ll have another tinker later but all looks good to me???


#12

I had a bit of a tweak to your first piston as well as the Fibaro wasn’t turning on with the set level command so included it in another statement.
With that change the lights stayed on past 9pm based on motion but now they won’t turn off.

Logs
04/12/2017, 20:59:59 +88ms
+1ms ╔Received event [Home].time = 1512421200000 with a delay of -912ms
+94ms ║RunTime Analysis CS > 24ms > PS > 43ms > PE > 27ms > CE
+106ms ║Runtime (41387 bytes) successfully initialized in 43ms (v0.2.0ff.20171129) (103ms)
+107ms ║╔Execution stage started
+140ms ║║Comparison (string) :eba3c93fc70a56007cf247fea5d8b766: is (string) :eba3c93fc70a56007cf247fea5d8b766: = true (1ms)
+141ms ║║Condition #26 evaluated true (5ms)
+142ms ║║Condition group #25 evaluated true (state did not change) (7ms)
+153ms ║║Comparison (enum) active is (string) inactive = false (1ms)
+154ms ║║Cancelling condition #21’s schedules…
+155ms ║║Condition #21 evaluated false (10ms)
+156ms ║║Cancelling condition #20’s schedules…
+157ms ║║Condition group #20 evaluated false (state changed) (13ms)
+163ms ║╚Execution stage complete. (56ms)
+165ms ║Setting up scheduled job for Tue, Dec 5 2017 @ 2:54:00 PM GMT (in 64440.748s), with 1 more job pending
+415ms ╚Event processed successfully (415ms)


#13

Acording to the logs your motion sensor was reporting active at 9pm so the turn off command was prevented by line 40.

I can see the issue now, you are not subscribed to the motion events on line 49… click on the IF, click on the cog, and change subscription to ‘always’ instead of ‘automatic’


#14

Ok thanks.

I have just tried that. It seems to have triggered when i tested it as the lights did dim but if motion is sensed it will alternate between starting the 15min countdown timer and if motion is then sensed again it will reset the pistion for tomorrow ar 1hr before sunset and then if motion is triggered again it goes back to the 15 min countdown and continues this loop each time motion is sensed.

04/12/2017, 22:16:50 +975ms
+1ms ╔Received event [Front Room Motion Sensor].motion = active with a delay of 80ms
+126ms ║RunTime Analysis CS > 14ms > PS > 40ms > PE > 73ms > CE
+138ms ║Runtime (41400 bytes) successfully initialized in 40ms (v0.2.0ff.20171129) (137ms)
+139ms ║╔Execution stage started
+150ms ║║Comparison (enum) active is (string) active = true (1ms)
+152ms ║║Cancelling condition #16’s schedules…
+152ms ║║Condition #16 evaluated true (5ms)
+153ms ║║Cancelling condition #8’s schedules…
+154ms ║║Condition group #8 evaluated true (state changed) (7ms)
+191ms ║║Comparison (time) 80211131 is_between (time) 75600000 … (time) 1512373440000 = true (6ms)
+192ms ║║Time restriction check passed
+193ms ║║Condition #27 evaluated true (37ms)
+194ms ║║Condition group #12 evaluated true (state did not change) (39ms)
+195ms ║║Cancelling statement #12’s schedules…
+201ms ║║Skipped execution of physical command [Front Room Alcove Lights].on([]) because it would make no change to the device. (3ms)
+202ms ║║Executed [Front Room Alcove Lights].on (4ms)
+204ms ║║Cancelling statement #14’s schedules…
+213ms ║║Skipped execution of physical command [Front Room Wall Light 1].setLevel([50]) because it would make no change to the device. (4ms)
+213ms ║║Executed [Front Room Wall Light 1].setLevel (6ms)
+221ms ║║Skipped execution of physical command [Front Room Wall Light 2].setLevel([50]) because it would make no change to the device. (5ms)
+221ms ║║Executed [Front Room Wall Light 2].setLevel (6ms)
+225ms ║╚Execution stage complete. (86ms)
+226ms ║Setting up scheduled job for Tue, Dec 5 2017 @ 2:54:00 PM GMT (in 59828.799s), with 1 more job pending
+242ms ╚Event processed successfully (242ms)
04/12/2017, 22:14:08 +191ms
+1ms ╔Received event [Front Room Motion Sensor].motion = inactive with a delay of 153ms
+131ms ║RunTime Analysis CS > 16ms > PS > 40ms > PE > 76ms > CE
+142ms ║Runtime (41396 bytes) successfully initialized in 40ms (v0.2.0ff.20171129) (139ms)
+142ms ║╔Execution stage started
+154ms ║║Comparison (enum) inactive is (string) active = false (2ms)
+155ms ║║Cancelling condition #16’s schedules…
+156ms ║║Condition #16 evaluated false (6ms)
+156ms ║║Cancelling condition #8’s schedules…
+157ms ║║Condition group #8 evaluated false (state changed) (7ms)
+195ms ║║Comparison (time) 80048350 is_between (time) 75600000 … (time) 1512373440000 = true (6ms)
+196ms ║║Time restriction check passed
+197ms ║║Condition #22 evaluated true (38ms)
+198ms ║║Condition group #9 evaluated true (state did not change) (39ms)
+199ms ║║Cancelling statement #9’s schedules…
+204ms ║║Executed virtual command [Front Room Wall Light 1, Front Room Wall Light 2, Front Room Alcove Lights].wait (0ms)
+204ms ║║Requesting a wake up for Mon, Dec 4 2017 @ 10:29:08 PM GMT (in 900.0s)
+210ms ║╚Execution stage complete. (67ms)
+211ms ║Setting up scheduled job for Mon, Dec 4 2017 @ 10:29:08 PM GMT (in 899.994s), with 2 more jobs pending
+228ms ╚Event processed successfully (228ms)
04/12/2017, 22:13:24 +45ms
+1ms ╔Received event [Front Room Motion Sensor].motion = active with a delay of 89ms
+160ms ║RunTime Analysis CS > 30ms > PS > 41ms > PE > 88ms > CE
+171ms ║Runtime (41400 bytes) successfully initialized in 41ms (v0.2.0ff.20171129) (169ms)
+172ms ║╔Execution stage started
+186ms ║║Comparison (enum) active is (string) active = true (2ms)
+188ms ║║Cancelling condition #16’s schedules…
+189ms ║║Condition #16 evaluated true (7ms)
+190ms ║║Cancelling condition #8’s schedules…
+190ms ║║Condition group #8 evaluated true (state changed) (9ms)
+231ms ║║Comparison (time) 80004238 is_between (time) 75600000 … (time) 1512373440000 = true (6ms)
+232ms ║║Time restriction check passed
+233ms ║║Condition #27 evaluated true (41ms)
+234ms ║║Condition group #12 evaluated true (state did not change) (42ms)
+235ms ║║Cancelling statement #12’s schedules…
+241ms ║║Skipped execution of physical command [Front Room Alcove Lights].on([]) because it would make no change to the device. (2ms)
+241ms ║║Executed [Front Room Alcove Lights].on (4ms)
+244ms ║║Cancelling statement #14’s schedules…
+253ms ║║Skipped execution of physical command [Front Room Wall Light 1].setLevel([50]) because it would make no change to the device. (4ms)
+253ms ║║Executed [Front Room Wall Light 1].setLevel (6ms)
+260ms ║║Skipped execution of physical command [Front Room Wall Light 2].setLevel([50]) because it would make no change to the device. (5ms)
+261ms ║║Executed [Front Room Wall Light 2].setLevel (6ms)
+265ms ║╚Execution stage complete. (93ms)
+267ms ║Setting up scheduled job for Tue, Dec 5 2017 @ 2:54:00 PM GMT (in 60035.689s), with 1 more job pending
+321ms ╚Event processed successfully (321ms)


#15

that’a how it’s meant to work… lights will turn off after 15 minutes of activity, the 15 minute countdown resets every time there is motion.

It schedules for 60 minutes before sunrise as that’s what it’s supposed to do. Motion turns active, lights turn on and the next known event is 1h to sun. The fact that motion will likely go inactive shortly after is irrelevant, that’s not a known event until it happens.