Loop the entire automation

Hi, i try to automate a socket but i don’t succeed, what i want is that socket to turn off at each 20 minutes and have a delay of 20 seconds till turn on. After that i want that this automation to run again in loop.

The yaml scrypt look like this:

alias: Oprire/Pornire la 20 minute Centrala
description: ''
trigger:
  - platform: time_pattern
    minutes: '20'
condition:
  - condition: state
    entity_id: switch.priza_centrala_on_off
    state: 'on'
action:
  - type: turn_off
    device_id: 8e3b69149d68762a25141f90a251bdbf
    entity_id: switch.priza_centrala_on_off
    domain: switch
  - delay:
      hours: 0
      minutes: 0
      seconds: 20
      milliseconds: 0
  - type: turn_on
    device_id: 8e3b69149d68762a25141f90a251bdbf
    entity_id: switch.priza_centrala_on_off
    domain: switch
mode: single
max: 10

Thanks.

Should be:


trigger:
  - platform: time_pattern
    minutes: '/20'

1 Like

If you want 20 seconds, why is it 10 seconds in the automation?

      seconds: 10

It was a test with 10.

For future reference, when you ask people to correct your automation, post the automation that represents the requirements you described and not something else.

The documentation for the Time Pattern Trigger includes an example of how to make it repeat every X minutes. Here’s the relevant example:

  trigger:
    - platform: time_pattern
      # You can also match on interval. This will match every 5 minutes
      minutes: "/5"

That’s why rossk suggested you change it to '/20' in order to repeat every 20 minutes.

Thanks rossk , is working.

1 Like

Damn, easy boy, easy…

Yes, the documentation makes it easy.