home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.07k stars 31.09k forks source link

Sun next setting is wrong #131850

Open AndreKR opened 2 days ago

AndreKR commented 2 days ago

The problem

To my understanding the sensor sun_next_setting should contain the time of the next time that the sun.sun entity will change from above_horizon to below_horizon.

I found there is a difference between those two times.

image

image

You can see that the sun was supposed to set at 16:30, but in fact it set at 16:34.

What version of Home Assistant Core has the issue?

core-2024.9.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Sun

Link to integration documentation on our website

https://www.home-assistant.io/integrations/sun/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

It might be interesting why this is an issue. I'm using this template sensor to control when my blinds should be down (from 15 minutes before sunset to sunrise):

{% set current = now() %}
{% if states('sun.sun') == 'above_horizon' %}
  {# Sun is up - check if we're within 15 min before sunset #}
  {% set next_sunset = states('sensor.sun_next_setting') | as_datetime %}
  {{ current >= (next_sunset - timedelta(minutes=15)) }}
{% else %}
  {# Sun is down #}
  {{ True }}
{% endif %}

Because of the bug my blinds go down at 16:16, then up again at 16:30 (when the time of sun_next_setting is reached) and then down again at 16:34 (when sun.sun actually changes to below_horizon).

home-assistant[bot] commented 2 days ago

Hey there @swamp-ig, mind taking a look at this issue as it has been labeled with an integration (sun) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `sun` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign sun` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


sun documentation sun source (message by IssueLinks)

mib1185 commented 1 day ago

The first screenshot is a logbook entry which just means that at 16:30 the sensor "Sun Next setting" has been set to "November 28, 2024". The new state is just a date because of limited accuracy of visible log book entries. So it doesn't mean, that the next sun set is at 16:30, but the the state has been changed at 16:30. You can check the state in the Developer tools -> states tab

AndreKR commented 1 day ago

The first screenshot is a logbook entry which just means that at 16:30 the sensor "Sun Next setting" has been set to "November 28, 2024".

I'm reasonably sure that the "at 16:30" is part of the value and not the time that it was changed.

Here are more logbook entries as well as the current state:

image

image

As you can see the "at xx:xx" part corresponds to the time in the value and not to the time the logbook entry was made.