Why doesn't this automation run, sun trigger, lux condition? Opposite works!

I don’t get it. This doesn’t work:

alias: 'Light: Nattlampor SH/TH ON; sunset, <20 lux'
description: ''
trigger:
  - platform: sun
    event: sunset
condition:
  - condition: numeric_state
    entity_id: sensor.infart_motion_light_level
    below: '20'
action:
  - service: light.turn_on
    data:
      brightness_pct: 50
    target:
      entity_id: light.hallfonster
  - service: light.turn_on
    target:
      entity_id: light.gardsfonster
    data:
      brightness_pct: 15
  - service: light.turn_on
    data:
      brightness_pct: 70
      rgb_color:
        - 255
        - 0
        - 0
    target:
      entity_id: light.koksfonster
  - service: light.turn_on
    data:
      brightness_pct: 20
    target:
      entity_id: light.th_nattlampor
mode: single

But this works:

alias: 'Light: Nattlampor SH/TH ON; <20 lux, sunset'
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.infart_motion_light_level
    below: '20'
condition:
  - condition: sun
    after: sunset
action:
  - service: light.turn_on
    data:
      brightness_pct: 50
    target:
      entity_id: light.hallfonster
  - service: light.turn_on
    target:
      entity_id: light.gardsfonster
    data:
      brightness_pct: 15
  - service: light.turn_on
    data:
      brightness_pct: 70
      rgb_color:
        - 255
        - 0
        - 0
    target:
      entity_id: light.koksfonster
  - service: light.turn_on
    data:
      brightness_pct: 20
    target:
      entity_id: light.th_nattlampor
mode: single

Can someone please explain this for me? Thanks!

For the first automation, it appears that the light level is not below 20 at sunset, so it doesn’t execute its action.

For the second automation, by the time the light level is below 20, it’s already past sunset so it executes its action.

1 Like

Well of course, that’s must be the problem thanks! I had a similar issue to turn lights off at sunrise, but the opposite way. :woozy_face: