Take a look at the documentation for conditions. This bit is wrong. You need to have multiple conditions.
condition:
condition: or # 'when dark' condition: either after sunset or before sunrise
conditions:
- condition: sun
after: sunset
- condition: sun
before: sunrise
Check out the documentation:
Sunset to Sunrise will not work because it crosses the reset. Days reset at midnight. So anything after sunset does not equal before sunrise. You want to write your condition based on before sunrise OR after sunset.
before sunrise = 0 to sunrise. after sunset = sunset to 24 (or midnight).