Seems like a major obvious use case; I want an event to be triggered only after sunset and before midnight as a condition. But the time condition is only time, and the sun condition has only sunrise/sunset! I need both! I’m trying to avoid yaml for automations but is this not possible in the UI??
An automation executes its action
only if both its trigger
and condition
are fulfilled.
In fact, an automation’s last_triggered
attribute is updated only when trigger
and condition
are fulfilled (not when only trigger
is fulfilled but not condition
).
Create a Sun Trigger set to sunset and a Time Condition set to before midnight (all achievable using the UI). The combination of the two must be fulfilled in order for the automation to execute its action
.
Taras I’m setting up a trigger to be used only during a time window. Here it is:
I believe the two conditions here should work but have to test it. Both conditions must be met, correct? When I play via my android tv, after sunset and before 11pm, I want lights to turn off.
BTW the UI can’t do this natively. The sun condition requires a “before” time unless you edit it out via yaml. I did that and reverted to the UI.
Your first post led me to believe you wanted the automation to trigger at sunset, that’s why I mentioned the Sun Trigger. It’s now clear that you will be using a different trigger and want the condition to be a time between sunset and midnight.
Simply use a Sun Condition and Time Condition. As explained above, conditions are logically ANDed by default. In contrast, multiple triggers are logically ORed.
Got it. It certainly would be nice if the “sun” and “time” condition variables were merged into one. After all, they are both elements of a time construct.
Glad to hear the issue has been clarified.
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s which signals to other users that this topic has been resolved. This helps users find answers to similar questions.
For more information about the Solution tag, refer to guideline 21 in the FAQ.