Time based trigger every hour

I have this:

    on_time:
      # Every hour when sun is up
      - seconds: 0
        minutes: /59
        then:
          - if:
              condition:
                and:
                  - sun.is_above_horizon:
                  - binary_sensor.is_off: disable_fish_feed
              then:
                - script.execute: dispense_food

but it’s a little messy.

I need it to run the script every hour. Every 59 minutes achieves the same thing, more or less, but how do I get it to every hour on the hour?

Is hour: /1 just at 01:00?

No, hour: /1 is every hour divisible by 1. So all of them. Unfortunately this is also true every second as you have not specified seconds and it defaults defaults to *. Same for minutes.

So you want:

   on_time:
      - seconds: 0
        minutes: 0

Which triggers at 00:00:00, 01:00:00, 02:00:00, 03:00:00, …etc

Or using cron:

    on_time:
      - cron: 0 * * * *

Other cron examples: Cron examples - Crontab.guru

2 Likes

Thank you. I would not have figured that!