Repeat automation if necessary

Hi, pretty new to this. I have added 5 outdoor plugs to my instance and created an automation to turn them all on 30 minutes after sunset. I noticed manually triggering the items results in some of them not turning on. Some of them are kind of far away from my router so I’m guessing that’s why. Usually triggering again will fix any remaining ones that didn’t turn on the first time. What’s the most efficient way of repeating the automation if any have failed? Here’s my script in case it helps

  alias: Christmas Lights On
  description: ''
  trigger:
  - event: sunset
    offset: +00:30:00
    platform: sun
  condition: []
  action:
  - device_id: 596fde4a7a444f19a998cb238134fa41
    domain: switch
    entity_id: switch.front_door_left
    type: turn_on
  - device_id: 596fde4a7a444f19a998cb238134fa41
    domain: switch
    entity_id: switch.front_door_right
    type: turn_on
  - device_id: ebde72a0b2b04e5386cabec781c1b950
    domain: switch
    entity_id: switch.front_yard_left
    type: turn_on
  - device_id: ebde72a0b2b04e5386cabec781c1b950
    domain: switch
    entity_id: switch.front_yard_right
    type: turn_on
  - device_id: d98cf020b4704f94bf8655da66261685
    domain: switch
    entity_id: switch.side_yard_ground_left
    type: turn_on
  - device_id: d98cf020b4704f94bf8655da66261685
    domain: switch
    entity_id: switch.side_yard_ground_right
    type: turn_on
  - device_id: 1060a7555c284aeb9c2beb3036fdc687
    domain: switch
    entity_id: switch.side_yard_roof_left
    type: turn_on
  - device_id: 1060a7555c284aeb9c2beb3036fdc687
    domain: switch
    entity_id: switch.side_yard_roof_right
    type: turn_on
  - device_id: a0a1a26aae37479c858211dbc73c0bb4
    domain: switch
    entity_id: switch.backyard_left
    type: turn_on
  - device_id: a0a1a26aae37479c858211dbc73c0bb4
    domain: switch
    entity_id: switch.backyard_right
    type: turn_on

You don’t mention what platform ?

What happens when you trigger them one by one ?

What you could do is delay 1 second between each switch

I have some lights that can do this… So I just trigger them another 2 times in the automation… I have a failsafe automation that is triggered when the state of a light changes. My lights don’t provide any feedback (limitlessled). It looks like this:

- id: '1532478833427'
  alias: Lights On Failsafe
  trigger:
  - platform: state
    from: 'off'
    to: 'on'
    entity_id: light.lounge, light.dining, light.desk, light.office
  condition: []
  action:
  - delay: '00:00:02'
  - service: light.turn_on
    data_template:
      entity_id: '{%- if (as_timestamp(now()) - as_timestamp(states.light.lounge.last_changed)
        < 5) and (as_timestamp(now()) - as_timestamp(states.light.desk.last_changed)
        < 5) -%} light.lounge, light.desk {%- elif (as_timestamp(now()) - as_timestamp(states.light.office.last_changed)
        < 5) and (as_timestamp(now()) - as_timestamp(states.light.desk.last_changed)
        < 5) -%} light.office, light.desk {%- elif (as_timestamp(now()) - as_timestamp(states.light.desk.last_changed)
        < 5) -%} light.desk {%- elif (as_timestamp(now()) - as_timestamp(states.light.office.last_changed)
        < 5) -%} light.office {%- elif (as_timestamp(now()) - as_timestamp(states.light.lounge.last_changed)
        < 5) -%} light.lounge {%- else -%} light.dining {%- endif -%}'
      brightness: 191   #brightness_pct: 75
      color_temp: 322   #kelvin: 3100
  - delay: '00:00:05'
  - service: light.turn_on
    data_template:
      entity_id: '{%- if (as_timestamp(now()) - as_timestamp(states.light.lounge.last_changed)
        < 10) and (as_timestamp(now()) - as_timestamp(states.light.desk.last_changed)
        < 10) -%} light.lounge, light.desk {%- elif (as_timestamp(now()) - as_timestamp(states.light.office.last_changed)
        < 10) and (as_timestamp(now()) - as_timestamp(states.light.desk.last_changed)
        < 10) -%} light.office, light.desk {%- elif (as_timestamp(now()) - as_timestamp(states.light.desk.last_changed)
        < 10) -%} light.desk {%- elif (as_timestamp(now()) - as_timestamp(states.light.office.last_changed)
        < 10) -%} light.office {%- elif (as_timestamp(now()) - as_timestamp(states.light.lounge.last_changed)
        < 10) -%} light.lounge {%- else -%} light.dining {%- endif -%}'
      brightness: 191   #brightness_pct: 75
      color_temp: 322   #kelvin: 3100

I’m not sure how to do it, or if it’s even possible, using the device automation editor.

If you used a regular automation then you could easily trigger the automation normally the first time then at the end of the action of that automation give a small delay of a second or so then just call the automation.trigger service on itself so it runs the actions a second time.

Not sure what you mean, wouldn’t that put itself in a loop? I’m really new to this, any guidance would be appreciated

I managed to figure it out. What I did was to create a script to turn on all the lights. Basically the script is the same as my automation was. Then I created a new automation that called the script, waited 5 seconds, and then called the script again.

1 Like

Crap! Yeah, in my mind i wzs actually thinking of doing the same thing that you ended up doing (calling the actions you wanted, wait a few seconds then calling those same actions again) but within the same automation action section. I’m not sure why I wrote to trigger the automation again. Of course that would be bad.

I’m glad you listened to what I meant And not what I said.

1 Like