Automation Help: Turn on Light with Button press, but don't turn off with automation for no motion

Hey all,

So I have an automation set up that will turn on my lights with a Phillips Hue motion sensor, and also turn them off when there is no motion detected for 5 minutes. This is working great and is really useful, however, I want to add another layer of complexity.

I’ve got another automation that will turn on the lights with a button press of an Aqara button, however, the lights will still turn off with no motion being detected. This is ran as 3 separate automation (1 for motion turn on, 1 for motion turn off, 1 for turn on with button).

What I’m looking to do is create a statement of some kind which is something to the effect of “if x light is turned on with button press, turn off lights after 1 hour of no motion instead of 5 minutes, or with toggle press of button” and I’m not sure how to achieve this.

I’ve read some people use input booleans but I wanted to get some more specific advice.

Below are my automations that I have currently.

Button Press;

alias: Button - Toggle Landing Light
description: ""
trigger:
  - platform: device
    domain: mqtt
    device_id: c0b83b571d9a64ec8b7cd5c56dba4887
    type: action
    subtype: single
    discovery_id: 0x00158d000705142c action_single
condition: []
action:
  - service: light.toggle
    data:
      rgb_color:
        - 255
        - 217
        - 120
      brightness_pct: 90
      transition: 1
    target:
      entity_id:
        - light.landing
mode: single

Turn On with Motion;

alias: Landing Light - Turn Light On - 7am to 7:59pm
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.stairs_sensors
    to: "on"
condition:
  - condition: and
    conditions:
      - type: is_illuminance
        condition: device
        device_id: 43951e2239f123987f9180c373597527
        entity_id: 1fb93710c431cd3ac2eda9282aab50e3
        domain: sensor
        below: 40
      - condition: time
        after: "07:00:00"
        before: "19:59:59"
action:
  - service: light.turn_on
    data:
      rgb_color:
        - 255
        - 217
        - 120
      brightness_pct: 90
      transition: 1
    target:
      entity_id:
        - light.landing
mode: restart

Turn off with no motion;

alias: Landing Light - Turn Light Off when No Motion
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.stairs_sensors
    to: "off"
    for:
      hours: 0
      minutes: 2
      seconds: 0
condition:
  - condition: state
    entity_id: light.landing
    state: "on"
action:
  - service: light.turn_off
    data:
      transition: 1
    target:
      entity_id:
        - light.landing
mode: restart

Thanks in advance.

you can disable the no motion turn off lights automation inside turn on with button automation. I assume, you need to press the same button to turn off the light (you are in manual override mode), so do not forget to enable no motion turn off lights automation back.

I am suggesting this simple trick because you have already 3 split automations (which I like) to manage each action separately, on the other hand, if you were doing many other stuff under one automation, you must use the input boolean way.

Let me know if you want to learn more about input boolean way

I would create an input boolean helper “Landing Light Motion”.

When button Is pressed in the actions you also change the helper to off.
Then in the motion sensor off automation add in the conditions that the helper should be on.
When the button turn off the light, you restore the helper to on.

I did orginally have this under one automation, however, what I found is if one thing went wrong, then the whole automation wouldn’t run. So having it separated is easier to ensure consistency in service.

This was the simplest solution and was so easy to add in. Thanks for the suggestion!