You could just install it now. Time Based State Machine [3.2.0;3.4.9]
You just need to define the Items and set some metadata. Beyond the advantages of not needing to code anything at all, it supports adding and removing times of day without needing to change the code like this old old approach does.
As an alternative, OH now supports a DateTime trigger, as in Time is MorningStart timeOnly where MoringStart is a DateTime Item conataining the time you want your MORNING time of day to start. With that, you can just create a separate very simple rule for each time of day with that trigger (use the Items linked to the Astro Channels for those times) and command the time of day Item as required. (The timeOnly part tells it to ignore the date so it will trigger every day at that time.
I’m about 80% certain that was added before 3.3.
rule "morning"
when
Time is DayStart timeOnly
then
tod_TimeOfDay.sendCommand('MORNING')
end
rule "day"
when
Time is DayStart timeOnly
then
tod_TimeOfDay.sendCommand('DAY')
end
// and so on
Sooo much simpler than that old complicated rule which was only so complicated because it was a work around for things lacking in OH at the time, mainly the ability to trigger a rule based on a DateTime Item’s state and the ability to easily set the state of a DateTime Item from sitemaps (which will finally be somewhat possible as a single entry in OH 4.