Completely lost trying to get a light to turn off after 10 minutes based on motion

could do it in 1 automation. mode: restart would make it 10 mins after last motion detected; this is after 10 mins of initial motion detected.

- id: whateveryouwant
  alias: whateveryouwant
  mode: restart
  trigger:
  - platform: state
    entity_id: binary_sensor.samjin_motion_fad40c01_ias_zone
    from: 'off'
    to: 'on'
  condition:
  - condition: time
    after: '07:00'
    before: '19:00'  
  action:
  - service: light.turn_on
    entity_id: light.zen27_s2_dimmer_wall_switch_level_2
    data: 
      brightness_pct: 80
  - delay: 600
  - service: light.turn_off
    entity_id: light.zen27_s2_dimmer_wall_switch_level_2

Sacriledge, I know, but HA doesn’t have to do everything. Sounds as if you already have SmartThings - if that makes it “super easy”, why not let Smartthings do it? No need to re-invent the wheel.

I use two automation too for this purpose. The second stays on for 10 minutes AFTER the last movement. Well actually between 10 and 12 minutes since the sensor only updates every 2 minutes once motion is detected.

- id: '1582165998300'
  alias: Bathroom motion Detected
  description: ''
  trigger:
  - device_id: 15ae2a163ece41e6b3e51d159c0b83bb
    domain: binary_sensor
    entity_id: binary_sensor.motion_sensor
    platform: device
    type: motion
  condition: []
  action:
  - entity_id: light.bathroom_light_switch
    service: light.turn_on
- id: '1582166296047'
  alias: Bathroom Motion Not Detected
  description: ''
  trigger:
  - device_id: 15ae2a163ece41e6b3e51d159c0b83bb
    domain: binary_sensor
    entity_id: binary_sensor.motion_sensor
    for:
      hours: 0
      minutes: 10
      seconds: 0
    platform: device
    type: no_motion
  condition: []
  action:
  - entity_id: light.bathroom_light_switch
    service: light.turn_off

SmartThings is crap now. Left it behind.

This is a fairly basic thing that any automation system should be able to do though. If HA can’t do it properly, it should be pretty high on the “it should be implemented immediately” list.

Have none of the examples offered to you demonstrate that it can easily be achieved?

I’m actively getting to it right now. I’ll check back in a bit. So far, the first couple just error out.

We will need to know which example(s) you tried and what the errors say before we can determine the best way to fix the problem(s).

After messing with it, I have the second one working.

Now I am going to review some of the other things posted here. My intent is to have these lights trigger differently based on time of day.

OK I’m back at this.

Here’s what I want this automation to do:

  • Turn two lights on when motion is detected

  • Stay on while motion continues to be detected

  • Turn off after 5 minutes

  • Only trigger at certain times of the day

What it currently does:

  • Turns one light on when motion is detected
  • After the motion detector resets, it turns off even though I am waiving my hand infront of the detector
  • Once the detector triggers again, it turns on the OTHER light

Here is my current automation

alias: Lights On 
description: Turn on  ights to 80% during the daytime (7am-7pm)
trigger:
  - platform: device
    domain: binary_sensor
    entity_id: binary_sensor.samjin_motion_fad40c01_ias_zone
    device_id: 2675990a33b0745b10e7288e4ecb1be6
    type: motion
condition:
  - condition: time
    after: '07:00'
    before: '19:00'
action:
  - type: turn_on
    device_id: e741a53117757bda89df624de422b911
    entity_id: light.zen27_s2_dimmer_wall_switch_level_2
    domain: light
    brightness_pct: 80
  - delay: '20'
  - service: light.turn_off
    entity_id: light.zen27_s2_dimmer_wall_switch_level_2
  - type: turn_on
    device_id: 8bd3d79057c13ff80ba25bacd25fb336
    entity_id: light.zen27_s2_dimmer_wall_switch_level_6
    domain: light
    brightness_pct: 50
  - delay: '20'
  - service: light.turn_off
    entity_id: light.zen27_s2_dimmer_wall_switch_level_6
mode: parallel
max: 10

Personally I find it easier to separate the turn on and turn off functions into different automations. Sure you wont get any plaudits for elegant solutions but it’s easier to maintain and implement and can give you greater flexibility.

I wish that worked…here is my attempt to make that behave at a basic level and it fails.

alias: Test Office On
description: ''
trigger:
  - type: motion
    platform: device
    device_id: db12673d26ebb3845160a1463b163cc6
    entity_id: binary_sensor.samjin_motion_3aa50b01_ias_zone
    domain: binary_sensor
condition: []
action:
  - domain: light
    entity_id: light.office_fan
    device_id: d2da70e04e94b64ae2e6f4a1942f5345
    type: turn_on
mode: single

alias: Test Office Off after 2 min no motion
description: test
trigger:
  - device_id: db12673d26ebb3845160a1463b163cc6
    entity_id: binary_sensor.samjin_motion_3aa50b01_ias_zone
    domain: binary_sensor
    for:
      hours: 0
      minutes: 2
      seconds: 0
    platform: device
    type: no_motion
condition: []
action:
  - domain: light
    entity_id: light.office_fan
    device_id: d2da70e04e94b64ae2e6f4a1942f5345
    type: turn_off
mode: single

This correctly turns on the light with motion. Then it promptly turns the light off after 2 minutes even with motion. Sometimes, when the light is on and it re-detects motion, it decides to turn off the light.

All I want is a simple way to turn a light on with motion, leave it on until motion is NOT detected (with a pad added to that) and to stay on if motion is re-detected during the pad time. If it turns a light on with motion and then the motion goes away and comes back while the light it still on, I do not want it to turn off the light. I’ve never had such trouble with an automation system doing this simple thing.

Note that your setup references something called “service light.turn_on”. This gives an error on my HA.

There’s a blueprint to turn a light on from motion and turn it off after a period of no detection. If detection is picked up during the on period the timer off resets.

That leads to the next question…what is a blueprint? Is that something new?

You had me hopeful…but that doesn’t work either.

alias: Motion-activated Light
description: ''
use_blueprint:
  path: homeassistant/motion_light.yaml
  input:
    no_motion_wait: '120'
    motion_entity: binary_sensor.samjin_motion_3aa50b01_ias_zone
    light_target:
      area_id: a9db76df767cb39e2c7325cd041e0730
      entity_id: light.office_fan

This works fine as long as motion remains detected. Once motion drops and reappears in the 120 seconds, the light does not stay on, instead it immediately turns off…and from then on the automation works in reverse…

I might have figured out my issue…the state of the light is not reporting back to HA properly.

When I switch to a different light, the blueprint seems to do what I want.

Now to figure out how to take the blueprint and incorporate luminance and time of day conditions…

What I do is have one automation which is triggered from the motion sensor, this in turn starts a 5 min timer and turns on the lights. I then have a second automation that is triggered off of the expired timer to turn the lights off. This is flexible, there can be multiple ways to set the timer and when it goes off the lights will always be turned off. Just a suggestion…

The biggest issue I was having was testing with a light being controlled through a Bond Hub. There is obviously something not quite right with the Bond integration in relation to automation.

Understood. I tried a bunch of different ways to do the motion lights and the timer was by far the best solution for me. It put me in a better mindset with the event driven nature of HA. Best of luck!

Because I migrated everything from ST to HA, except the storage under the stairs. My ST hub exists only because a door switch and a lamp. I still have my ST hub connected because of this automation.
Child opens the door and triggers de door switch, turning the light on. Almost never closes the door, and the light stays on.
On ST there’s a condition to keep it on for maximum 10 minutes.

I’m happy I’m not the only in this boat.

Btw, is there already a simple solution for this?