Automation with 2 conditions triggering very late

I created a automation to turn on the outside lights when it’s getting dark. I only want to trigger it if the time is between 17:00 and 21:55, so they don’t go on late at night in summer.

My automation looks like this:

- alias: Outside lights on when dark
  trigger:
    platform: numeric_state
    entity_id: sensor.light_sensor_18
    below: 100
  condition:   
    condition: and
    conditions:
      - condition: time
        after: '17:00:00'
        before: '21:55:00'      
  action:
     service: script.outside light on

I have another automation that turns the light off at 22:10

Since it’s now getting dark around 17:00, I would expect it to trigger quite soon after 17:00, but I noticed that it is getting triggered a lot later, sometimes it takes up to 19:00 before they go on, even though sensor.light_sensor_18 is reporting a value of 0 at 16:45 already.

Any idea what could be wrong? should I configure this in a different way?

This is only 1 condition, you don’t need the and.

- alias: Outside lights on when dark
  trigger:
    platform: numeric_state
    entity_id: sensor.light_sensor_18
    below: 100
  condition: 
   condition: time  
    after: '17:00:00'
    before: '21:55:00'      
  action:
    service: script.outside light on

Numeric state only trigger on value change. If the value stays at 0 it won’t trigger (until a car pass or something change the sensor value at some point).

One solution would be to use the light sensor as condition and to trigger the script from both the light sensor and a time trigger at 17h01 (in case the light sensor is already at 0)

2 Likes

I use something similar to this at home:

- alias: Auto Exterior Lighting
  trigger:
    platform: sun
    event: sunset
    offset: '-1:00:00'

  action:
    service: switch.turn_on
    entity_id: switch.outside_lights

Turns on the lights 1 hour before sunset.