Precision of Sun component

Hello All,

I found the piece of code below in the sun.sun component and the following explanation for decreasing the precision of sun updates during particular times of day: https://github.com/home-assistant/core/pull/23832

_PHASE_UPDATES = {
    PHASE_NIGHT: timedelta(minutes=4 * 5),
    PHASE_ASTRONOMICAL_TWILIGHT: timedelta(minutes=4 * 2),
    PHASE_NAUTICAL_TWILIGHT: timedelta(minutes=4 * 2),
    PHASE_TWILIGHT: timedelta(minutes=4),
    PHASE_SMALL_DAY: timedelta(minutes=2),
    PHASE_DAY: timedelta(minutes=4),
}

However I need more precise readings during twilight (every 30s) - since this is when I am automating my blinds to be opened. I have created a variable that calculates the cut-off elevation for each day of the year which falls between -12° (for Summer solstice) and 0° (for Winter solstice) and I would like to use that elevation with the highest time precision to open or close my blinds (I find it that values in minutes do make a difference)

Question: Is there a way of configuring the _PHASE_UPDATES on a live system?

You can’t.
Beside trying to convince the HA devs this is a good idea, your best immediate approach would be to copy the sun integration and adapt it to your liking.

See How to create a custom component from one removed from HA itself for an outline of how to do that

All right!
I created my own component, called it Sol in order not to duplicate the Sun and it just works.
Thank you!

For future reference, you didn’t have to rename it.
If you keep the same name, it just overwrites the builtin one.

Also look at the sun2 custom integration, but honestly, you can just use the sun elevation attribute of the built-in integration, or is the problem that the elevation isn’t updating frequently enough?

Just the link to Sun2, as suggested by parautenbach.