Continues Motion Automation

Hi,
I am trying to build an automation for one of the room that have quick motion in/out and I am trying to ensure that there is someone in the room for x min/sec to trigger the automation. triggering based on state on is working great but I do not want to turn everything on if someone just entered and exit the room.
my current config is as following:

Thanks in Advance.
PS: I have searched for a solution for sometime but cannot find it.

- id: turnonglassled
  alias: "Turn on Dining Room when there is movement"
  trigger:
  - entity_id: binary_sensor.glass_room_motion
    platform: state
    to: 'on'
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: switch.glassroom_ac_control
        state: 'off'
      - condition: template
        value_template: '{{ states.sensor.zooz_zse40_4in1_sensor_temperature.state | float > 24 }}'
  action:
    - service: homeassistant.turn_on
      data_template:
        entity_id: >
          {% if is_state('switch.glassroom_ac_control', 'off') and (states.sun.sun.attributes.elevation < 4) %}
            group.glassroom_auto
          {% elif is_state('switch.glassroom_ac_control', 'off') and (states.sun.sun.attributes.elevation > 4) %}
            switch.glassroom_ac_control
          {% endif %}

In your trigger section you can add…

β€˜β€™β€™β€™
for:
minutes: 3
β€˜β€™β€™β€™

Just remember, many motion sensors have a minimum time before they trigger off. Set your value to something less than this and the lights will still turn on, just… Delayed.

You could look at using a timer to do this. Maybe motion detector β€œon” is an automation that starts a timer, a motion detector β€œoff” automation cancels that timer, and a timer finish automation performs the things you want to happen.

@swiftlyfalling I tried that but if I put that it will not run.

This would be a lot considering that this is the same for several others which make it complicated.

I think I got it to work using:

- id: turnonliving
  alias: Turn on Living room when there is movement
  trigger:
  - entity_id: binary_sensor.down_living_room_motion
    platform: state
    from: 'off'
    to: 'on'
    for:
      hours: 00
      minutes: 00
      seconds: 30
1 Like