Please help with sunset and sunrise with polar days/lights

I had a great deal of work making my NodeRed handle polar days/nights.
Common issue was the state of light the first day when the sun never went below horizon, or raised over.
Adding offsets to this generated completely inversed situations too.

Does HA have some decent variable/method I can use that can be used to control lights, and not get confused by polar day/nights?

Can you give a more detailed description of what you want?

The most flexible option is probably a Template sensor or binary sensor. Templating can be used to take data from multiple sources to synthesize your desired output.

You may also want to look at Sun2 custom integration.

That integration used to have a warning about it not working for high latitudes. Not sure if it was fixed or if they just removed the warning from the docs.

Does knowing what day it is have any significance? Its either day or it is night. Are you testing the right identity?

You could use sun elevation instead of sunset. It will always be negative during polar nights and positive in summer, regardless of the time.