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
69.72k stars 28.88k forks source link

Sunset trigger and sun.sun state not in sync #115743

Open sallygal1 opened 2 months ago

sallygal1 commented 2 months ago

The problem

I'm using the sun.sun sunset trigger in my automation (among others). Additionally I have an automation condition to confirm that the state of sun.sun is below_horizon. This has been working fine so far. I suspect there is a new bug, introduced in https://github.com/home-assistant/core/pull/113544 @bdraco

Now, once the sun.sun sunset trigger fires, the sun's state sometimes is below_horizon but sometimes also above_horizon (altough the trigger just fired).

To reproduce create an automation with a sunset trigger and a condition with sun state below_horizon. You will notice, sometimes the automation condition is false.

And interestingly, some other automation in my system is working fine:

What version of Home Assistant Core has the issue?

core-2024.4.2

What was the last working version of Home Assistant Core?

core-2024.3.3

What type of installation are you running?

Home Assistant OS

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

alias: Sun trigger error
description: Sun trigger error
trigger:
  - platform: sun
    event: sunset
condition:
  - condition: state
    entity_id: sun.sun
    state: below_horizon
mode: single

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 2 months 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)

atx32 commented 1 month ago

I am seeing the same issue, with about a 2-minute difference between the sunset/sunrise trigger and the state updating.