It’s easier to explain to someone that this will happen a half-hour before sundown or hour after.
The reason for that is to be able to quickly adjust those values without the need to edit YAML manually and restart HA.
I’m building my first automation, for my parents and I can’t expect them to learn YAML
I want to turn light on and off in two rooms, both have windows on other sides, so in one there could be dark and in second the light could be sufficient.
I think it’s more of having the ability to build a config view where all things could be configured via UI.
Why trigger would be problematic? Sadly I don’t know the insides of Home Assistant enough.
Then the real solution is to add light sensors. Or barring that, again, use elevation & azimuth. It takes a bit more work to figure out which elevation & azimuth values to use, for each room, but once you get that figured out it will adjust the time automatically throughout the year, with (theoretically) no further manual intervention by you or your parents.
It’s a bit easier to template the offsets for the condition because they will be evaluated once, exactly when they’re needed – i.e., when the automation triggers. And it’s behavior will be completely as expected.
But templating the offsets for the sun trigger means the trigger will need to be re-initialized every time an entity referenced in the template changes, which is a bit more involved. But worse, I don’t think it would behave as people might expect. Let’s say, for example, the trigger is set for one hour after sunrise. Then about a half hour after sunrise the offset is changed to 15 minutes after sunrise. What do you think should happen? Should it trigger because the time was before the offset but now it’s after? Well, no, it wouldn’t. This is because a trigger is for an instant in time, and that point in time was moved without the actual time ever coinciding with it.
I think what you described it the correct way of the trigger to work. If you change offset from 1 hour to 15 minutes it will work the next day. I think the same logic applies if you don’t use a template. Am I right.
The only way it should work is like this:
you have a trigger set for one hour after sunrise, then about a half-hour after sunrise, you change the offset to 45 minutes. This should fire in 15 minutes.
I saw a couple of your PR that add template support, so I was thinking about adding support based on your code, but before that, I wanted to discuss that with you.
What do you think about having ability to specify hours, minutes and seconds individually in offset? Is this build in or should it be added?