Creating Capabilities with Rule Templates: Time of Day

Thanks very much for your valuable input.
I traced through the logs and found that the three items relating to the errors were missing from a certain point in time which related to me removing them from the ‘model’ and adding them again with the ToD_DAY format to get the transition rule to work as it had been splitting the item incorrectly as per the entries below.

[openhab.event.ItemStateChangedEvent ] - Item 'TimeOfDay' changed from BED to Rise
[openhab.event.ItemStateChangedEvent ] - Item 'TimeOfDay' changed from Rise to StartTime
[openhab.event.ItemStateChangedEvent ] - Item 'TimeOfDay' changed from StartTime to Set

I am presuming that all worked after changing the items as the timers were all running and I only noticed the issue in the log after the reboot.

I am wondering if adding the local sun as equipment into the model messed with the item names.

I will now go through your setup process after removing and adding the local sun again without using the model.
I will post an update once I have finished.

On another topic, in the UI rules, how would I do a replace on multiple special characters, a [ and ] (I want to remove them). I can do it using regex with normal characters but couldn’t find anywhere to assist with these characters. My rule has a replace line for each of the characters which works fine but would love to simplify it. I am using a tag in a proxy timer item to give me a link to the correct item to process.

Once again, thanks for your assistance, greatly appreciated.

The names of Item are independent from the model. The model only works with tags and Group membership.

To use a regex on characters that have special meaning to the regex, you need to escape the character: \[, \], etc. But, because you are running a script and these characters also have special meaning in the script, sometimes you have to double escape them: \\[, \\], etc.

Or you can just use mystring.replace('[', '');.

Hi Rich, thanks for your input.
I found that the three manager rules for the astro events had the incorrect items so deleted them and added them again and the ran the rules without any errors. I now have to wait until tomorrow to see if they are working ok.

Regarding the regex, I tried all types of combinations to get it to work, either side of the square bracket, [ or ], and any other character worked ok but the moment I added both sides of the square brackets it only did the one. I’ll stick to the 2 step as it does the job just as well.

I will pop an update tomorrow as to how things went.

Once again, really appreciate the time and effort that you put into the openHAB community. You have been providing me with solutions from the very beginning of my time with home automation.
Thanks
Gordy

Hi Rich, The time of day rules are working as expected now. I ended up deleting the ToD manager rules for the astro items and re-adding them and all has worked ok since then.

Thanks again
Gordy

Hi

I’m run OH 3.3 on ubunut 22.04

I have followed this tutorial.
My astro item (rlkoshak’s ToD_EVENING item) works perfect with astro time.

My night item (rlkoshak’s ToD_BED item) with a fixed time works but when I restart my computer, it becomes NULL. I use the built in calendar that popup and set a new fixed time, restart, the item becomes NULL again.

The item I’m using is a date/time item with rlk_datetime_standalone widget.

Second
I have a second item, a alarm clock, which is date/time item with rlk_datetime_standalone widget. The popup calendar works on a computer, but on iPhone/iPad, the calendar will not popup (the calendar icon does not appear). What do I have to do, to set time on my alarm clock item with my iPhone/iPad?

Thanks!

Is that Item configured to be restored on startup from Persistence? It would appear that it isn’t. See Persistence | openHAB for more details.

What renders the date time picker is the browser. There is nothing I have control over there. There might be something the devs of MainUI can do so file an issue.

In the mean time, you can manually type the date time in instead of using the date time picker.

Hi

I followed the instructions above as best I could. If I follow the values of the ToD items for a few days now they work as expected except the Item “Time of day”. This one remains “NULL”.
image

What could be the cause of this?

Which approach did you follow, No Code or Fewer Rules?

Note, this tutorial is a little bit out of date. The Alarm Clock Rule is no longer required. You can trigger a rule now with the state of a Date Time Item. So when you follow the “Crete the Transition Rules” section, also add a trigger to those Rules using a Time trigger with “at a time specified in a given Item’s state” and select the DateTime Item that specifies when that time of day should start.

You can choose whether to ignore the date part of the DateTime which frees you from needing the To Today rule template too.

Then you don’t need to instantiate any rules using the templates. No Alarm Clock nor To Today rules are required any more.

Hi Rich,

I use No Code.

Do you mean the “mgr” rules are no longer needed?

Should the word AFTERNOON at Command be placed in between quotation marks: “AFTERNOON”?

Correct. All those rules do is call the rules you created in the first step at the right time. That’s now built into OH with the new(ish) time trigger that uses the DateTime Item’s state. All you need to do is add a trigger to rules in the first step.

No, quotes are not required.

Like this:

(My english is probably not good enough to understand you completely)

Nov-01-2022 07-15-11

Thanks,
This works.

Hi, I’m not seeing the Time Only section at the bottom of the selection window?
Any ideas?
V3.3.0

At the bottom of what selection window?

it’s ok , i upgraded and i can now see the option.
cheers