Assitance with Automation at Sun till hour

Hello, I’m Trying to transfer an automation from Nodered to Homeassistant automations.
This is to turn on a light after sunset till 02:00 (AM). But it’s not working. By Traces it stops at the time condition. Why?

alias: Luz Cozinha Movimento Before2
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.cozinha_occupancy
    to: "on"
  - platform: state
    entity_id:
      - binary_sensor.cozinha_pir
    to: "on"
condition:
  - condition: and
    conditions:
      - condition: state
        entity_id: input_boolean.luzes_cozinha_auto
        state: "on"
      - condition: sun
        after: sunset
        after_offset: "-00:15:00"
      - condition: time
        before: "02:00:00"
action:
  - service: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.int2cozinha1
  - delay:
      hours: 0
      minutes: 2
      seconds: 0
      milliseconds: 0
  - service: switch.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: switch.int2cozinha1
mode: single

condition:
  - condition: state
    entity_id: input_boolean.luzes_cozinha_auto
    state: "on"
  - or:
      - condition: sun
        after: sunset
        after_offset: "-00:15:00"
      - condition: time
        before: "02:00:00"

You want the time to be after sunset OR before 02:00.

You had them logically ANDed which doesn’t work because, for example, 22:00 is after sunset but it’s not before 02:00. Twenty-two is not less than two.

Thank You. It works