Sunset lighting: colour transition + turn off

Dear community:

New to HA and hope somebody can help me with my automation to simulate a sunset effect of my lights in bedroom. I have the Hue Colour Ambient lights which support colour transition, so what I’d like to achieve is:

  1. When sunset starts, set start HSB values (cool temp)
  2. Set end HSB values (warm temp) and turn off light

(1) is straight forward, but I’m struggling with (2). So obviously light.turn_off doesn’t support HSB, so I tried light.turn_on with HSB (B=0), this sort of works for brightness, but colour transition doesn’t work, so the light stays at cool temp and gradually turn off.

The workaround I found is to first transition to HSB (B=1), then turn_off, but it’s quite messy as I need to wait for transition period to turn off the light, and it creates other issues for my supposed to be generic automation.

Does HA have a nicer way to address this? Thank you all!

Does anyone know what’s best way to implement sunset?