Sensor Light to come on between certain times from sunset

maybe to also make it clearer, let’s imagine sunset is 18:00. this original code:

  - condition: sun
    before: sunset
    before_offset: "-00:45:00"
    after: sunset
    after_offset: "01:00:00"

would translate to:

  - condition: sun
    before: sunset
    before_offset: "-00:45:00"
#  so 18:00 - 00:45... meaning before 17:15


    after: sunset
    after_offset: "01:00:00"
#  and after 18:00 + 01:00 ...  so after 19:00

so it would happen only when it’s simultaneously before 17:15 and after 19:00…

Hi Armedad, sadly I was not able to continue replying as I am new and limits were applied to my profile on replies
However after a lot of searching and watching I have got a decent working solution
While I have re-read the description on the sun condition and it works I am just battling to fully understand why the AFTER SUNSET must be a negative offset and BEFORE SUNSET is a positive yet logic would denotes that its the other way around, in my head anyway. I really do appreciate all the assistance on this and the learning that comes with it. I was really pleased once I got this going last night

alias: Stairs Strip Light - Non Bed Time
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.stairs_motion
    from: "off"
    to: "on"
    id: Stairs - Motion Detected
  - platform: state
    entity_id:
      - binary_sensor.stairs_motion
    from: "on"
    to: "off"
    for:
      hours: 0
      minutes: 2
      seconds: 0
    id: Stairs - No Motion
condition:
  - condition: sun
    before: sunset
    before_offset: "00:45:00"
    after: sunset
    after_offset: "-01:00:00"
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Stairs - Motion Detected
        sequence:
          - service: light.turn_on
            metadata: {}
            data:
              brightness_pct: 64
            target:
              entity_id: light.stairs
      - conditions:
          - condition: trigger
            id:
              - Stairs - No Motion
        sequence:
          - service: light.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: light.stairs
mode: single

I think you are getting confused because you are thinking too much about code and not starting from real life… If sunset is 18:00

You want it the condition to be after 17:15 right?

And before 19:00 right?

How would you express “after 17:15”. If sunset is 18:00?

After == after
17:15… Is that sunset -45 or +45?

ah of course
ok yeah was Clearly over thinking that, now makes sense
thank you very much

ah ok I see now