Endless automation - most elegant way to achieve it

I would like to create an automation that starts as soon as the HA service is started and never ends.
It has to toggle a Raspberry PI GPIO pin On and Off every second.
Is that possible ?

can’t imagine your usecase, some thoughts behind this would be nice (to prevent xy problem)
depending a bit how strict your timing and on off needs to be:

alias: do some repetitive
description: ''
mode: single
  - platform: time_pattern
    seconds: '2'
condition: []
  - type: turn_off
  - wait_template: '00:00:01'
  - type: turn_on
1 Like

This will be used as a sort of watchdog, to know if HA is alive.
For the moment I’m testing it with a plain RPi pin, but it will run with a I2C expander in the final project.
Thanks for your help, I will test it soon.

  platform: time_pattern
  seconds: "/1"
  service: switch.toggle
  entity_id: switch.your_gpio_switch
1 Like

Tested now, works like a charm!
It would be really nice to prevent this automation and the related entity from flooding the logbook.

You can exclude entities from the logbook https://www.home-assistant.io/integrations/logbook/#exclude

I’d advise you to exclude them from the recorder too. To prevent unnecessary inflation of your database.


Excellent! Done now. It works!
Thanks again for your prompt support