Hey guys, I’ve been struggling with an automation and have not been able to figure this out or find a good example. What I want is to: On motion, wait 2 minutes, then turn on a light, keep the light on while there is motion and another minute after the last motion, then turn it off.
As you can see in my code below, I made it work for the part where the light comes on right away and stays on 1 minute after the last motion. But I’m not sure how to make it wait the initial 2 minutes. I’ve considered inserting a second timer for the delay which comes on with motion as well, but I would need some boolean variable to only make it run the first time it sense motion, or maybe a counter, either inserted as part of an if/then block…but I’m not sure how to make that work. Any ideas? Thank you so much!
Thank you for walking through this with me, @123. Here’s the exact use case, I was trying to avoid the details
This is for a small toilet room part of a larger bathroom. If a person walks in there for #1 and they’re in and out in 2 minutes, don’t turn on the fan, no need. But if they go in and start playing Candy Crush in anticipation of #2 (so they’re still in the bathroom generating some motion), turn on the fan after 2 minutes and leave it run for 5 minutes after the last time motion is triggered. I have set the sensor timeout to 30 seconds and sensitivity high so if you’re in there on your phone or reading a book, it will pick you up.
This is really what I’m working through. The part that I’m struggling with is that initial delay. Does this make more sense now? I know that it’d be easier to just turn on the fan right away on motion, it’s how it works now…but let’s just say that I received some push back.
It all depends on your motion detector’s ability to detect their presence, even when they’re virtually motionless.
For example, if their activity causes your motion detector to report motion for several seconds, followed by no-motion, followed by motion, etc, all within that 2 minute window, it voids the use of a State Trigger with a for option. Every time the motion detector reports off it serves to reset the for option’s countdown.
You would have to be using mmWave for this to work, and it seems unlikely you have a powerpoint in a useful spot for it.
As Taras says, you come into the room and it triggers motion. Then you either leave 30 seconds later triggering no-motion after the cooldown period; or you sit down which also triggers no-motion after the cooldown period. Either way, after 2 minutes there’s never going to be motion (except the one going down the toilet ).
And while the cooldown for my Hue motion sensor is 10 seconds, for my Aqara sensors it is 2 minutes (although I think this can be adjusted at the expense of battery life).
You may be able to achieve what you want by combining with a door sensor. Door open then motion then door closed is somebody coming in; whereas motion then door open is somebody leaving. If somebody came in 2 minutes ago and haven’t left, then start the fan. Unless you like to do #2 with the door open
I actually started looking into some TVOC sensors for this purpose but they don’t seem to be sensitive enough. It would have made things so much simpler. Maybe a seat pressure sensor if I can find a compact one.