Help creating piston to dim lights before turning off but go back to 100% if motion occurs


#1

Hi all,

Having trouble getting my head around the best way (if its possible) to set this up…

1) Give a description of the problem
Help creating piston to dim lights before turning off but go back to 100% if motion occurs.

2) What is the expected behavior?

With lights off: When motion changes to active, lights turn on to 100%, then dim to 5% after 2 minutes before turning off after 10 seconds. Lights to go back up to 100% if motion has been detected.

With lights already turned on when motion detected: When motion changes to inactive, dim lights to 5% after 30 minutes before turning off after 10 seconds. Lights to go back up to 100% if motion has been detected.

3) What is happening/not happening?

Unable to get lights to go back from 5% to 100% when motion detected.

4) Post a Green Snapshot of the pistonimage

Thanks :slight_smile:


#2

There’s quit a bit going on with this piston and I’m not sure your “waslighton” variable is doing you any favors… it may actually be making things more complicated for you.

Can you write out in plain English how you want these lights controlled by the motions sensor (including different actions at times, colors, etc.) and we’ll see if there’s a more straight-forward approach?


#3

Ok so… I want the lights to come on when I walk into the room. I then want them to dim to 5% after 2 minutes if no motion has been detected, this is to prompt me to move about a bit and get them to come back on before placing me into darkness (if I’m still there).

I also want them to do the same as above but stay on for longer if the lights were already on before I walked into to the room.

I had this setup without the dimming to 5% and it worked fine. When I added dimming the piston wouldn’t turn the lights back up to 100% when motion was detected due to the condition being to trigger only if the lights are off which they aren’t as they have only been dimmed.

My brain hurts trying to figure out how this might be possible.


#4

Sorry my screenshot shouldn’t have included the 2nd if statement as that isn’t going to work. This one kind of works but the lights don’t go back to 100 after dimming:


#5

Your first IF statement won’t allow the lights to go back to 100% because you have a line in there “AND any of bulbs X and Y are off”. If your lights are at 5%, both will be on and that condition will evaluate false.


#6

This is a slightly different approach using nested IF statements. More importantly it gets rid of the “if lights are off” conditional statement that prevents your lights from turning back up to 100% but keeps your ‘waslightsoff’ variable working the way you want it to.

I don’t have a motion sensor to select from my device list, so you have to change line 19 from $device to your motion sensor.


#7

Thats awesome thanks! Seems to be working well :grinning: