Light inactive

Hi guys,

Hopefully someone can help me here. I’m trying to create an automation with a motion sensor and light where the following happens:

  • Light is turned on manually
  • If there is no motion for ~4-5 minutes the light dims to ~75%
  • if there is no motion for a minute the light goes off
    • otherwise (if there is motion) the light goes back to 100% and the process starts again.

I already have a similar basic automation created where the light just goes off after 5
minutes of inactivity between a certain time. Maybe this could be adjusted:

alias: Marcie inactivity
description: ''
trigger:
  - type: no_motion
    platform: device
    device_id: ea23b09e150e671b78495c84f674c988
    entity_id: binary_sensor.hue_motion_sensor_1_motion
    domain: binary_sensor
    for:
      hours: 0
      minutes: 5
      seconds: 0
      milliseconds: 0
condition:
  - condition: time
    before: '18:30'
    after: '07:00'
  - condition: and
    conditions:
      - condition: device
        type: is_on
        device_id: 75394c537946ef4ba42b9f3f866e1be2
        entity_id: light.marcie_s_roof_light
        domain: light
      - condition: or
        conditions:
          - condition: device
            type: is_on
            device_id: 6200bad2117ac0525b2ef93ba03bf655
            entity_id: light.marcie_s_light
            domain: light
action:
  - type: turn_off
    device_id: 6200bad2117ac0525b2ef93ba03bf655
    entity_id: light.marcie_s_light
    domain: light
  - type: turn_off
    device_id: af547b3ec0e559a2fa07d59d7c9dc351
    entity_id: light.marcie_s_roof_light_2
    domain: light
  - device_id: b2317d55b15e5cd057256d816f330cd7
    domain: mobile_app
    type: notify
    message: Marcie's Light turned off due to inactuvity
    title: 'Inactivity '
mode: single

Thanks!

So, for another minute (5-6 minutes in total)?

yes, so the person can see (by the light dimming) that they haven’t been detected as moving for the last 4-5 minutes and can then react (by moving).

A typical example, my wife reads to the kids in the evening and all of a sudden the light goes off because they are all sitting still.

Okay. I tend to use multiple automations, because it’s easier to debug and you can use the visual automation editor in the UI:

#1. automation, turn light on at 100% if there is motion (optionally: if lights are off or dimmed, but it doesn’t hurt to turn on-lights on again)
#2. automation to dim the lights, if it has been on for 5 minutes
#3. automation to turn off the lights, if they have been on for 6 minutes and are still dimmed.

1 Like

Thanks @m0wlheld, I was thinking multiple automations but wasn’t sure if that was the right way to go about it. I was thinking wait_for_trigger or something…

I’ll give it a shot with multiple automations and let you know if it worked. Thanks!

I got this working with 1 automation. Here it is if anyones interested:

alias: Marcie Light inactivity (interactive) final
description: ''
trigger:
  - type: no_motion
    platform: device
    device_id: ea23b09e150e671b78495c84f674c988
    entity_id: binary_sensor.hue_motion_sensor_1_motion
    domain: binary_sensor
    for:
      hours: 0
      minutes: 5
      seconds: 0
condition:
  - condition: device
    type: is_on
    device_id: 75394c537946ef4ba42b9f3f866e1be2
    entity_id: light.marcie_s_roof_light
    domain: light
action:
  - delay:
      hours: 0
      minutes: 0
      seconds: 11
      milliseconds: 0
  - repeat:
      until:
        - condition: or
          conditions:
            - condition: device
              type: is_off
              device_id: 75394c537946ef4ba42b9f3f866e1be2
              entity_id: light.marcie_s_roof_light
              domain: light
            - type: is_motion
              condition: device
              device_id: ea23b09e150e671b78495c84f674c988
              entity_id: binary_sensor.hue_motion_sensor_1_motion
              domain: binary_sensor
      sequence:
        - device_id: 75394c537946ef4ba42b9f3f866e1be2
          domain: light
          entity_id: light.marcie_s_roof_light
          type: brightness_decrease
        - delay:
            hours: 0
            minutes: 0
            seconds: 3
            milliseconds: 0
  - choose:
      - conditions:
          - condition: device
            type: is_on
            device_id: 75394c537946ef4ba42b9f3f866e1be2
            entity_id: light.marcie_s_roof_light
            domain: light
        sequence:
          - type: turn_on
            device_id: 75394c537946ef4ba42b9f3f866e1be2
            entity_id: light.marcie_s_roof_light
            domain: light
            brightness_pct: 100
    default: []
mode: single