Time-Triggered Automation, not fire as should be expected

Time-Triggered Automation, not fire as should be expected, I put an interval of 5 hours but instead, as you can see in the screenshot, he fire every day at 5 am and/or pm (wtf)

image

here the yaml:

id: '1676675534738'
alias: WebOS Dev AutoRenewal
description: ''
trigger:
  - platform: time_pattern
    hours: '5'
  - platform: homeassistant
    event: start
condition: []
action:
  - service: webhook_service.basic_webhook
    data:
      webhook: >-
        xxxxxxx
mode: single

Your automation is designed to trigger at 05:00:00 or when Home Assistant starts.

The screenshot you posted, displaying a list of times for the last 5 traces that were produced, shows that it triggered four times at 05:00:00, corresponding to the Time Pattern Trigger, and once at 17:20:15 which probably corresponds to when Home Assistant was restarted.

Check the trace produced at 17:20:15 and it will reveal which of the automation’s two triggers was responsible for triggering the automation. It’s likely to be the Home Assistant Event Trigger.

my fault, the 5pm one is a manual startup made by me😅, the problem still remains that instead of starting every 5 hours it starts every day at 5

That’s because you configured to operate that way.

Change it to this:

  - platform: time_pattern
    hours: '/5'

Reference: Time Pattern Trigger

1 Like

This trigger fires whenever the hour = 5

trigger:
  - platform: time_pattern
    hours: '5'

This trigger fires whenever the hour is divisible by 5:

trigger:
  - platform: time_pattern
    hours: '/5'

See: https://www.home-assistant.io/docs/automation/trigger/#time-pattern-trigger

1 Like

I created it via ui, it’s not exactly crystal clear to do it from the ui, however I will try :+1:

For future reference, creating automations with the UI doesn’t always support everything that Home Assistant’s scripting language can do. Even when the UI does support a given scripting feature, it might only support it partially and require that you switch to YAML mode to support it fully or assumes you already know what you can/can’t enter.

In this particular case, the UI doesn’t provide much guidance and assumes you are already familiar with the Time Pattern Trigger and know what to enter in the Hours field.

Screenshot_20230222-083106~2

This trigger fires whenever the hour is divisible by 5

You really need to take note of that statement. That is also confusing.

the trigger only occurs when the hour is divisible by 5 NOT every 5 hours.

so it will trigger at 00:00, 05:00, 10:00, 15:00, 20:00 then it will fire again at 00:00, etc…

At least I’m fairly certain that’s the case.

(Sorry Tom I didn’t mean to reply to you it was meant for the OP)

Yes that is correct.

Sorry I didn’t mean to reply to you. It was for the OP

Yeah, I was just letting you know that any doubts you had about what you were saying were unfounded.

The issue here is that 24 is not evenly divisible by 5. So a time pattern trigger won’t work. An alternative method is required. Maybe a timer.

Agreed.

This hours: '/5' will certainly get the OP closer to triggering every 5 hours than this hours: '5' but not completely; the final period of each day will be 4 hours owing to the way the Time Pattern Trigger computes repeating intervals.

Every five hours, at the top of the hour. Change the final 0 in the condition to line it up with the hour you want: can be any integer from 0 to 4.

trigger:
  - platform: time_pattern
    minutes: '0'
condition:
  - "{{ (now().timestamp()//3600)%5 == 0 }}"
1 Like

so summarizing there are no real “every x hours,” but a “every fifth/fourth/third/etc of day/hour/etc” right?

Here’s the way the documentation explains it:

You can prefix the value with a / to match whenever the value is divisible by that number.

In your case, the time interval you specified is hours: '/5' so that means it will trigger when the current hour is divisible by 5. What that implies is the current hour must be evenly divisible (no remainder) by the value 5.

0/5 = 0
5/5 = 1
10/5 = 2
15/5 = 3
20/5 = 4

So, like finity explained, it will trigger when the current hour is 0, 5, 10, 15, and 20. That’s 5 hours apart except for the period between 20:00 and 00:00.