Design Pattern: Time Of Day

I doubt this would be caused by a configuration problem but to be sure check any custom ephemeris configs you have for corruption or weirdness.

Beyond the obvious, that it can’t find Jolly Day, I have no idea what could be the problem. If you are running the latest milestone or SNAPSHOT you should file an issue on openhab-core. If not you should try it out with the latest milestone or SNAPSHOT and see if the problem still persists. I can’t think of any way any configuration change you’ve made would cause this.

I dont have any custom ephemeris. The error message seems to trigger on startup. The log file shows that the TimeOfDay rule has been working fine since startup (more than 24 hours).

2021-06-20 23:11:41.127 [INFO ] [ab.ui.habpanel.internal.HABPanelTile] - Started HABPanel at /habpanel
2021-06-20 23:11:42.710 [INFO ] [e.automation.internal.RuleEngineImpl] - Rule engine started.
2021-06-20 23:11:46.170 [INFO ] [zwave.handler.ZWaveControllerHandler] - Attempting to add listener when controller is null
2021-06-20 23:11:51.349 [INFO ] [ve.internal.protocol.ZWaveController] - Starting ZWave controller
2021-06-20 23:11:51.351 [INFO ] [ve.internal.protocol.ZWaveController] - ZWave timeout is set to 5000ms. Soft reset is false.
2021-06-20 23:12:34.749 [WARN ] [de.jollyday.util.ClassLoadingUtil   ] - Could not load class with current threads context classloader. Using default. Reason: ClassNotFoundException: de
.jollyday.impl.DefaultHolidayManager cannot be found by
2021-06-20 23:12:34.763 [WARN ] [de.jollyday.util.ClassLoadingUtil   ] - Could not load class with current threads context classloader. Using default. Reason: ClassNotFoundException: de
.jollyday.datasource.impl.XmlFileDataSource cannot be found by
2021-06-20 23:12:34.783 [WARN ] [de.jollyday.util.XMLUtil            ] - Could not create JAXB context using the current threads context classloader. Falling back to ObjectFactory class
2021-06-20 23:12:34.905 [WARN ] [de.jollyday.util.ClassLoadingUtil   ] - Could not load class with current threads context classloader. Using default. Reason: ClassNotFoundException: de
.jollyday.parser.impl.FixedParser cannot be found by
2021-06-20 23:12:34.912 [WARN ] [de.jollyday.util.ClassLoadingUtil   ] - Could not load class with current threads context classloader. Using default. Reason: ClassNotFoundException: de
.jollyday.parser.impl.ChristianHolidayParser cannot be found by
2021-06-20 23:12:34.916 [WARN ] [de.jollyday.util.ClassLoadingUtil   ] - Could not load class with current threads context classloader. Using default. Reason: ClassNotFoundException: de
.jollyday.parser.impl.IslamicHolidayParser cannot be found by
2021-06-20 23:12:34.996 [INFO ] [openhab.model.script.Rules.TimeOfDay] - Today is a default day.
2021-06-20 23:13:06.018 [INFO ] [openhab.model.script.Rules.TimeOfDay] - The current time of day is BED
2021-06-20 23:30:00.024 [INFO ] [openhab.model.script.Rules.TimeOfDay] - Transitioning Time of Day from BED to NIGHT
2021-06-21 00:00:30.221 [INFO ] [openhab.model.script.Rules.TimeOfDay] - Today is a default day.
2021-06-21 00:00:30.362 [INFO ] [openhab.model.script.Rules.TimeOfDay] - Moved Default_Morning to today.
2021-06-21 00:00:30.381 [INFO ] [openhab.model.script.Rules.TimeOfDay] - Moved Default_Bed to today.
2021-06-21 00:00:30.427 [INFO ] [openhab.model.script.Rules.TimeOfDay] - Moved Default_Night to today.
2021-06-21 00:01:00.578 [INFO ] [openhab.model.script.Rules.TimeOfDay] - The current time of day is NIGHT
2021-06-21 00:01:00.683 [INFO ] [openhab.model.script.Rules.TimeOfDay] - Today is a default day.
2021-06-21 00:01:30.708 [INFO ] [openhab.model.script.Rules.TimeOfDay] - The current time of day is NIGHT
2021-06-21 05:00:00.002 [INFO ] [openhab.model.script.Rules.TimeOfDay] - Transitioning Time of Day from NIGHT to MORNING
2021-06-21 05:56:00.002 [INFO ] [openhab.model.script.Rules.TimeOfDay] - Transitioning Time of Day from MORNING to DAY
2021-06-21 10:53:56.777 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'livingroom.rules'
2021-06-21 18:46:00.002 [INFO ] [openhab.model.script.Rules.TimeOfDay] - Transitioning Time of Day from DAY to EVENING

I am running openhab 3.0.2-1 which is latest stable.

Your problems have nothing to do with the rule examples this thread is about.

This line, as a “global” definition -

populates your CurrentTime variable with a value only once, at rules file load time.
So far as I can see, you never update it, so yes it will stay the same.
This behaviour has not changed since OH2.
Wouldn’t you be interested in “now” at the time the rule runs?

When you’re ready, you might show us those.

I don’t know what your Zwave problems are about, but not related to this rule.

But it isn’t. It’s populated when the xxx.rules file is loaded. You’ve placed it outside of your rule.

See also

Quick question.
Would an Item that is already defined with { etod="MORNING"[type="default"] } be the same as the API where:

Namespace = etod

  "value": "MORNING",
  "config": {
    "type": "default"

? One of my day-types isn’t happening so I wonder if it is the metadata that is wrong and would like to update it via the api…

That metadata doesn’t look wrong but it’s hard to tell by just looking at the JSON like that.

If the metadata is present but not well formed then the rule will complain about that.

You can see which Items are being considered by the rule by turning up the logging to DEBUG when it runs. It will list all the Items it’s using for the day.

If you don’t get any errors and you don’t see your Item in the debug logs then for some reason the rule doesn’t see that Item at all. If you see errors then the error should tell you what’s wrong.

Oh I get it now… thanks :slight_smile:

I’m trying to get the javascript version running on my OH3.1 system. But when executing the script imported from ephemTimeOfDay.yml io get this error in openhab.log:

2021-07-18 11:23:15.674 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID '1d2a859923' failed: org.graalvm.polyglot.PolyglotException: ReferenceError: "scriptExtension" is not defined

I cleaned /etc/openhab/automation before installing all files mentioned in the at:

since i got some python and javascript fragments there, from trying some older OH2.5 examples. When looking at the javascript examples at:

it looks like i’m missing some really basic thing here since


is getting used there frequently and without mentioning any requirements?

I’m using the official .deb package on a Ubuntu 20 system if that matters…



Create a simple rule with a JavaScript script action. Just have it log something. Does that generate the same error?

This is something very fundamental wrong and not specific to this role I think. But if the error occurs even on a simple rule maybe not.

Logging into Karaf, would this line to the job? log:set DEBUG openhab.model.script.Rules.TimeOfDay

I still get no debug log, only info.

You’re missing the “org” part of the logger name.


Thanks for the reply - i’ve created this javascript script and it works:

var logger = Java.type("org.slf4j.LoggerFactory").getLogger("org.openhab.model.script.Rules.Examples");"Typing needed classes");

adding a line with:


raises the “ReferenceError” exception…

You are using the built in ECMAScript 5.1, not the GraalVM JavaScript addon? The above only works with the default JavaScript.

How do i select using the “default JavaScript”? When creating a script or rule i only have these options:

I tried the Blockly option where i switched to the code view and pasted the code and the ECMAScript option as well…

It appears that if you’ve installed the GraalVM JavaScript addon it replaces the default one. In other words, you can’t. If you do not plan on using the GraalVM JavaScript, don’t install it. If you do plan on using it you’ll have to rewrite the rule above to work with that.

Thank you for clarifying! After uninstalling the GraalVM addon and restarting openhab, the script is working finally!

You’ve also installed Jython and Groovy too. Do you have plans to use those? If not don’t install them. The more stuff you have installed the more opportunities there are for problems. Only install add-ons (and software for that matter) you intend to use. Don’t install stuff “just in case”.

Good advice - i will do so.

Logging debug-info worked and one “Time of day”-item was indeed missing. Instead of messing about with metadata in the API-explorer, I just created the item again with info from your github. Now it works fine. Thanks

I migrated from installation from armhf to arm64 today, and restored from backup. The java version is

$ java -version
openjdk version “16.0.2” 2021-07-20
OpenJDK Runtime Environment Zulu16.32+15-CA (build 16.0.2+7)
OpenJDK 64-Bit Server VM Zulu16.32+15-CA (build 16.0.2+7, mixed mode)

apt search zulu|grep installed

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

zulu-repo/now 1.0.0-2 all [installed,local]
zulu16-ca-doc/stable,now 16.0.2-1 arm64 [installed,automatic]
zulu16-ca-jdk/stable,now 16.0.2-1 arm64 [installed,automatic]
zulu16-ca-jdk-headless/stable,now 16.0.2-1 arm64 [installed,automatic]
zulu16-ca-jre/stable,now 16.0.2-1 arm64 [installed,automatic]
zulu16-ca-jre-headless/stable,now 16.0.2-1 arm64 [installed,automatic]
zulu16-doc/stable,now 16.0.2-1 arm64 [installed,automatic]
zulu16-jdk/stable,now 16.0.2-1 arm64 [installed]
zulu16-jdk-headless/stable,now 16.0.2-1 arm64 [installed,automatic]
zulu16-jre/stable,now 16.0.2-1 arm64 [installed,automatic]
zulu16-jre-headless/stable,now 16.0.2-1 arm64 [installed,automatic]

Every other rules seems to be ok except, the ones required here.

For ephemTimeOfDay I get,

Validation of rule 1bed65e3c8 has failed! Action Type “script.ScriptAction” does not exist!

Also my dsl rules show up as invalid. Any idea what could be the issue?