Probs with my automation Alarm

hi,

I’m try to make my first automation but I’m to stupid :frowning:

Trigger is when my Alarm System changes to armed

then it should as action after sunset turn on some lamps ranomly.

my problem is when its not sunset now the automation is finished. how can I make that it checks every 5 mins the sunset state?

thank you

Paste your automation, that is always helpful.

alias: away
description: activate some lamps randomly
trigger:

  • platform: state
    entity_id:
    • alarm_control_panel.gigaset_elements
      to: armed_away
      condition:
      action:
  • condition: sun
    after: sunset
  • service: switch.turn_on
    entity_id: switch.lamp1
  • delay: 00:{{ range(0,10) | random | int }}:00

it should be if “sun” = sunset then activate the lamp

else retry in 5 min…

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?

action:
  - delay:
      minutes: '{{ range(0,10) | random }}'
  - service: switch.turn_on
    target:
      entity_id: switch.lamp1

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?

thanks,

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…