I want certain lights to come on Monday-Friday at 6:30 a.m., but only if the sun is below the horizon.
I’ve read through a large handful of posts*; originally I couldn’t get the automation to not fire on the weekend, but you folks helped me out, thanks**! Unfortunately, every different syntax I’ve tried for combining two conditions has resulted in the sun coming up before 6:30, and the lights coming on anyway.
Here’s what I have currently; I’m hopeful it’s a simple syntax error (I’m relatively new to scripting):
Hmm. Even though “sunrise” happened today at 6:26, the lights in the script still came on at 6:30.
The order I have the trigger and conditions (including the time and sun conditions) shouldn’t make a difference, right? I think I read that, as soon as a false condition is reached, the script should terminate. So it should be checking to see if it’s before sunrise, false, terminate. But that isn’t happening.
The only other thing I can think of is to reboot hass.io and hope for the best tomorrow.
Conditions are AND by default, so if those two conditions are not both true when the trigger becomes true, the action won’t fire. Order doesn’t matter in this case since you don’t have any nested condition: and or condition: or conditions.
Check that your location is set correctly in Home Assistant. Also, are you saying that per the logbook in Home Assistant, the sun rose at 6:26? Either way, you could try changing your sun condition to this:
- condition: state
entity_id: sun.sun
state: 'below_horizon'
The docs warn about using the sunset/sunrise conditions in certain cases. Perhaps one of them applies to you.
I’ve checked and confirmed that my location is set correctly; I also have a sunrise event trigger that shuts off any active lights and switches, which fired at 6:26, so that’s working as expected.
I think my location would be considered pretty “standard,” but since what I have isn’t working, I’ve changed my sun condition to the state condition you suggested, thanks!