#Motion Sensor + light switch

1 messages · Page 1 of 1 (latest)

slow acorn
#

Hey there,

I would need some advice about how to approach this scenerio. My son's bedroom currently has a dumb light connected to a smart switch. When it's time to go to bed, I did setup a basic "switch toggle off" at 8h30pm . However it is not very practical because my son's time to bed may vary.

I recently purchased some motion detectors ( Ikea Vallhorn) just to try it out and I was thinking about a way to trigger the light switch on/off between 8pm and 9pm. It seems to be a better idea but now I'm wondeering what about if the light is still on after 9pm ? that means the light will stay "on" for the whole night ? how can I approach this situation ?

Thanks!

fickle citrus
#

i tend to avoid using the motion detectors idea of "unoccupied" as that triggers if you are sitting still.

one idea is to have one automation that triggers on motion. set as a condition that time must be after 8. action would be to (re)start a countdown timer created as a helper. a second automation then triggers on the timer reaching 0 and turns the light off. set the timer to e.g. 10 minutes. maybe also a third automation that starts the timer at 8 just to catch the possibility of the light being on at 8 but nobody is moving.

i think this should be a user friendly way to do it. of course motion will not turn the light on with this scenario if it is off already. so moving around in bed will not turn the light on.

slow acorn
#

Yea I just figured the idea of "unoccupied" doesn't work at all . thanks for the advice I'll try that

#

So I have to create my countdown timer from a helper first ? and then use that timer for 2 automations, one triggering on motion after 8pm and restarting the timer and the other one triggered when timer reach 0 and turn the lights off ?

fickle citrus
#

yes. and in case the room is quiet at 8 and the lights are on add a trigger for 8 o clock to the first automation to start the countdown anyway

slow acorn
#

alright thanks !

fickle citrus
#

while you are at it add a trigger for ha starting as well for the first automation. in case ha is down at 8 and comes up afterwards.

that is the nice thing about using conditions correctly. you can have lots of triggers on the same automation. it will only run between 8 pm and whatever other time you decide anyway. like 6 am.

slow acorn
#

what do you mean by "add a trigger for ha starting as well for the first automation" , not sure to understand ?

#

Also when you say "automation that triggers on motion" , with Ikea Vallhorn I have only 3 entities available, "identity, illuminance and occupancy"

#

which one should I choose for the trigger ?

#

The occupancy right ?

tight sparrow
#

Honestly - much simpler to have 2 triggers:
State trigger: motion sensor from on to off for 5 minutes or whatever
Time trigger: 9pm or whatever backstop time you want to use
You can do whatever conditions you like around timing, but honestly I don't see why you'd ever not want the lights to turn off after no motion for 5 minutes.
Adding in an extra timer helper is unnecessary in 99% of cases - it only really has an advantage in the niche case your home assistant restarts during those 5 minutes and then it will trigger with a resumed countdown rather than starting again from 5 minutes

fickle citrus
#

there are so many different motion sensors with different ideas about how long to wait before being unoccupied. with the timer you are free from all that. you decide how long you should wait without occupance being signalled no matter which sensor you use. the ikea sensor is one i have not tried yet, but working with various tuya/sonoff/aqara ones i just chose what gives me the control

fickle citrus
# slow acorn Also when you say "automation that triggers on motion" , with Ikea Vallhorn I ha...

there is a separate trigger that fires whenever home assistant starts up.

as long as your automations have conditions that keep them from running when they should not then adding this trigger can help your home "self heal" after a restart or downtime on your ha server.

using that trigger on your first automation would make it trigger when there is movement, when it is 8 pm or when ha restarts. setting 8pm to 6am as condition would mean restart or movement cause no action during daytime.

tight sparrow
# fickle citrus there are so many different motion sensors with different ideas about how long t...

Not really, they pretty much all live in the fraction of a second to 15s range, which especially when you're talking 5-10 minutes of "on" time is pretty negligible
If you use z2m or zha you can also generally update that value to whatever you want.
With the timer you are increasing the effort to set everything up, adding another variable you need to tune, another automation you need to run for every motion sensor etc
If you really want to tweak things with an intermediate helper that much, just set a template binary sensor to turn on with the motion sensor and give it an auto_off of X seconds. Not only does this make it significantly simpler (no extra automation) but it can also be blueprinted and duplicated for all your sensors very easily.