Automation - turn off entity with no motion and no original motion trigger

Hello

I tried searching for a solution not sure I got the correct terminology to find what I need. Apologies if this has been discussed.

Scenario: A light is turned on in a room by some method, automation, physical or “digital” switch, but no one is in the room.

Desired Result: Turn off the light if there is no motion/presence in that room, it can be after a determined amount of time (one minute).

Example: A light was turned on by accident via a dashboard or voice command, but the room/area has no one in it. There was no trigger for motion, so how do I turn the light off with no motion is detected when there was no original motion is detected? The basic method of “stopped detecting motion” will not work because the area may not have detected motion for hours or days, yet the light was still turned on and there is no motion or presence detected in the room.

There are probably better ways (maybe others can share), but here is something simple from me …
Use trigger to be the light going to on state (for 2 min lets say) and then check condition for motion (if there is no active motion) (or combine with helpers, timers, previous runs of automations etc. - depending how complex you want to get) action would be to turn the light off.
Hope this helps you.

yes. but don’t check one then the other. Put the condition together. Trigger on both events.

Here’s a verbose version. it could possibly be combined via a template, but I’m leaving it verbose for easier to learn and also so that op could see how it can be build 100% via ui:

trigger:
  - platform: state
    entity_id:
      - light.entry_cans
    for:
      minutes: 2
    to: "on"
  - platform: state
    entity_id:
      - binary_sensor.am_front_motion_detected
    for:
      minutes: 2
    to: "off"
condition:
  - condition: and
    conditions:
      - condition: state
        entity_id: light.entry_cans
        state: "on"
        for:
          minutes: 2
      - condition: state
        for:
          minutes: 2
        entity_id: binary_sensor.am_front_motion_detected
        state: "off"
action:
  - service: light.turn_off
    target:
      entity_id: light.entry_cans

1 Like

Thank you., this looks like what I need. I’ll try it out.

[Edit] This worked flawlessly. Thank you again!

1 Like