Dusk to dawn dimmer with motion


I can’t seem to figure out how to do this in one single piston.

I have a light I want to turn on at sunset, dimmer 5%.
Set brightness 100% during motion, back to 5% after motion ends.
Turn off at sunrise.

Anyone have a similar setup they can share with me?

Here’s what I came up with, but I’m skeptical this is the right way, or if it will even work.


I was thinking something like this… I didn’t test it.


Thanks. Testing yours out now. Mine worked up until 5 minutes after motion stopped and it never dimmed again.

I’m thinking it’s an issue with subscribing to the wrong event in mine (watching for the motion to go inactive and stay inactive for xx)

I’m assuming your way if the motion is retriggered during the “wait 5 minutes”, it restarts that if section for another 5 minutes?


No dice. Same thing with the above piston. Motion turns the brightness up, but then never re-dims it.

For the test I changed the 5 minutes to 10 seconds and turned logging on. I see where it sets a wakeup event for 10000ms but never does anything after that time hits.

+163ms ║║Executed physical command [House Garage Flood].setLevel(99) (15ms)
+165ms ║║Executed [House Garage Flood].setLevel (17ms)
+170ms ║║Executed virtual command [House Garage Flood].wait (0ms)
+172ms ║║Requesting a wake up for Sun, Oct 24 2021 @ 7:51:31 PM EDT (in 10000ms)


Yes, timers cancel when there’s an event subscribed to.


Okay. I went back to my original piston and changed the if on line 48 from 100 to 99 since the dimmer in hubitat never actually goes to 100.

Seems to be behaving as expected. Just have to see if it turns off at sunrise, and back on at sunset tonight. :slight_smile:


My only observation is the following…


I have learned from an old friend that using


may work better because of the transition from one day to the next at midnight. I’m not sure that it makes ANY difference. But I do understand the logic for NOT BETWEEN.
Just my 0.02 cents.


I can see the logic behind that. I have a couple other pistons that I use for outside lighting that occasionally would leave a light on after sunrise if the motion was triggered right before and sunrise happened during the 5 minute period.

My fix there was just to add another if, happens daily, turn lights off at sunrise.

I’ll give that a spin and see.


It shouldn’t really make any difference for the simple reason that webCoRE already does exactly the same thing itself. However it isn’t going to do any harm and if people feel more confident in it, then why not?


So this piston seems to be working well as it sits. Here’s the latest version I’m using if anyone else wants it.

I’m using 99% for the bright setting because in Hubitat, even commanding 100 results in 99. 1% for the dim is because even at 1% the led bulbs I’m using still give off enough light for my cameras to see in color.

Thanks for the help everyone!