Hello,
I have 2 separate timers, one for the actuall lights to turn off, and one that is 10 seconds shorter, which triggers lowering the brightness to 50%. The problem is, when there is movement again during those 10 seconds, the illuminance is checked again (which is of course higher now, because the lights are on). So the lights stay on, but at 50% until the timer is at 0 again.
Also, doesnt it work to have something like “time between sunset and 11pm”? Because it seems like it does not for me.
I’m not sure why you’d need to use 2 timers, I set my lights to come on based the motion sensor detection, which cycles them through some colours, before settling on a ‘final’ colour that I can set in a helper, I then use a wait _for_trigger to detect no motion, then turn the lights first to red, then to off.
I also trigger on illuminance changing, as I want the lights to come on if I’m already in there and the motion sensors have already detected me.
This sounds similar to what you are looking to do.
Critically, I use mode:restart to constantly refresh the motion sensor, but if the automation is triggered again because motion is detected at any time, it has an if condition to see if the lights are already on and therefore abort. This stops the initial colour cycling from repeating if the lights are already on, but constantly refreshes the wait on trigger timeout if someone is present in the room.
Just out of curiosity, why are your lights cycling colors?
I am still pretty new to all of this, especially in text form. Maybe I should have been clearer,
I want the lights to be on when there is motion. But if I happen to not move for a bit longer, it should only dim down before going off, so I know that I need to move to keep the lights on (like for example in the Philips Hue app).
I don’t see how that it in your blueprint, or maybe I just don’t understand it yet.
The code I posted before was shortened a bit, I have several options included depending on what time of day it is.
I only colour cycle the lights for a bit of theatre as I enter the room.
Now I understand your use case a little more, it should be pretty straightfoward
Start your automation to be triggered by your motion sensor.
Turn on your lights
Use a wait_for_trigger to wait for motion to stop being detected. You should set a minimum duration that no motion should be detected, as I have in my automation:
The script will now sit here indefinitely until 15 seconds of no motion is detected. You can add a timeout for this, but I dont think you need it in your use case.
Set lights to 50%
create another simple wait for (say) 10 seconds.
Turn off the lights
Set the script mode to restart (the default is single). This means every time motion is not detected then detected again, you’ll keep triggering the script again, which will sit in the first 15 second wait period.
I see you also have an illuminance check in there. When I use that with the script I posted, there is a problem. It ALWAYS checks illuminance, so when the light is about to turn off, I can’t move sometimes to turn it back on, because it’s now too bright for the automation to trigger again. What could be done about that?