Trigger pattern "minutes: /45" is executed twice per hour (solved)

I am trying to trigger an event every 45 minutes. Instead, it triggers every hour at X:00 and at X:45

Any idea, what is happening here and how to get the event to trigger every 45 minutes?

Thanks for your help!

alias: Test Event
description: ""
  - platform: time_pattern
    minutes: /45
  - condition: time
    after: "05:25:00"
    before: "21:35:00"
  - service: switch.turn_on
    metadata: {}
    data: {}
      entity_id: switch.tasmota
  - delay:
      hours: 0
      minutes: 5
      seconds: 0
      milliseconds: 0
  - service: switch.turn_off
    metadata: {}
    data: {}
      entity_id: switch.tasmota
mode: single

I am using

  • Core2024.6.1
  • Supervisor2024.06.0
  • Operating System12.3
  • Frontend20240605.0
1 Like

Please format your code.

Thank you for the reply and pointing out, that code was not formatted. I edited the post on my mobile phone and failed to use the preformatted text-button…

I created the automation using the GUI, but copied the code for completeness.

Also, I am well aware that this is not a forum for “hey - I got stuck on the very first try”-questions. I did research thoroughly on this matter for half an hour, read the documentation, watched YouTube videos and still get this unexpected result. I am looking for advice to get a true /45 pattern for my event, triggering e.g. at 0:45h, 1:30h, 2:15h…

I did not mean to imply that you hadn’t done any research, only that code is hard to read when it’s not formatted.

Regarding your issue: I’m afraid that is just how time_pattern works. It uses cron underneath the hood and it has that behaviour.

See the discussion here for a possible solution:


There isn’t a way to do this directly with the Time Pattern trigger.

It can be done with a Template trigger:

  - alias: "Every 45 minutes"
    platform: template
    value_template: "{{ (now().timestamp()/60)|int % 45 == 0}}"

If, for some reason, you want to select the start time you could use something like:

{% set start = '2024-01-01 00:00:00.0000' | as_datetime | as_local %}
{% set total_min = ((now() - start).total_seconds() | int / 60) %}
{{ total_min % 45 == 0 }}
1 Like

As outlined in the discussion I linked to…

Thank you very much to the both of you and for the advice, how to solve this.
By the way, the time pattern is documented, this was not clear to me.