Automation for door open, lights on, but do not activate when im leaving the space

ive been trying to figure out how am I going to do an automation that the door sensor our motion sensor will activate the lights on my apartment when I arrive home. that part is straight forward… but what i dont want is to when im leaving the apartment and I open the door, the automation doesnt trigger… how do i find a solution for this? did anyone ever thought of this?

How can you tell ha you’re leaving? Probably depends on how you register presence. I would start with checking the device_tracker.[your_name_here] when arriving at front door. If state is away some time after arriving home, you can use this device_tracker in a condition for the automation. This can make sure the trigger only fires when the state of the device_tracker is not home.

1 Like

That a good idea. I could try that. But it wont work for guests or other members of the family. I am thinking on putting a motion sensor on the outside. This way it will only turn on if that motion is activated.
Thank you for the idea !

True, did miss that. Keep in mind that outside sensor will also detect movement when leaving, so condition should check for movement outside and no very recent movement inside :wink:.

I have a motion sensor on the inside. I live in an apartment building so I can’t really put anything outside. If the sensor has not detected movement when the door opens, then it is assumed, that someone is coming in. I don’t know how well this works if there’s a significant delay with the signals. I’m using Zigbee so everything is practically instant.

I found a Solution to this… and it was super Simple…

all i had to do is put a condition that the motion sensor on the inside if he detected montion 2 minutes prior to opening the door, then it would not trigger the automation :slight_smile:

alias: Door Open lights on 3drt TESTE
description: o detetector da sala esta a detectar movimento por 2 minutos
trigger:
  - type: opened
    platform: device
    device_id: 3c98316e1b18e49dc5b0841bd85c253f
    entity_id: binary_sensor.3drt_sensor_porta_access_control_window_door_is_open
    domain: binary_sensor
condition:
  - type: is_motion
    condition: device
    device_id: 766e9a4791c402b72ac13842897aab8e
    entity_id: binary_sensor.3drt_sensor_mov_sala_home_security_motion_detection
    domain: binary_sensor
    for:
      hours: 0
      minutes: 2
      seconds: 0
      milliseconds: 0
  - condition: time
    after: '17:00'
action:
  - type: turn_on
    device_id: 3fbea69e0c5e89ed49709db76471407c
    entity_id: switch.3drt_luzes_sala_principal
    domain: switch
  - type: turn_on
    device_id: 6a38b06b41e5be9adf400359aaa1fc54
    entity_id: switch.3drt_luzes_cozinha_grande
    domain: switch
  - device_id: e772c96042b9626d85031612ac482177
    domain: mobile_app
    type: notify
    message: entrei no 3drt
    title: 3drt
  - service: media_player.turn_on
    data:
      entity_id: media_player.lg_webos_smart_tv_3
      source: YouTube
    entity_id: media_player.lg_webos_smart_tv_3
  - type: turn_on
    device_id: 3fbea69e0c5e89ed49709db76471407c
    entity_id: switch.3drt_luzes_sala_secundario
    domain: switch
mode: single

What if you have a door handle on the inside that is causing the motion detector to see it move prior to opening the door (from the outside)? Will this still work then?

Trying to figure out how the “for” condition is working in this case? What does “for 2 minutes” exactly mean here?

Hello,
Now the Door sensors detect if you are leaving or entering. So that doesnt apply anymore.

I dont understand how this condition would stop the execution. Your condition is checking for movement the last 2 minutes on the inside. If movement is found the last 2 minutes, you asume that you are entering the appartment and execute the automation.
But shouldn’t you test for NO movement instead? Because in your example I see “is_motion”?