Dim Lights after No Motion then Off


#1

1) Give a description of the problem
I’m attempting to dim my lights by 50% for 5 minutes if there’s been no motion in the room for 45 minutes. If there’s motion within those five minutes, I want to restore the lights to their original value. If there is no motion, I want the lights to return back to their original state and then turn off.

2) What is the expected behavior?
Light dims for 5 minutes before turning off/restoring to original brightness, dependent on motion.

3) What is happening/not happening?
Light dims appropriately after 45 minutes of no motion, but does not wait 5 minutes before turning off completely. Instead, it immediately turns off. What might I be doing wrong?

**4) Post a Green Snapshot of the piston


#2

Hmm, to me it looks like it satisfied the inactivity period you wanted and then proceeds going down the piston. Since timerON is already true from line 29, the piston hits line 34 which is true, then proceeds down the to 37 where it looks for the 5 minute inactivity… this one is still true because it was inactive for 45 minutes already from earlier… so it proceeds to turn off the dimmer.


#3

Hmm…what’s the difference between the WERE condition and the STAYS trigger? I thought the condition was based on the past while the trigger is based on the moment the trigger is activated on.


#4

Not sure I’m understanding the question, sorry. I did modify your piston earlier and ended up with the one below.

You’ll need to adjust the times (as usual).


#5

I mean, when creating a piston - why does the “STAYS” trigger not start a timer from the moment it was triggered? In my piston above, I would think that line 37 would only start counting down 5 minutes once the parent condition on line 34 (timeron = true) is met.

Either way, thank you so much for your piston. One thing I’m not understanding - once timeron turns to true (line 33, after the 45 minute wait), this is supposed to start the 5 minute countdown. During that 5-min period, if there’s movement, I want the lights to restore by +50% and restart the 45 min countdown - but I don’t see anything that resets the timeron variable to false if movement happens between line 33 and line 35. Can you please clarify what’s happening there?


#6

One more question - is it sane to attempt to do this with multiple dimmers in the same room, like this?


#7

The Stays trigger does start a timer but I don’t think it shows on the piston dash even when trace is on. If line 24 becomes true it is the same for line 37, it’s not going to change the inactive time unless there’s another motion event.

So let’s see if did this correctly. On line 33, timerOn becomes true, we wait 5 minutes since motion is still inactive. If motion becomes active, the condition becomes false, so the Else kicks in, bumps it up 50%, waits another 5 minutes, then turns off. If motion becomes active again within the 5 minute wait, timerOn is still true, condition is still false, so the timer resets and counts another 5 minutes.

Damn, I hope I got that right haha.


#8

Will the dimmers be always on at the same time or would there be times that one is off and one is on? If they’re always in synch as far as the switch and level, it’s probably ok to apply the same piston logic to both but if they can be independent of each other then it might need a little more tweaking.


#9

There’s high possibility that one switch might be off while the other is on and vice versa though I can’t think of what would need to be done, though I’m imaging it requires a “for each” loop of some sort? It’s probably easier to just copy your piston a second time and just select a different device though.

One thing I wonder how change: when you say “If motion becomes active, the condition becomes false, so the Else kicks in, bumps it up 50%, waits another 5 minutes, then turns off.” If motion becomes active during at anytime during the 45 minute period, or the 5 minute period - I want it to reset and restart the 45 minute timer (not the 5 minute timer). Does changing Line 44 to 45 minutes accomplish that?


#10

Ok looks like this one isn’t working. When the Dimmer 1 is turned off, it’s turning the light ON when there is motion detected.

Looks like line 44 is kicking off because Dimmer 1’s switch is OFF (line 24 is not true). I also notice that the Dimmer light’s “recent activity” tab in ST now gets a new line every time motion turns on/off - making that data really noisy. Any ideas if there’s a way to decrease the noise and fix this?

6/13/2018, 9:53:50 AM +734ms
+1ms ╔Received event [Motion - Fam Room / Kitchen].motion = active with a delay of 73ms
+254ms ║RunTime Analysis CS > 13ms > PS > 41ms > PE > 199ms > CE
+256ms ║Runtime (41233 bytes) successfully initialized in 41ms (v0.3.104.20180323) (254ms)
+257ms ║╔Execution stage started
+266ms ║║Comparison (enum) active changes_to (string) inactive = false (1ms)
+267ms ║║Cancelling condition #7’s schedules…
+268ms ║║Condition #7 evaluated false (6ms)
+269ms ║║Cancelling condition #1’s schedules…
+270ms ║║Condition group #1 evaluated false (state changed) (7ms)
+272ms ║║Cancelling statement #19’s schedules…
+339ms ║║Executed physical command [Kitchen Table].setLevel([51]) (60ms)
+340ms ║║Executed virtual command [Kitchen Table].adjustLevel (64ms)
+343ms ║║Executed virtual command [Kitchen Table].wait (1ms)
+344ms ║║Requesting a wake up for Wed, Jun 13 2018 @ 9:58:51 AM EDT (in 300.0s)
+349ms ║╚Execution stage complete. (92ms)
+351ms ║Setting up scheduled job for Wed, Jun 13 2018 @ 9:58:51 AM EDT (in 299.995s)
+374ms ╚Event processed successfully (373ms)


#11

Ah, good catch, I did not anticipate that part… I edited the Else to include a check for the switch being on.

I just saw your previous post also about the timer resetting to 45 mins, I need to look at it closer.

image


#12

I made another change to the piston so that it resets to 45 minutes when motion becomes active again. I also moved the device selection and time delay settings under the variables so it only needs to be changed in one location once when editing the piston.

I added some checks in the piston also like in line 35 to make sure that the level adjustments doesn’t get sent if the light has been turned off manually.


#13

Hi there - sorry about the delay on my part. The last piston is writing events to the dimmerSwitch object “recent” tab every single time motion stops (which can happen multiple times per minute). Is there anyway to prevent that? Can I do something about that? Maybe a line 27 can actually be a parent “if” statement of everything.


#14

I’m not sure we can do something about that since those are actual device events, you’d probably see it in the IDE logs also if even we don’t have a piston using it.


#15

You would need to edit the device handler to stop those notifications.