How to trigger sunset automation but only when sunset is before xx:xx time?

Hi all,

I’m working on completing my move from Smartthings to Home assistant, and struggling with a condition on an automation. Here’s my scenario:

I want to turn on a light in my chicken coop during winter months to encourage my chickens to go into the coop before sunset. For whatever reason, their circadian clock doesn’t seem to work quite as it should, and in the winter, they stay out of the coop until after sunset, and then can’t find their way back in without a light inside.

I had an automation on Smartthings that would turn on the light 30 min before sunset, but only if sunset was before 8pm. I’m struggling to figure out how to do that with HA, because the sun condition (via UI) allows an offset, but not a before/after time.

Does anyone have any help for me on this issue?

Just use a time condition.

That doesn’t work for me because I don’t need/want the light to come on during the summer months when Sunset is later.

Make the trigger sunset minus 30 minutes, and the condition time is before 7:30 pm.

1 Like


Leave it to me to overcomplicate the situation. Thank you!

1 Like