Odd automation issue with light sensor

Wondering if someone can tell me why the first automation is working fine but the second one doesn’t work?
I created the 2nd as a duplicate of the 1s so can’t understand why it isn’t working.
This one does work.
alias: Garden lights on at dusk
description: ‘’
trigger:

  • platform: numeric_state
    entity_id: sensor.sonoff_1000184024_light
    above: ‘9’
    condition:
  • condition: time
    after: ‘15:30’
    action:
  • scene: scene.garden_lights_on
    mode: single

This one doesn’t work.
alias: livingroom lights on at dusk
description: ‘’
trigger:

  • platform: numeric_state
    entity_id: sensor.sonoff_1000184024_light
    above: ‘8’
    condition:
  • condition: time
    after: ‘16:00’
    action:
  • scene: scene.living_room_lights_on
    mode: single

Other than changing the time, light level & target device they’re identical.
If I manually click “execute” it runs fine.
Any thoughts folks?

Please post formatted code. Proper indentation is required for YAML and no one can inspect it when the code is posted unformatted.

Select the code and click the </> icon in the forum’s editor.

Alternately, type three consecutive back-quotes ``` on a separate line before the block of code and then three more on a separate line after the code. Everything between the two sets of triple back-quotes will be automatically formatted.

In addition, the Numeric State Trigger will not trigger if the value is already above the threshold. It only triggers when the value crosses the threshold.

Please do as Taras suggested.
Are you sure your first automation works? I never seen a scene being activated like this.

It should be:

action:
  service: scene.turn_on
  entity_id: scene.xxxx

Apologies try again.
Working

alias: Garden lights on at dusk
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.sonoff_1000184024_light
    above: '9'
condition:
  - condition: time
    after: '15:30'
action:
  - scene: scene.garden_lights_on
mode: single

Not working

alias: livingroom lights on at dusk
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.sonoff_1000184024_light
    above: '9'
condition:
  - condition: time
    after: '16:00'
action:
  - scene: scene.living_room_lights_on
mode: single

Note I just changed the light level in the 2nd from 8 to 9 as a fault finding exercise.

The only significant difference between the two is the second automation’s condition checks a half-hour later.

If the light level rises and crosses the threshold value (9) just after 15:30, the first automation’s action will be executed but not the second one because it requires the time to be after 16:00.

Done. The second automation will no longer be triggered because of the way a Numeric State Trigger works. It only triggers when the value crosses the threshold.

I think that may well be the issue, the value is already above the trigger level by the time the time condition is met.
Any thoughts on how I would achieve this, I want the light to come on when it starts to get dark but not before say 4pm otherwise my living room lights are on for hours before I need them.
Yes I was just typing this as you replied.

This is one of those situations where the trigger and condition require equivalent tests.

trigger:
  - platform: numeric_state
    entity_id: sensor.sonoff_1000184024_light
    above: '9'
  - platform: time
    at: '16:00'
condition:
  - condition: numeric_state
    entity_id: sensor.sonoff_1000184024_light
    above: '9'
  - condition: time
    after: '16:00'

Now it can be triggered by either the light level or the time. The condition must check both light level and time because the trigger can be either one.

A Numeric State Condition, unlike a Numeric State Trigger, isn’t concerned about crossing the threshold, just if the value is above the threshold (or below if using the below: option).

Thank you for your help and yes makes sense.
I’ll give it a try and see how that goes tomorrow at dusk.
Cheers :wine_glass: