Automation 'n' times an hour

Hi!

I’m looking for a way to turn on/off a switch ‘n’ times an hour (n=17 for example, so it’s 60%n!=0)

Is there a way to do this?

Thank you in advance!

‘n’ times an hour would be <current_minute>%(60//n) == 0.

You can do this using sensor.time. (See Date & Time Sensor.)

{{ states('sensor.time').split(':')[1]|int%(60//n) == 0 }}

n, of course, has to come from somewhere. If, e.g., it was an input_number, then you’d do this before the above:

{% set n = states('input_number.n')|int %}
1 Like

Like a time based trigger maybe?

automation 3:
  trigger:
    platform: time
    # You can also match on interval. This will match every 5 minutes
    minutes: '/5'
    seconds: 00

I assumed @Sumi would want to be able to control the ‘n’. But if not, then yeah, a simple time trigger would work.

Can you use a data_template with the time trigger? I suspect not, but that could be a cool way to implement a input_number for “n.”

Thank you very much for the inputs so far, I really appreciate them!

What I would like is a bit more complex. I’d like an automation that would trigger ‘n’ times a minute, where n is let’s say 17, and evenly distributed in a minute. So if n = 17, then it would trigger every ~3.5294 seconds. If n = 45, it would trigger every ~1.334 seconds, and so on. ‘n’ doesn’t have to be adjustable from the interface, it’s okay if it is hard coded into the config, but the trigger “seconds” are not integers, but floats. So (minute % n IS NOT zero)

I don’t think you can do this. From everything I’ve seen, HA’s resolution for running time-based events is one second.

Thank you! Yeah, that was what I thought as well:(

Sorry, does it means something more than at zero second? I mean “‘’'” marks.

No, it means I messed up the formatting when I posted :man_facepalming:

Fixed it now