You don’t need to make it check every 5 minutes. Simply add a trigger for sunset. If you arm the alarm system before sunset, when sunset occurs it will trigger the automation and turn on the light.
alias: away
description: activate some lamps randomly
trigger:
- platform: state
entity_id: alarm_control_panel.gigaset_elements
to: armed_away
- platform: sun
event: sunset
condition:
- condition: state
entity_id: alarm_control_panel.gigaset_elements
state: armed_away
- condition: state
entity_id: sun.sun
state: below_horizon
action:
- service: switch.turn_on
target:
entity_id: switch.lamp1
If you want to do that then why did you add this last action?
- delay: 00:{{ range(0,10) | random | int }}:00
It serves no purpose other than to delay the end of the automation. Perhaps you meant to put a delay before the light is turned on?
I’ve added a 2nd trigger for the sunset after arming the alarm trigger right?
a fundamental question if I set the automation to active… It waits infinitely for a trigger that applies and then the automation runs until the end …? What happens the next day if it’s still active… Does the automation start again or only after a new trigger is detected, does the status of the system have to be changed first?
Yes but the example I posted above also contains two conditions, a State Condition and a Sun Condition.
Yes and the “end” is after the delay finishes (a duration between zero and nine minutes) and turns on the switch. Immediately after that, it’s ready to be triggered again.
Yes but the example I posted above also contains two conditions, a State Condition and a Sun Condition.
Seems not to work correct…I think I used to be as far as I am now…
with the 2nd trigger “sunset” It runs the automation also when the alarm is not armed… so thats not the solution…
the workflow should be like:
when alarm armed
condidion sunset
or wait until sunset
turn lamp1 on…
when automation “end” check again if its armed and start again when sunset…