How to have ONE automation turn on a light at sunset then turn off at 11pm?

I can certainly do this in two automation (turn on light at sunset, off at 11pm) but how to trigger an off in the SAME automation? I’m using the automation UI. Do I add a Condition after turning on the lights, condition as Time 11pm, then add a turn-off light command after that? So the automation first turns the lights on, waits for the time condition, then turns off lights all in the same automation?

Set a trigger ID in the three dots.

Then in action use choose and trigger ID, one for each trigger

Thank you-
So in “Trigger” I created a trigger for sunset and labeled it “Sunset”, and another for 11pm and labeled it “11pm”.
Under Action, I select “Wait for a trigger” but it doesn’t ask me for the trigger name I created above? Or should I choose “Choose” in action, create two options that each are triggered by the trigger IDs above?

Yes choose.
In the drop-down select trigger id.
Select sunset, and as action turn on.
Add a new action (below the choose, not inside it. It can be confusing but the “add action” that is furthest down), choose, trigger id, 11pm, action turn off.
Save.

Awesome thank you! So you can’t have both triggers under one Choose?
I saw another example where the time trigger automatically goes to the “default” action under the first “choose” action?

You can if you only have one trigger and everything else is “the other”.
But that could mean an unavailable sensor will trigger your automation.

I generally use two choose both for readability and to be sure it only triggers on what it should.
But if your triggers are strict then it should work fine with using the default

Thank you Hellis81. You are an officer and a gentleman.

Could you please share your automation code, actually i am new and want to implement in my Home automation

This post came up when I was looking for help on a slightly more advanced topic, but my YAML example over here about sunset lighting illustrates the dual trigger with id’s approach.