Light level OR time automation?

I have two automations that run:

  1. Light levels below 800lux - SET SUNSET SCENE
  2. Light levels below 35lux - SET COSY SCENE

What I am trying to achieve is that the COSY scene will only trigger AFTER or AT 8PM but can’t figure out how to do this.

I have a condition on the automation for AFTER 8PM but this means if the light levels drops at 6PM for example the automation doesn’t run but in this scenario I’d still like it to trigger the scene at 8PM.

Because I am running the SUNSET scene too which in summer happens anywhere up until 10PM I can’t simply put another automation on to trigger the cosy scene at 8PM because it would be COSY before SUNSET which would be backwards of how I want it if that makes sense.

I want SUNSET scene to activate at light levels below 1000lux (no time requirement) and COSY scene to activate at 250lux after 8PM and if this is light level is achieved before 8PM then set the scene at 8PM.

Does anyone know how to achieve this? Any help would be much appreciated! Sorry for the long winded question!

You need to post the automation(s) that you are using and make sure they are properly formatted using coe blocks.

Sorry, I’m new here - is the below coe blocks? Thanks :slight_smile:

SUNSET SCENE:

alias: Scene - Sunset
description: ""
trigger:
  - type: illuminance
    platform: device
    device_id: fbc6c8d6c99e3b1f92848996d5afa5f9
    entity_id: sensor.drive_hue_motion_sensor_illuminance
    domain: sensor
    below: 800
    for:
      hours: 0
      minutes: 10
      seconds: 0
condition:
  - condition: time
    after: "16:00:00"
    weekday:
      - sun
      - sat
      - fri
      - thu
      - wed
      - tue
      - mon
    before: "23:00:00"
action:
  - service: scene.turn_on
    target:
      entity_id: scene.sunset
    metadata: {}
  - device_id: 16216b83a9c146a5c3250f24edf9623c
    domain: mobile_app
    type: notify
    message: Sunset Scene Activated
    title: Scene Activation
  - delay:
      hours: 6
      minutes: 0
      seconds: 0
      milliseconds: 0
mode: single

COSY SCENE:

alias: Scene - Cosy
description: ""
trigger:
  - platform: time
    at: "20:00:00"
    enabled: false
  - type: illuminance
    platform: device
    device_id: fbc6c8d6c99e3b1f92848996d5afa5f9
    entity_id: sensor.drive_hue_motion_sensor_illuminance
    domain: sensor
    below: 35
    for:
      hours: 0
      minutes: 5
      seconds: 0
condition:
  - condition: state
    entity_id: input_boolean.after_sunset
    state: "on"
    for:
      hours: 0
      minutes: 10
      seconds: 0
    enabled: false
  - condition: time
    after: "20:00:00"
action:
  - service: scene.turn_on
    target:
      entity_id: scene.cosy
    metadata: {}
  - device_id: 16216b83a9c146a5c3250f24edf9623c
    domain: mobile_app
    type: notify
    message: Cosy Scene Activated
    title: Scene Activation
mode: single

I think you are saying that the sunset automation works as expected but you could probably remove all of the weekday requirements since you are using all of them. not a big deal but it can clean it up a bit.

in the cosy automation you can make both requirements a trigger and both a condition

alias: Scene - Cosy
description: ""
trigger:
  - platform: time
    at: "20:00:00"
    #enabled: false
  - type: illuminance
    platform: device
    device_id: fbc6c8d6c99e3b1f92848996d5afa5f9
    entity_id: sensor.drive_hue_motion_sensor_illuminance
    domain: sensor
    below: 35
    for:
      hours: 0
      minutes: 5
      seconds: 0
condition:
  - condition: numeric_state
    entity_id: sensor.drive_hue_motion_sensor_illuminance
    below: 250
  - condition: state
    entity_id: input_boolean.after_sunset
    state: "on"
    for:
      hours: 0
      minutes: 10
      seconds: 0
    enabled: false
  - condition: time
    after: "20:00:00"
action:
  - service: scene.turn_on
    target:
      entity_id: scene.cosy
    metadata: {}
  - device_id: 16216b83a9c146a5c3250f24edf9623c
    domain: mobile_app
    type: notify
    message: Cosy Scene Activated
    title: Scene Activation
mode: single

it looks like you were on the right track (but you had the 2000 time trigger disabled). You just needed top add the lux setting condition.

and I’m not sure what the sunset boolean is for.

Ah OK awesome - I didn’t think it would work if I had them both as triggers but that does make sense now. I’ll give it a go. Thanks for your help - much appreciated! :smiley:

1 Like