Why are the sunrise and sunset times wrong?

The times for sunrise and sunset given by the sun integration are consistently and significantly different from time calculated elsewhere. For example, sunrise tomorrow is 0715 according to my Ecowitt station, my Garmin watch, and an online calculator. Sun shows it as 0707. My watch says the sun sets tomorrow at 1705, Ecowitt at 1706 and online it’s 1707. Sun says 1715. In other words, the Sun integration is about 8 minutes early at sunrise and about 8 minutes late at sunset.

Settings>System>General>Edit location shows my house within a few meters of its actual location.

Sun times have always been off in my HA and I work around it with offsets. but I wonder if anyone else has seen this and what could be the cause?

Make sure your coordinates are correct in your Home / Map, and laborate with the ( Elevation )
A few meter Heigher / Lower can make the difference , even on external temperature-forecasts.
But dont expect miracles, they all have different sources, and measurements.
I.E top of sun, middle of sun or bottom, of the horizon. some maybe take account for the common Elevation in the area, an average of the area, but not within meters from your particular spot.

( And whether you live in a big city tower on 31st floor, or bottom level )

The issue is usually that many of those other sources make approximations.
It is often too hard for normal users to find their lat, long and height of their current location, so it is easier to ask for nearest major city or use the location of the point of interconnection for your ISP (https://iplocation.io/).
These location can be quite far off and sometimes it is even state/country instead of city.

1 Like

My IP Location, fiber-provider is approx 600km north-east of my place (at the east-coast, lowland ) , Or 250km south-vestcoast ( at the lowland ), Depending upon which whois-service you use :smile:
My phone ( while not entirely on my wifi ) is approx 200km south, lowland )

I live at 130m height, cording to i.e google, others say 134m , fact is cording to officials-docs, it’s 136m ( so i adapted to 134m , to get the weather-providers-temperature as close to my local-own-devices-outside temperatures )

Maybe OP, could make an automation / template and take all his sources, + from google(voice-assistant ) and apple (siri) , + ofcause his gps / map coordinates , and run all these sources through his favorite , most reliable AI-engine , and use this as ( Accurate ) sunrise /sunset :sun_with_face:

Actually, it’s quite easy to determine your precise lat/longs and elevation above sea level. Just go to earth.google.com and find your location. These measurements are found in the lower right corner of the screen.

Seeing the comments about elevation, I decided to set that to zero in location settings. Sure enough, HA then agreed (within one minute) with my other sources. So I checked the HA documentaion, and it says to set that at your elevation above sea level. That would be correct only if you could see the sea; otherwise, it should be your elevation above the surrounding terrain.

Does HA use this elevation setting for any other purpose than adjusting sunrise and set times?

Probably also for home zone and distances from home.

If you rely upon Google yes, thou Ha uses OpenStreetMap , might differ a bit there ( well it Does differ ), using Google’s lat/long place me +100m off in OpenStreeMapp

PS: Does earth.gogle.com, gives you the same coordinate as google.com/map ( Same Spot ? )

Some Integrations might/do use the Elevation + Coordinates you’ve set in HA, such as in specific weather-integration

When I paste google earth coordinates into google maps it plots to within 25-30 meters, close enough. As far as weather integrations, I convert those with templates where needed, eg absolute pressure to sea level pressure. I haven’t used distance for anything, but I checked the device trackers on my mobile apps. My phone and tablet don’t appear on the map since they’re at home, but the coordinates in entity attributes show the correct lat/longs and the actual altitude from GPS. My chromebook does show on the map since it is in our second home. When I switch to that HA server I see my phone and tablet on that map. So, I’ll leave the site elevation set at zero for the correct sunrise/set times, unless I find something that breaks because of that. Thanks to all for the useful replies.

Ok, i don’t have problems with that, my phone ( or my place actually ) seems to always be unavailable from GPS over mobile ( 25-50m from my House ), and i seldom get a 3G connection here , so i only turn on GPS if i need a Driver guide :slightly_smiling_face: , and always call over , connects to Wifi when home ( doo to the blind spot i live in ) … so when im home, my phone is mostly 200km south of here ( because it’s not available for the mobile network )

Home Assistant uses the Astral package (currently v2.2) to calculate sun-related data & events. Some of the data it requests from the package require an “observer elevation.” In these cases, HA provides its elevation config value.

As mentioned previously, the value provided to the package should be the observer’s “elevation above ground level.” See Effect of Elevation from Astral’s documentation for more detail.

However, the HA documentation says the elevation configuration parameter is “Altitude above sea level in meters. Impacts sunrise data.” That seems like a documentation defect. I would think it should say “elevation above ground level.” (Honestly, I never noticed this before!)

But, having said that, there are at least five built-in integrations (medcom_ble, airthings_ble, met_eireann, openuv & met) that also use the elevation configuration parameter. I have no idea what they assume the value means.

I think the only thing that is agreed on is that the value is in meters!

1 Like

The altitude would have to be over sea level.
Ground level is impossible to put into a calculation unless you have the entire earths ground elevation for something like each meter in between.
The only case where a ground level would make sense would be if 3-axis GPS coordinates would be required to enter in the configuration, but that would mean only actually GPS readings could be used.
Google maps and I think all the other free map services only use 2-axis coordinates, because the 3. axis would require huge amount of data for ground levels with something like 1 meter in between each reading.

I think you misunderstood what I said and quoted.

The value you should enter into HA’s elevation option on the general system page is your elevation above the ground around you, not the elevation of that ground above sea level, or even your elevation above sea level. Unfortunately, this is not what the HA documentation says, because it’s wrong.

E.g., if you live in a regular house in a generally flat area, your elevation would be zero. If you live in a high-rise, your elevation would be the distance from ground level to your apartment/flat. If you live on a hill in an otherwise flat area, it would be the height of the hill as compared to the surrounding area.

You’re correct in that it would be impractical for a package like astral to accept altitude above sea level, because then, like you say, it would have to have access to a database containing worldwide elevations, which it does not.

2 Likes

There is no algorithm to calculate such a thing without the system knowing all the ground levels on the entire world.
The altitude has to be your altitude over sea level, which means your ground level over sea level + the level over that if you live in a high rise.
The sea level is set to the same around the world.

I’m sorry, but you are incorrect. Please follow the link I provided to the documentation of the astral package. Maybe I’m just explaining it poorly.

I was wrong. It seems to be somewhat more complicated.
It is not the height of the ground as such, because on a circle the formula will be the same for any size of the circle.
The problem comes when the circle is not really a circle, but more “bumpy”, which change the tangent line.
The post with pictures here explains it pretty well.

So it is a calculation you need to make over your own placement and the surroundings.
You can choose to do those calculations with measurements taken from the sea level or from the ground level (or from the center of earth if you so desire), as long as the measurement method is the same for all measurements.

That’s just the point. The calculations are done by the astral package, so it defines the inputs it needs. Again, you might want to browse its documentation.

The bottom line is, HA’s documentation misleads the users as to what value to enter for elevation so that the astral package can generate useful results.

1 Like

I found the page you might refer to: Setup basic information - Home Assistant
I agree that is wrong and should be reported as a bug!

Yep, I had a link to that above. :smile: I’ll probably just submit a PR at some point.

Ahh, I missed the link, because it had nothing with HA in the visible text. :smiley:

I would sometimes be nice, if you can just flag a post as a bug report.

I wouldn’t consider it as a bug, the description follows ( Common understandings ) , as mention , various Maps-provider etc , use varies measurement when they present their ( Facts ) , and the GAS whether you live in a sunken hole, on a slope or on top floor of empire state building.

People can use common sense, if they use Google as their source for gps, longitude/latitude, they can use their ( suggestion ) for altitude as well , and then add / subtract a few meter, if they need to (adapt) to either weather provider, or Sun integration ( From their specific “Point” of view )