hvardrino
(HĂ©ctor Varghese)
October 1, 2022, 9:36pm
1
Sun condition should be easy to set up for automation, but I always end up using state condition.
123
(Taras)
October 1, 2022, 10:27pm
2
Post what failed to work for you.
tom_l
October 2, 2022, 2:12am
3
If this is what I suspect, then it is a known issue:
opened 12:10PM - 26 Apr 22 UTC
integration: sun
### The problem
The Sun integration has two conflicting conditions for night.… As seen here:
![Screenshot 2022-04-26 at 22-00-20 Conditions](https://user-images.githubusercontent.com/10679300/165295450-9ac229e9-26cc-4486-b5cc-8a368953b91d.png)
The first condition
```
condition:
- condition: sun
after: sunset
before: sunrise
```
always returns false.
The second condition:
```
condition:
condition: or
conditions:
- condition: sun
after: sunset
- condition: sun
before: sunrise
```
Does return true at night.
I attempted to remove the first condition from the documentation in a PR but was told by Frenk that if the first condition is not returning true at night it is an issue with the sun integration. See: https://github.com/home-assistant/home-assistant.io/pull/22486
### What version of Home Assistant Core has the issue?
core-2022.4.7
### What was the last working version of Home Assistant Core?
_No response_
### 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/docs/scripts/conditions/#sunsetsunrise-condition
### Diagnostics information
_No response_
### Example YAML snippet
```yaml
- id: 52289855-75f5-437f-a28c-933e23446226
alias: 'Test Sun Condition' ### Does not operate as expected, input number is not incremented at night ###
trigger:
platform: time_pattern
minutes: "/1"
condition:
condition: sun
before: sunrise
after: sunset
action:
- service: input_number.increment
target:
entity_id: input_number.test
- id: 332125de-61c8-4c81-8c4c-3d0c4389617d
alias: 'Test Sun OR Condition' ### Operates as expected, increments input number at night ###
trigger:
platform: time_pattern
minutes: "/1"
condition:
condition: or
conditions:
- condition: sun
before: sunrise
- condition: sun
after: sunset
action:
- service: input_number.increment
target:
entity_id: input_number.test_or
```
### Anything in the logs that might be useful for us?
_No response_
### Additional information
_No response_
frenck
(Franck Nijhof)
October 2, 2022, 8:14am
4
There is an PR open to fix that occurrence of the sun, it might make 2022.10
2 Likes
b-jazz
November 22, 2022, 4:57am
5
I’ve read up on a couple of the bugs in the issues github, but most everyone is talking about conflicts between two different statements (before sunset and before sunrise for example). But I’m having problems with just trying to set up a Sun condition of “after sunset” in the web UI when editing an automation. Even running the test from the hamburger menu says the condition does not pass. I just updated to the latest versions (Home Assistant 2022.11.4) and the tests are still broken. Are we talking about the same bug?