[Deprecated] Design Pattern: Time Of Day

Ok, i checked it at one of the items and the custom meta data was avaible:

value: BED
config:
  type: custom
  file: /openhab/conf/services/custom1.xml

I created this path now comming from root directory and copied custom1.xml to it.
Now i get a warning instead of an error:

19:37:18.730 [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 org.apache.aries.jax.rs.whiteboard_1.0.9
19:37:18.734 [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 org.apache.aries.jax.rs.whiteboard_1.0.9
19:37:18.744 [WARN ] [de.jollyday.util.XMLUtil             ] - Could not create JAXB context using the current threads context classloader. Falling back to ObjectFactory class classloader.
19:37:18.782 [WARN ] [re.automation.internal.RuleEngineImpl] - Fail to execute action: 3
java.lang.IllegalStateException: Cannot instantiate configuration from URL 'file:/openhab/conf/services/custom1.xml'.
        at de.jollyday.datasource.impl.XmlFileDataSource.getConfiguration(XmlFileDataSource.java:43) ~[?:?]
        at de.jollyday.impl.DefaultHolidayManager.doInit(DefaultHolidayManager.java:209) ~[?:?]
        at de.jollyday.HolidayManager.init(HolidayManager.java:319) ~[?:?]
        at de.jollyday.caching.HolidayManagerValueHandler.createValue(HolidayManagerValueHandler.java:44) ~[?:?]
        at de.jollyday.caching.HolidayManagerValueHandler.createValue(HolidayManagerValueHandler.java:13) ~[?:?]
        at de.jollyday.util.Cache.lambda$get$0(Cache.java:43) ~[?:?]
        at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705) ~[?:?]
        at de.jollyday.util.Cache.get(Cache.java:43) ~[?:?]
        at de.jollyday.HolidayManager.createManager(HolidayManager.java:166) ~[?:?]
        at de.jollyday.HolidayManager.getInstance(HolidayManager.java:146) ~[?:?]
        at org.openhab.core.ephemeris.internal.EphemerisManagerImpl.getHolidayManager(EphemerisManagerImpl.java:235) ~[?:?]
        at org.openhab.core.ephemeris.internal.EphemerisManagerImpl.isBankHoliday(EphemerisManagerImpl.java:284) ~[?:?]
        at org.openhab.core.ephemeris.internal.EphemerisManagerImpl.isBankHoliday(EphemerisManagerImpl.java:289) ~[?:?]
        at org.openhab.core.model.script.actions.Ephemeris.isBankHoliday(Ephemeris.java:91) ~[?:?]
        at org.openhab.core.model.script.actions.Ephemeris.isBankHoliday(Ephemeris.java:85) ~[?:?]
        at jdk.nashorn.internal.scripts.Script$Recompilation$108$5426A$\^eval\_.getTodayItems#custom(<eval>:124) ~[?:?]
        at jdk.nashorn.javaadapters.java_util_function_Predicate.test(Unknown Source) ~[?:?]
        at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:176) ~[?:?]
        at java.util.Iterator.forEachRemaining(Iterator.java:133) ~[?:?]
        at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) ~[?:?]
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[?:?]
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[?:?]
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:550) ~[?:?]
        at java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260) ~[?:?]
        at java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:517) ~[?:?]
        at java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:523) ~[?:?]
        at jdk.nashorn.internal.scripts.Script$Recompilation$109$4398A$\^eval\_.getTodayItems(<eval>:121) ~[?:?]
        at jdk.nashorn.internal.scripts.Script$Recompilation$128$\^eval\_.:program(<eval>:260) ~[?:?]
        at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:655) ~[jdk.scripting.nashorn:?]
        at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:513) ~[jdk.scripting.nashorn:?]
        at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:527) ~[jdk.scripting.nashorn:?]
        at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:456) ~[jdk.scripting.nashorn:?]
        at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:413) ~[jdk.scripting.nashorn:?]
        at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:409) ~[jdk.scripting.nashorn:?]
        at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:162) ~[jdk.scripting.nashorn:?]
        at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264) ~[java.scripting:?]
        at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.lambda$0(ScriptActionHandler.java:62) ~[?:?]
        at java.util.Optional.ifPresent(Optional.java:183) ~[?:?]
        at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.execute(ScriptActionHandler.java:59) ~[?:?]
        at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1179) [bundleFile:?]
        at org.openhab.core.automation.internal.RuleEngineImpl.runNow(RuleEngineImpl.java:1031) [bundleFile:?]
        at org.openhab.core.automation.internal.RuleEngineImpl.runNow(RuleEngineImpl.java:1047) [bundleFile:?]
        at org.openhab.core.automation.rest.internal.RuleResource.runNow(RuleResource.java:314) [bundleFile:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
        at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179) [bundleFile:1.0.9]
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) [bundleFile:1.0.9]
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:201) [bundleFile:1.0.9]
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:104) [bundleFile:1.0.9]
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) [bundleFile:1.0.9]
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96) [bundleFile:1.0.9]
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) [bundleFile:1.0.9]
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) [bundleFile:1.0.9]
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267) [bundleFile:1.0.9]
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234) [bundleFile:1.0.9]
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) [bundleFile:1.0.9]
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160) [bundleFile:1.0.9]
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:216) [bundleFile:1.0.9]
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301) [bundleFile:1.0.9]
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:220) [bundleFile:1.0.9]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) [bundleFile:3.1.0]
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:276) [bundleFile:1.0.9]
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:852) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:544) [bundleFile:9.4.20.v20190813]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71) [bundleFile:?]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:536) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1581) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1307) [bundleFile:9.4.20.v20190813]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:293) [bundleFile:?]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:482) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1204) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [bundleFile:9.4.20.v20190813]
        at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80) [bundleFile:?]
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.Server.handle(Server.java:494) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.onFillable(SslConnection.java:426) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:320) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.io.ssl.SslConnection$2.succeeded(SslConnection.java:158) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:367) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918) [bundleFile:9.4.20.v20190813]
        at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.lang.IllegalStateException: Cannot parse holidays XML file.
        at de.jollyday.util.XMLUtil.unmarshallConfiguration(XMLUtil.java:75) ~[?:?]
        at de.jollyday.datasource.impl.XmlFileDataSource.getConfiguration(XmlFileDataSource.java:41) ~[?:?]
        ... 100 more
Caused by: javax.xml.bind.UnmarshalException
        at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:310) ~[jakarta.xml.bind-api-2.3.2.jar:2.3.2]
        at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:548) ~[jaxb-runtime-2.3.2.jar:2.3.2]
        at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:234) ~[jaxb-runtime-2.3.2.jar:2.3.2]
        at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:199) ~[jaxb-runtime-2.3.2.jar:2.3.2]
        at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:140) ~[jakarta.xml.bind-api-2.3.2.jar:2.3.2]
        at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:179) ~[jakarta.xml.bind-api-2.3.2.jar:2.3.2]
        at de.jollyday.util.XMLUtil.unmarshallConfiguration(XMLUtil.java:72) ~[?:?]
        at de.jollyday.datasource.impl.XmlFileDataSource.getConfiguration(XmlFileDataSource.java:41) ~[?:?]
        ... 100 more
Caused by: org.xml.sax.SAXParseException: Content ist nicht zulässig in Prolog.
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204) ~[?:?]
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:178) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1471) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:978) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:534) ~[?:?]
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:888) ~[?:?]
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824) ~[?:?]
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) ~[?:?]
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1216) ~[?:?]
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:635) ~[?:?]
        at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:228) ~[jaxb-runtime-2.3.2.jar:2.3.2]
        at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:199) ~[jaxb-runtime-2.3.2.jar:2.3.2]
        at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:140) ~[jakarta.xml.bind-api-2.3.2.jar:2.3.2]
        at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:179) ~[jakarta.xml.bind-api-2.3.2.jar:2.3.2]
        at de.jollyday.util.XMLUtil.unmarshallConfiguration(XMLUtil.java:72) ~[?:?]
        at de.jollyday.datasource.impl.XmlFileDataSource.getConfiguration(XmlFileDataSource.java:41) ~[?:?]
        ... 100 more
19:37:19.800 [WARN ] [ommon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception: 
java.lang.NumberFormatException: For input string: "o Preset"
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[?:?]
        at java.lang.Integer.parseInt(Integer.java:652) ~[?:?]
        at java.lang.Integer.parseInt(Integer.java:770) ~[?:?]
        at org.openhab.binding.yamahareceiver.internal.protocol.xml.InputWithPresetControlXML.convertToPresetNumber(InputWithPresetControlXML.java:157) ~[?:?]
        at org.openhab.binding.yamahareceiver.internal.protocol.xml.InputWithPresetControlXML.update(InputWithPresetControlXML.java:123) ~[?:?]
        at org.openhab.binding.yamahareceiver.internal.handler.YamahaZoneThingHandler.lambda$2(YamahaZoneThingHandler.java:725) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
        at java.lang.Thread.run(Thread.java:834) [?:?]

Well, you changed one of the Items. There are two more to go.

No, i did not change the item, the meta data was already saved (at all items).

Let’s take a step back here because by this point what you need to do should be obvious. There must be some basic and fundamental misunderstanding on how openHAB works.

openHAB has Items. Items can be defined in .items files or through the UI. You’ve create the Items in the UI.

Items can have metadata. Metadata is used to add a little extra information on an Item to do various things. In this case the etod metadata is added to the Item so the rule knows how to use that Item.

When you imported the Items from the examples above, those Item definitions included etod metadata. They would be pretty bad examples if they didn’t.

However, for the custom holiday Items, the path to the custom XML file is different than the path to where you put the custom holiday XML file.

Notice how three of those Items have the custom holiday etod metadata. Notice how all three of them are using a path different from the path in your system.

So you need to go to each of the three Items that use the custom holiday XML file and update the metadata to use the correct path to the XML file on your system.

And again, if you have no use for custom defined holidays just delete those Items. You don’t need them. They are just examples for how to use them.

Ultimately you need to create your own sets of Items with your own times of days and start times. If you are coming from the Rules DSL version of the rule, all you need are the default set of DateTime Items to reproduce the same behavior.

Thank you, i think that pointed me to the problem:
I imported the complete item list from above and didnt recognize, that some itemnames are mentioned multiple times and at the import the meta data from the last version was stored and so the url got into the meta data - but not at the holiday item but in the weekend item.

Before I create the items all over again, one more question for understanding…
Is it correct, that i have to create a set of items for every type/dayset, like this?

DateTime Default_Morning (TimesOfDay) { etod="MORNING"[type="default"] }
DateTime Default_Day (TimesOfDay) { channel="astro:sun:set120:set#start", etod="DAY"[type="default"] }
DateTime Default_Evening (TimesOfDay) { channel="astro:sun:local:set#start", etod="EVENING"[type="default"] }
DateTime Default_Night (TimesOfDay) { etod="NIGHT"[type="default"] }
DateTime Default_Bed (TimesOfDay) { etod="BED"[type="default"] }

DateTime Weekend_Morning (TimesOfDay) { etod="MORNING"[type="weekend"] }
DateTime Weekend_Day (TimesOfDay) { channel="astro:sun:set120:set#start", etod="DAY"[type="weekend"] }
DateTime Weekend_Evening (TimesOfDay) { channel="astro:sun:local:set#start", etod="EVENING"[type="weekend"] }
DateTime Weekend_Night (TimesOfDay) { etod="NIGHT"[type="weekend"] }
DateTime Weekend_Bed (TimesOfDay) { etod="BED"[type="weekend"] }

Optional:
DateTime Holiday_Morning (TimesOfDay) { etod="MORNING"[type="holiday"] }
DateTime Holiday_Day (TimesOfDay) { channel="astro:sun:set120:set#start", etod="DAY"[type="holiday"] }
DateTime Holiday_Evening (TimesOfDay) { channel="astro:sun:local:set#start", etod="EVENING"[type="holiday"] }
DateTime Holiday_Night (TimesOfDay) { etod="NIGHT"[type="holiday"] }
DateTime Holiday_Bed (TimesOfDay) { etod="BED"[type="holiday"] }

Edit: Tried it out and it works fine now! Thank you for your help and your patience!

There is just one question open, right now: Can i define the holiday state also with an item instead of an xml? I have already a switch item in use to de/active the holiday mode at home.

Thanks again!

What you posted is the .items file. If you are going to create the items through the UI, you’ll have to edit the metadata manually like Rich said.
So I’m not entirely sure which way you want to go.

Thanks, but meta data was importet successfully by import with textual definition.

Yes.

No. But you can use the Ephemeris actions to determine if it’s a holiday instead of your Switch Item. Or you can use Ephemeris to set your Switch Item.

But the Time of Day rule only works with Ephemeris.

Right, but the imported metadata was not correct for your system. So you’d have to modify that metadata to be correct for your system.

Ok I understand. The idea of my holiday switch is to activate it when I’m on vacation. But this is more about general holidays?

Yes, that’s why it’s called “holiday” and the actions are called things like “isBankHoliday()”. It’s purpose is to mark of those days which are nationally/regionally scheduled days off. I know that the term “holiday” means “vacation” in some parts of the world and the term “bank holiday” is mostly used in the UK, but those are the terms the developers chose.

These are intended to cover single days which are typically off work days. I do not think that holidays that usually occur on a weekend are always included in the default list.

1 Like

Ok, now that the “normal” days are working, I couldn’t stop trying around with the holidays.
I have created a file /etc/openhab/services/holidays_de.xml:

<?xml version="1.0" encoding="UTF-8"?>
<tns:Configuration hierarchy="de" description="Germany" xmlns:tns="http://www.example.org/Holiday"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://www.example.org/Holiday /Holiday.xsd">
    <tns:Holidays>
        <tns:Fixed month="JANUARY" day="1" descriptionPropertiesKey="Neujahr"/>
        <tns:Fixed month="MAY" day="1" descriptionPropertiesKey="Tag der Arbeit"/>
        <tns:Fixed month="OCTOBER" day="3" validFrom="1990"
                   descriptionPropertiesKey="Tag der dt. Einheit"/><!-- Tag der Deutschen Einheit ab 1990 -->
        <tns:Fixed month="DECEMBER" day="25" descriptionPropertiesKey="1. Weihnachtstag"/>
        <tns:Fixed month="DECEMBER" day="26" descriptionPropertiesKey="2. Weihnachtstag"/>
        <tns:ChristianHoliday type="GOOD_FRIDAY"/>
        <tns:ChristianHoliday type="EASTER_MONDAY"/>
        <tns:ChristianHoliday type="ASCENSION_DAY"/>
        <tns:ChristianHoliday type="WHIT_MONDAY"/>
    </tns:Holidays>
    <tns:SubConfigurations hierarchy="ni" description="Niedersachsen">
        <tns:Holidays>
            <tns:Fixed month="OCTOBER" day="31" descriptionPropertiesKey="Reformationstag" validFrom="2018"/>
            <tns:Fixed month="APRIL" day="04" descriptionPropertiesKey="Test" validFrom="2018"/>
        </tns:Holidays>
    </tns:SubConfigurations>
</tns:Configuration>

Then I added the path to the meta data of the holiday items:

value: BED
config:
  type: holiday
  file: /etc/openhab/services/holidays_de.xml

If I execute the rule now, I fortunately no longer get an error message, but I get an entry in the log that it is a default day, even though I entered today as a public holiday for the public holidays.

22:26:51.163 [INFO ] [.openhab.model.script.Rules.TimeOfDay] - Today is a default day.

I would expect, that today is a holiday? Did i miss something?

Why? You’ve defined a holiday for April 4th but today is the 8th.

Oh, i think its too late - i changed it and startet the service, but no change.

Perhaps it is obvious to everyone but entering etod did not take for me until I pressed the “enter” key.

I’m running OH3 3.0.1 on rPi using openhabian and I thought I followed the steps in this DP and in the Github but I believe I must have missed something trivial or obvious. Just to summarize:

  • ftp files timerMgr.js and timeUtils.js to /etc/openhab/automation/lib/javascript/community/ folder
  • Copied the YAML to a new rule
  • Created a TimeOfDay string item which is currently set to NULL.
  • Created a TimesOfDay group item which is currently set to NULL.
  • Added a subset of sample items from the top of the DP as shown below. Linked them to an Astro Channel. etod metadata was included in the copy (DP items) and paste operation

image

Manually ran the rule and received the following error

2021-04-11 18:00:15.220 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘rkoshak-ephem_tod’ failed: TimeOfDay’s state is undefined
Invalid metadata for Item! Expected metadata in the form of etod=“STATE”[type=“daytype”, set=“dayset”, file=“uri”] where set is required if type is dayset and file is required if type is custom. in at line number 256 at column number 6

Thanks to @rlkoshak for clarifying that the TimeOfDay string must not be included in the timeOfDay Group. The rule worked once I removed it from the group.

Hi!

First post from me.

I have always found a solution to my questions on the forum, but for the described problem below I couldn’t find one.

I have migrated to OH3 (3.0.1) and it works as it should beside one thing. I have recently used a TimeOfDay rule (DSL) from the design pattern and it worked well. In the migrated solution I have implemented DSL rule from post 572 in this thread.

Running the rule I get an error-message in the log file saying:

14:07:30.498 [ERROR] [.internal.handler.ScriptActionHandler] - Script execution of rule with UID 'astro-1' failed: cannot invoke method public abstract org.openhab.core.types.State org.openhab.core.persistence.HistoricItem.getState() on null in astro

It is connected to this line as I see it:

var last = TimeOfDay.previousState(true).state.toString 

When this line is activated the error is given and the rule terminates.
If i comment out the line the rule runs as expected.

I have mapdb installed and active for persistance. According to the logfile all items are saved.

I don’t know what I am missing, so if anyone could point me in the right direction for a solution it would help.

Hi,

Trying to setup this very useful design pattern, I’m struggling with the “Defaut_Day” and “Weekend_Day” items from the example above, and Astro’s implementation :

Group:DateTime TimesOfDay
String TimeOfDay "Current time of day [%s]"

// Default day, initialization for JavaScript should be done thgrough MainUI. See https://community.openhab.org/t/oh-3-examples-how-to-boot-strap-the-state-of-an-item/108234
DateTime Default_Morning (TimesOfDay) { etod="MORNING"[type="default"] }
DateTime Default_Day (TimesOfDay) { channel="astro:sun:set120:set#start", etod="DAY"[type="default"] }
DateTime Default_Evening (TimesOfDay) { channel="astro:sun:local:set#start", etod="EVENING"[type="default"] }
DateTime Default_Night (TimesOfDay) { etod="NIGHT"[type="default"] }
DateTime Default_Bed (TimesOfDay) { etod="BED"[type="default"] }

// Weekend day, notice that not all the states are listed, the unlisted states are skipped
DateTime Weekend_Day (TimesOfDay) { channel="astro:sun:set120:set#start", etod="DAY"[type="weekend"] }
DateTime Weekend_Evening (TimesOfDay) { channel="astro:sun:local:set#start", etod="EVENING"[type="weekend"] }
DateTime Default_Bed (TimesOfDay) { etod="BED"[type="weekend"] }

Indeed, “astro:sun:set120:set#start” channel is reported as “invalid link” in UI, and thus Default_Day and Weekend_Day stay stuck to a NULL state. I would like to have dynamic values for these two. I already initialized all other items with a standalone input widget, and Default_Evening and Weekend_Evening are correctly picking up the sunset channel.
Have I missed something in the configuration ?

You’ve created an Astro Thing called set120? See - [Deprecated] Design Pattern: Time Of Day - #682 by rossko57

That doesn’t really matter. previousState() will use the system default persist service unless you direct it by parameter.

Previous state is usually pretty meaningless in Mapdb, which is usually only holding current value, unless you have unusual arrangements.

Did you add DateTime Items to the TimesOfDay Group? Do not add TimeOfDay to the TimesOfDay Group. In hindsight I should have made those names more distinct.

All the DateTime Items need to be a member of TimesOfDay. The TimeOfDay String Item should not.

Do you have persistence set up and set up for the TimeOfDay Item? Note that the TimeOfDay Item is a String Item and not supported by rrd4j which is the persistence installed by OH by default. MapDB also is not a good choice for this because it only saves the most recent value. So you’ll need an external database server like PostgreSQL or InfluxDB configured to store the TimeOfDay Item. And since you are not supplying the name of the persistence you want to use in the call to previousState, without further information we have no idea which persistence is being used in the query. Also, I don’t know for sure, but it is reasonable that previousState(true) would always return null on MapDB because the true is telling the method to look for the previous state that is different from the current state. Because MapDB only saves the current state there never will be a result to that query.

I don’t know what that version of the rule is trying to accomplish by getting the previous state of the Item but if you don’t have any other use for an external database you should consider if there is another approach.