Scenario: I have an automation that performs AFTER Sunset but before 9pm.
Discovery: I found out (probably should have already known this) that as soon as the time turns to 12:00 am, the automation thinks it is before 9pm. So the automation runs from 12:00am to 8:59pm given ONLY that criteria.
Question: What is the duration of after Sunset? Is after Sunset from Sunset to Sunrise?
In other words, given the two conditions in my automation (and if AFTER Sunset is from Sunset to sunrise), my automation should only run from Sunset to 9pm.
Triggers will trigger when a value change from something to the value you have specified.
Conditions will checked after and if it is true then it will continue.
It is not uncommon to have the same value checked in both trigger and condition.
I am just interested in when does the condition “After Sunset” ends. Here is the condition code:
conditions:
- condition: sun
after: sunset
- condition: time
before: "21:00:00"
weekday:
- sun
- mon
- tue
- wed
- thu
- fri
- sat
I do apologize if I led you to think I needed help with the automation. I have it working, but wanted to ensure I was understanding how HA handles Sunset and Sunrise. If you have condition that states after: sunset… does that mean the automation will run from sunset to sunrise?
@123 Taras, I think that is exactly what I was looking for. So “After Sunset” is basically Sunset to 12:00:00am. Excellent! Thank you! That helps so much!
@123 Taras to answer your question, I was trying to bracket a time between Sunset and 9pm. You cannot currently do that in one condition since you can only select either the sun position or time, not both. So I wrote one condition to say After Sunset and another condition to say before 9pm. That got me thinking on how long is “After Sunset” anyway? LOL… I did not know if it went from Sunset to Sunrise, Sunset to 12am, or maybe even Sunset to 1 hour past Sunset.
@Didgeridrew, my bad. I should of said I was not able to do that condition using the GUI. I did not even attempt it in YAML. I really, REALLY need to learn YAML.
What I posted can be done in the UI, it’s just easier to share in YAML… especially with the new (2025.5.0) function that allows you to just paste it directly into the UI editor.
Brilliant!
So that is what the second Option “Value of a data/time helper or timestamp class sensor” means. I am hitting myself for not at least clicking on that option to determine what it was actually used for.