Loop Motion Sensor Automation Help Needed!

Hi, There

I am a newbie. I have a hue motion sensor placed in the bathroom. I want an automation to run constantly in the background and check if there is motion in the bathroom or not. İf not it should turn bathroom lights off.

There is a trigger option “when motion sensor stopped detecting motion” but that only triggers after motion ends. I want an automation where it will only check for motion in the bathroom and turn off the lights if there is not any. And that motion should run constantly during the day.

İs this possible ? Any help is appreciated.

I already checked that and I have tons of automations working in my house. It is just the one I asked that I can’t find a solution.

Automations are reacting to triggers… So having an automation running “constantly” is not possible…
So what you have to create is an automation that switch off the light if the motion detector has not detected anything during a specific time…
Your automation will trigger “when motion sensor stopped detecting motion” for x minutes or seconds… So is in the same state for x minutes
You have to add as a parameter of the trigger: “for: ‘00:01:00’” In this example, if no motion is detected during 1 minute, than the automation will trigger and execute what you want…

I actually have 4 Hue sensors right now and every of them has the automation you specified. Light will turn off after x seconds or minutes. But that only works if hue detects motion.

For example lets say bathroom has not been used by anyone between 12:00 and 18:00. If you turn on the light at 13:00 the light of the bathroom will stay open until someone gets in because Hue sensor needs motion before activating no move automation.

You need to add a trigger for the length of time the light has been “on” with the condition that motion is “off”.

Here’s an example:

alias: Lights - Basement - Near - Motion Control
description: Control Basement Near lights with motion
trigger:
  - platform: state
    to: 'off'
    for: '00:10:00'
    id: No Motion
    entity_id: binary_sensor.basement_motion
  - platform: state
    to: 'on'
    for: '00:10:00'
    id: No Motion
    entity_id: light.basement_near_lights_zha
  - platform: state
    entity_id: binary_sensor.basement_motion
    id: Motion
    to: 'on'
condition:
  - condition: state
    entity_id: input_boolean.basement_allow_motion_detector
    state: 'on'
  - condition: state
    entity_id: input_boolean.guest_mode
    state: 'off'
action:
  - choose:
      - conditions:
          - condition: trigger
            id: No Motion
          - condition: state
            entity_id: light.basement_near_lights_zha
            state: 'on'
            for: '00:00:00'
          - condition: state
            entity_id: binary_sensor.basement_motion
            state: 'off'
            for: '00:05:00'
        sequence:
          - service: light.turn_off
            data:
              transition: 10
            target:
              entity_id: light.basement_near_lights_zha
      - conditions:
          - condition: trigger
            id: Motion
          - condition: state
            entity_id: light.basement_near_lights_zha
            state: 'off'
            for: '00:00:10'
        sequence:
          - service: light.turn_on
            target:
              entity_id: light.basement_near_lights_zha
            data:
              transition: 3
              brightness_pct: 100
    default: []
mode: single

Another idea for executing this approach: an automation to start a Timer every time the light turns on OR motion is detected and another automation to turn off the light when the timer ends. I think that covers every case with only three triggers and two actions.