Next_rising and next_setting still shows appr. 2 minutes too late (GMT+1, central europe, Slovenia,)

BTW… since we’re talking about wrong times…
next_rising and next_setting still shows appr. 2 minutes too late (GMT+1, central europe, Slovenia,).

I have another sun sensor in Esphome, which reports correct times into HA. Why are times from sun.sun wrong? My position is correct and inserted into HA’s config file.

Currently sun.sun shows sun setting 18:13, which is GMT time, so if i add 2 hours (summer time) comes 20:13, which will be on thursday, while today sunset will be at 20:11.

Ok, it’s two minutes, but … just out of curiousity…?

It is what it is, I asked that question before. We are both SOL. Unless the site(s) with the best and reliable rise and set times does a integration or API that is free, it will have to do.

Is your home location altitude set correctly?

This affects sunrise predictions.

Also, when you looked at next_setting, had the sun already set for the day? If so, then the time is for when the sun sets tomorrow, not today, and can, and most likely will, be different by a minute or so from today’s sunset.

1 Like

Location is set, i entered it additionally in configuration.yaml later for testing (under “zone”, then i also tried to put it under “homeassistant” - same numbers come out). I put in same coordinates as in ESPHome module. In HA location points exactly to my house - they are copied from google maps.

pnbruckner: when i wrote above question it was afternoon, well before today’s sunset (at this moment it’s just about to set). It seems that two modules calculate this differently… (BTW according to out local official weather data correct one is the one from esphome)
Here’s data: top values are from esphome, bottom ones are from sun.sun (both for today, before today’s sunset):

image

Try to search for the sun2 integration

Not just location, altitude too

I did, i even installed it, but it shows the same data as HA’s sun.sun. I think that sun2 is based on sun.sun anyway, it just adds a few more sensors…

It is not based on sun.sun.
So I guess your location is set wrong as mentioned earlier in the thread.

Hm… there’s no mention of altitude anywhere…just latitude, did you mean that? I’m not sure how to get latitude for my place, or how to enter altitude other than in settings - system - general, where is correctly set for my city (315m). But, even if i change it, sun numbers doesn’t change.

OK, if i understand correct all this is set under settings -->System -->general (i DO have set it there, from the beginning of my HA existance). But, there are options to set it manually if i understand correctly, i found two options: under “homeassistant” and under “zone”. Which one is correct - or are they both ok or even needed at all ? As i said, i tried both options (and without any of two), in any case numbers are the same.

Wally, location is definitely correctly set, to 15 decimal places :innocent: that white square is me (you can almost see me waving…) Circle is 100m radius (default setting)

The Sun Integration seems to have the required fields disabled:

How do you find Sun2? Found under HACS > Store

Elevation is found under Settings > General

SUN2 integration
But, i found out this funny thing: I entered 1m into HA–>settings–>system–>general -->altitude and restarted HA - yes, i’ve had to restart HA, just reload zone in developer tools doesn’t help, and now it shows correct values. Odd indeed…how come, if i’m at 315m?

since google finds this:


(explanation: sončni zahod" means sunset)
So, now there IS one option: since above data is “official” for my country: perhaps it’s calculated for sea level - we do have sea, too - in this case ESPHome is the one which shows wrong values…

Don’t understand me wrong - i’m not picky about that at all, it’s purely for “scientific” reasons… i’m just curious why this difference…

The correct value is the one adjusted for your local height above sea level. The sun rise/set time you are comparing it to is not adjusted for this. Probably because it covers a large area or it is a simplistic model.

1 Like

With location I meant also the altitude/elevation.
I do not know how HA is set up in regards to sun.sun, but sun2 has it set in the YAML configuration.

Besides what source are you using to get your “correct” times?

I’ll send email to my weather provider, out of curiosity… i’m beginning to think as tom said, that this “official” data is general information and not super accurate, although it is (wrongly?) stated for my city…
After all, esphome is the one which doesn’t have altitude information, not HA (and i can’t find any info about esphome being able to work with altitude for sun sensor).
So, for now i guess i’ll have to “change my mind” and take HA’s values as correct ones…

Wally, when i tried sun2 i didn’t play with settings, i guess that in this case sun2 took data from HA, so same numbers came out, which is logical.

I’ve tried the Sun2, it give results in hours, not the time. So that is a problem.

Close. sun2 uses the same package that sun.sun, and other sun related items in HA, use, specifically astral. I should know because I’m the author of sun2. If the data is wrong, then you need to take it up with the authors of the astral package. :wink:

Yes, HA’s location elevation is entered in Settings → System → General, in the Elevation field. The elevation can change the results, but probably very slightly, like maybe seconds, or fractions thereof. I haven’t tested to see. I’ve always just set my elevation correctly.

First, zones do not have an elevation parameter, only latitude, longitude & radius. For HA’s built-in sun related calculations, only HA’s main location configuration matters. That’s the elevation already mentioned, and latitude & longitude, which are set (via the GUI) in Settings → Areas & Zones → Zones → Home.

Yes, sun2 allows to configure one or more locations (latitude, longitude & elevation), but uses HA’s config values (discussed above) by default.

Exactly!

The differences may be partly due to slightly different values for latitude, longitude and/or elevation. But it’s also possible that the algorithms used in the astral package may, just by their nature, return slightly different results than what some weather service uses. Let’s hope a weather service, with their super computers, can do a better job of calculating these values (for a particular, given spot on the globe) than some python package running on potentially very slow home computers. :grinning_face_with_smiling_eyes:

I’m not sure what you mean. By default, in the GUI, yes, it does show such and such hours before or ago. That’s how any entity with a device_class of timestamp is shown. That’s a GUI thing, not the entity itself. It’s state is a datetime in UTC (converted to a string, of course), and its yesterday, today & tomorrow attributes are python datetime objects in the local time zone:

1 Like

So here is another issue, the elevation shown in the sun.sun is wrong.

It shows 15.26m for my location

Now my elevation is 192 m or 629.9213 ft

Can I over write that value in the state?

That’s the elevation of the sun, not you. It’s in degrees, not meters. If you monitor it over time, you’ll see it will change as the sun rises and falls.

Thanks a lot for this detailed explanation!

1 Like