State of light from other light

Hi all, this is my first post…
I have recently started in the world of ha, I hope you will forgive the silly questions…

I made a simple automation that turns a light on and off. It is triggered by a door sensor. After 6 second, the light go off.

In the same room I also have a courtesy light. My idea was that: if the main light turns on, the courtesy light has to go off, until the main light goes off.
After the main light goes off, the courtesy light turns on (and stays on).
I thought about making a script, to be invoked twice in automation, but there is something wrong.

alias: Luce ingresso
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.door_window_sensor_158d00024de198
    from: 'off'
    to: 'on'
condition:
  - condition: time
    after: '09:00:00'
    before: '23:59:00'
action:
  - service: light.turn_on
    data:
      color_temp: 120
    entity_id: light.yeelight_color_0x00000000052c8b8f
  - service: script.cornice_ingresso
    data: {}
  - delay:
      hours: 0
      minutes: 0
      seconds: 6
      milliseconds: 0
  - service: light.turn_off
    data: {}
    entity_id: light.yeelight_color_0x00000000052c8b8f
  - service: script.cornice_ingresso
    data: {}
mode: single

The script cornice_ingresso:

alias: Cornice ingresso
sequence:
  - choose:
      - conditions:
          - condition: state
            entity_id: light.yeelight_color_0x00000000052c8b8f
            state: 'on'
        sequence:
          - service: light.turn_off
            data: {}
            entity_id: light.yeelight_stripe_0x0000000004575490
    default:
      - service: light.turn_on
        data: {}
        entity_id: light.yeelight_stripe_0x0000000004575490
mode: single

‘script.cornice_ingresso’ is invoked twice in automation. The first time, right after the main light turns on. The second after it goes out. In my head, the service light should go off in the first case, and light up in the second (the default action). It just doesn’t work well.

The courtesy light goes out, but then, after the main light goes out, it does not turn on again. Where am I doing wrong ?

Thanks for the tips !

May I ask why you don’t turn on/off the sexond light in the same automation and ibstead use a script?