How do I make my automation so when I turn on manually it does not follow the current automation time

So I have the below automation, and when I turn on the lights manually via HA UI it always follows the automation time - I would like to avoid that.
Below is my current YAML:

alias: Upstairs Hallway Light Turn On
description: Turn on when motion and turn off when no motion
trigger:
  - type: motion
    platform: device
    device_id: 160424f2c62357e1b6e7a79c2521378b
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_iaszone
    domain: binary_sensor
condition: []
action:
  - if:
      - condition: time
        before: "00:01:00"
        after: "06:55:00"
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
          - sat
          - sun
    then:
      - service: light.turn_on
        data:
          rgb_color:
            - 255
            - 74
            - 254
          brightness: 20
        target:
          entity_id: light.hallway_bulb2_light_2
    else: []
  - if:
      - condition: time
        before: "07:00:00"
        after: "19:00:00"
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
          - sat
          - sun
      - type: is_illuminance
        condition: device
        device_id: 160424f2c62357e1b6e7a79c2521378b
        entity_id: sensor.lumi_lumi_sensor_motion_aq2_illuminance
        domain: sensor
        below: 3
    then:
      - service: light.turn_on
        data:
          color_temp: 315
          brightness: 100
        target:
          entity_id: light.hallway_bulb2_light_2
  - if:
      - condition: time
        before: "23:59:00"
        after: "19:01:00"
        weekday:
          - sun
          - sat
          - fri
          - thu
          - wed
          - tue
          - mon
    then:
      - service: light.turn_on
        data:
          color_temp: 239
          brightness_pct: 60
        target:
          entity_id: light.hallway_bulb2_light_2
mode: single

Add a condition that confirms the light is currently off.

condition:
  - condition: state
    entity_id: light.hallway_bulb2_light_2
    state: 'off'

It will prevent the automation from controlling the light’s brightness if it’s already on (such as when you turn it on manually).

1 Like