Motion sensor to turn light on, then turn light off when detecting motion again

I need help with the best way to create this automation in HA. I’d like to use a motion sensor at the side of my bed (near the floor) to turn bedroom lamps on low when I get out of bed in the night to use the bathroom. I’d also like to use that same sensor to turn the lamps off when it senses that I’m getting back in bed. I’d like to create a min 15 second waiting period between both actions so the “off” trigger doesn’t happen right after turning on. Any ideas?

This is not an answer to your question but I found a much easier way to do this. I have cheapie night lights that have a motion sensor built in such that they only light up when motion is sensed and it is already dark (then go off after olne minute of no motion). When anyone walks by it lights up the floor (not the whole room) so we can see where we are walking as we walk by, whether coming or going. Easy peasy!

(P.S. I did cover up part of the PIR sensopr on them so that they only detect motion near the floor, so that turning over in bed doesn’t make them light up for example).

Thank you for your suggestion! Yes, it sounds like you’ve had some of the same challenges that I’ve had with the plug-in motion lights. Our dog sets it off, rolling over in bed does as well. Our issue is not tripping over the dog, which moves around during the night. I’d have to have multiple lights to cover the trip there and then the trip back. And i don’t have an accessible receptacle for the return trip. I should be able to find good locations for smart sensors that will resolve those problems.

1 Like

Could you use toggle rather than turn on/off?

But it sounds as if your trigger is getting in/out of bed, rather than movement. Have a look at a bed occupancy sensor:

That bed sensor is a great option and the price seems reasonable. I’ll likely check that out if i can’t figure it out otherwise. I’ll take a look at the toggle option to see if that works. I appreciate your help with this!

The bed sensor would be the best solution however until you get that set up you can use an automation like this:

triggers: 
  - trigger: state
    entity_id: binary_sensor.bedside_motion
    to: 'on'
conditions:
  - condition: template
    value_template: "{{ now() - this.attributes.last_triggered|default(as_datetime(0),1) > timedelta(seconds=15) }}"
actions:
  - action: light.toggle
    target:
      entity_id: 
        - light.bedroom_lamp_left
        - light.bedroom_lamp_right

Thank you, Tom! I’ll give that one a try.