# Time of Day - Cron every minute or at fixed times

**URL:** <https://community.openhab.org/t/time-of-day-cron-every-minute-or-at-fixed-times/139143>\
**Category:** Scripts & Rules\
**Created:** [September 20, 2022, 5:08pm UTC](https://community.openhab.org/t/time-of-day-cron-every-minute-or-at-fixed-times/139143 "2022-09-20T17:08:20Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [September 20, 2022, 10:34pm UTC](https://community.openhab.org/t/time-of-day-cron-every-minute-or-at-fixed-times/139143/10 "2022-09-20T22:34:39Z")

</div>

> [@MadFrankie](#):
>
> Part laziness in me having to add one trigger rather than multiple and also part with an eye to easy future code knowing that I just need to add new if statements and not worry about the trigger if it runs every minute.

One advantage to the separate triggers instead of one per minute is if you add the “Schedule” tag to your rule, it will show up on the calendar on the Schedule page in MainUI showing you when the rule will run and therefore show you graphically when your times of day transition. If you run it every minute that won’t work.

One other approach which is a little more configuration but might give you more flexibility would be to use the [Time Based State Machine [3.2.0;3.4.9]](https://community.openhab.org/t/time-based-state-machine/128245). Where this gives you more flexibility is:

- you don’t have to write any rules code at all, all you need is a set of DateTime Items with some metadata, and a Group
- you can use [DateTime List Item](https://community.openhab.org/t/datetime-list-item/127967) and [DateTime Standalone Widget](https://community.openhab.org/t/datetime-standalone-widget/127966) to set your fixed times of day from MainUI. That means you and/or your family could have the option to change the schedule without needing to modify rules. The schedule is all held in Item states.
- you have the option to have a different set of times set for different types of day (weekdays, weekends, hoilidays, etc.).

For static Items, you might also need [To Today [3.2.0;3.4.9)](https://community.openhab.org/t/to-today/127921) to move the date times that don’t come from Astro or other sources forward at to the current day at midnight.

> [@JustinG](#):
>
> For my ToD system, I use a different rule for each change so that rule can be customized to the event that most closely matches. For some, that’s just astro daylight events (afternoon → evening), but others might be based on house activity (evening → bedtime) or even multiple different factors such as phone alarm or set time which ever comes first (night → wake up).

Don’t miss the new `Time is <item>` rule trigger. I suspect you might be able to apply that to your system.

Speaking of that new trigger, @MadFrankie, if your timing needs are simple and you don’t need the Time based State Machine, perhaps still using a set of DateTime Items (with the DateTime widgets for the fixed times of day) and separate super simple rules using that `Time is <item>` trigger to transition would be the best balance between flexibility and simplicity. I don’t know if these rules will currently show up on the Schedule but bet they will eventually. Then you can see not only when your transitions between times of day are, but what the transitions are (assuming you name your rules well).

---

_[View the full topic](https://community.openhab.org/t/time-of-day-cron-every-minute-or-at-fixed-times/139143)._
