Philips Hue Motion Sensor automation with multiple actions

Hi,

I’m trying to setup automations for a hue bulb via a hue motion sensor trigger. Simple enough, but I want multiple actions for the off automation. Basically, looking to create:

  • Motion detected - light on 100%
  • No motion detected for 20 seconds - light to 25% brightness
  • Delay for another 20 seconds - light off

I created 2 automations for this. 1 for on and one for off. I used a scene to set the light to 25%. This works fine, until I trigger motion during the 20 second delay between the light being set to 25% brightness and the light turning off. In this scenario the following happens:

  • Motion detected - light on 100%
  • No motion detected for 20 seconds - light to 25% brightness
  • Motion detected again - light on 100%
  • Light off
  • Light back on at 25%
  • Light off

This seems to be happening because the first ‘off’ automation seems to keep running even though there is a new ‘on’ trigger. Is there a way to reset an automation based on a different automation being triggered?

here is my config:

id: '1619888212449'
alias: Philips Hue Top Landing Motion On
description: ''
trigger:
  - type: motion
    platform: device
    device_id: 4842773027a64a98ec72a5b08f634987
    entity_id: binary_sensor.top_landing_sensor_motion
    domain: binary_sensor
condition: []
action:
  - type: turn_on
    device_id: 2fc9d4475b599802f30ace553ccdf51c
    entity_id: light.top_landing
    domain: light
    flash: long
    brightness_pct: 100
mode: single
id: '1619888651865'
alias: Philips Hue Top Landing Motion Off
description: ''
trigger:
  - type: no_motion
    platform: device
    device_id: 4842773027a64a98ec72a5b08f634987
    entity_id: binary_sensor.top_landing_sensor_motion
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 20
      milliseconds: 0
condition: []
action:
  - scene: scene.dim_before_off
  - delay:
      hours: 0
      minutes: 0
      seconds: 20
      milliseconds: 0
  - type: turn_off
    device_id: 2fc9d4475b599802f30ace553ccdf51c
    entity_id: light.top_landing
    domain: light
mode: single

Won’t the Hue app do this? Why re-invent the wheel?

Try this:

id: 'phtlm'
alias: Philips Hue Top Landing Motion
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.top_landing_sensor_motion
    from: 'off'
    to: 'on'
  - platform: state
    entity_id: binary_sensor.top_landing_sensor_motion
    from: 'on'
    to: 'off'
    for: 20
  - platform: state
    entity_id: binary_sensor.top_landing_sensor_motion
    from: 'on'
    to: 'off'
    for: 40
condition: []
action:
  - choose:
      - conditions:
          - "{{ trigger.to_state.state == 'on' }}"
          - "{{ is_state('light.top_landing', 'off') }}"
        sequence:
          - service: light.turn_on
            target:
              entity_id: light.top_landing
            data:
              brightness_pct: 100
      - conditions:
          - "{{ trigger.to_state.state == 'off' }}"
          - "{{ trigger.for.seconds == 20 }}"
          - "{{ is_state('light.top_landing', 'on') }}"
        sequence:
          - service: light.turn_on
            target:
              entity_id: light.top_landing
            data:
              brightness_pct: 25
      - conditions:
          - "{{ trigger.to_state.state == 'off' }}"
          - "{{ trigger.for.seconds == 40 }}"
          - "{{ is_state('light.top_landing', 'on') }}"
        sequence:
          - service: light.turn_off
            target:
              entity_id: light.top_landing
mode: restart
3 Likes

Yes it will, but the hue app has other limitations which HA can overcome (like specifying differing ranges of time periods)

Thank you, that works perfectly!

1 Like

Hey, sorry for reopening this. I’m trying to do the same as OP, but when using @123’s example, the lights does not dim up to 100% when entering the motion sensor while the lights are at the 25% dimmed state. I’m not sure why, is that not why the entire automation is set as “Restart”?

I changed the first action to include an OR to look for the brightness at 25%. Seems to work, but I have no idea if it is the best/cleanest way to do it or if it will cause troubles in special scenarios…

action:
  - choose:
      - conditions:
          - condition: template
            value_template: '{{ trigger.to_state.state == ''on'' }}'
          - condition: or
            conditions:
              - condition: template
                value_template: '{{ is_state(''light.kitchen'', ''off'') }}'
              - condition: numeric_state
                entity_id: light.kitchen
                attribute: brightness
                below: '67'
                above: '62'
        sequence:
          - service: light.turn_on
            target:
              entity_id: light.kitchen
            data:
              brightness_pct: 100
1 Like

I tried above… could not get it to work for me.
All I want is simple If motion is detected : light on
If no motion for 20 sec : Light off.

Im using more simplified:

  • id: ‘1650294715289’
    alias: teknisen tilan liike
    description: ‘’
    trigger:
    • type: motion
      platform: device
      device_id: a1abd7dfed6b9169ddb1e9ea4700a152
      entity_id: binary_sensor.liiketunnistin_tekninen
      domain: binary_sensor
      action:
    • type: turn_on
      device_id: c556bed315caa485453f455d19b72576
      entity_id: switch.tekninen_tila
      domain: switch
    • wait_for_trigger:
      • platform: state
        entity_id: binary_sensor.liiketunnistin_tekninen
        to: ‘off’
        for:
        hours: 0
        minutes: 0
        seconds: 20
    • type: turn_off
      device_id: c556bed315caa485453f455d19b72576
      entity_id: switch.tekninen_tila
      domain: switch
      mode: restart

I cannot use HA automated “Motiondetection light” because device is switch.device_id NOT light.device.id.