Sunset, Sunrise condition & Offset

Hey guys i’ve just started getting into Home assistant and need some help with an automation. I have 4 lights in my living room i want to turn on 30-40 minutes before sunset. I set a sunset automation up and it starts up but when i put in a offset the lights don’t turn on. Not sure i’m doing it right.

alias: Living Room Lights On After Sunset Automation
description: ""
triggers:
  - type: occupied
    device_id: 950232b1b3a72f70144a3e7118469685
    entity_id: d311c3ba1089fe4317279d40f760592d
    domain: binary_sensor
    trigger: device
conditions:
  - condition: sun
    after: sunset
    before: sunrise
actions:
  - type: turn_on
    device_id: 17bb151fd490ab643b581b0beb368597
    entity_id: cb194b7273c39924efad7eeb9a131404
    domain: light
  - type: turn_on
    device_id: c76a09ca5215adc2082a5c4cb77eb5b3
    entity_id: b41defda5f5418e583ac443c5bf31895
    domain: light
  - type: turn_on
    device_id: a9d23b3ecab40459b589c62b9364e829
    entity_id: 4033b790f24a0abfd0af21d11ed92cce
    domain: light
  - type: turn_on
    device_id: 8d4bcf8833404903fb67c4f0736e4e6f
    entity_id: 7c980b2467486712c08c5385c3950ba3
    domain: light
    brightness_pct: 100
mode: single

In the GUI, do you have something that looks like this:

If there isn’t an offset option with the sunset/sunrise options, you might not be able to do an offset.

If that’s the case and what you’re trying to do is have something happen when it actually gets dark, you could look at the Azimuth the Sun integration provides and have it trigger when the sun is below the horizon. The other option is to look at the Sun2 integration:

IT has dawn and dusk options that already figure all that out.

The first automation you have posted only triggers when an occupancy sensor turns on… that’s it. If you need it to trigger based on sunset, you need to add a trigger for that. An automation can multiple triggers, so if you want both occupancy and sunset to trigger it, use them both… just make sure to mirror them in the conditions block as follows:

triggers:
  - type: occupied
    device_id: 950232b1b3a72f70144a3e7118469685
    entity_id: d311c3ba1089fe4317279d40f760592d
    domain: binary_sensor
    trigger: device
  - trigger: sun
    event: sunset
    offset: "-00:30:00"
conditions:
  - condition: sun
    before: sunrise
    after: sunset
    after_offset: "-00:30:00"
  - type: occupied
    device_id: 950232b1b3a72f70144a3e7118469685
    entity_id: d311c3ba1089fe4317279d40f760592d
    domain: binary_sensor
    condition: device