Automation every 5 seconds

Hi!

I’d like to trigger an automation every 5 seconds.

    trigger:
      platform: time
      seconds: 5

But that does not seem to work. How is it done correctly?

you want: seconds: '/5'

I believe that will only trigger only every 10 seconds, since it is testing whether seconds/5 = True.
Btw is this working?

Not sure what you mean, 5 seconds is divisible by 5 as is 10 as is 15…

… true! It’s working for you? My automation wasn’t triggering using this approach

I have several time based automatons that work fine for me. Probably would need to see your config to help.

1 Like

The automation (note I can trigger the python_script manually so no problems there):

- id: Update_indoor_temperature
  alias: Update indoor temperature
  trigger:
    platform: time
    seconds: '/5'
  action:
  - service: python_script.home_temperature

I have a similar automation triggering a python_script on a state change at that works no problem so not sure what the issue is here…
Cheers

Try indenting - service

- id: Update_indoor_temperature
  alias: Update indoor temperature
  trigger:
    platform: time
    seconds: '/5'
  action:
    - service: python_script.home_temperature

Thanks but unfortunately this didn’t fix it. Also my other automation works both with and without the indentation

Hmm not sure…
Maybe drop the ID property, (shot in the dark can’t find if that’s supported or not, but I don’t use it)

Make sure the automation is actually on/enabled

Other than that I got nothing since you said triggering manually executes the script.

1 Like

I know this thread is old, but for anyone who happens across it, like I had a few times when searching to remind myself of how to get an automation running every X seconds (Google is favoring it), I’ll post the solution.

I think the answer (or maybe just a change in versions) is that platform needs to be “time_pattern”. The platform for “time” is for a specific time. “time_pattern” is for cron-like components.

- id: Update_indoor_temperature
  alias: Update indoor temperature
  trigger:
    platform: time_pattern
    seconds: '/5'
  action:
  - service: python_script.home_temperature
3 Likes

It’s now right in Docs, no goooogling needed :wink:

This was changed about 2 months ago, prior to that the original solution was correct.