Can't seem to configure custom holidays in Ephemeris

  • Platform information:
    • Hardware: Raspberry Pi 4
    • OS: Armbian
    • Java Runtime Environment: OpenJDK Runtime Environment Zulu17.44+53-CA (build 17.0.8.1+1-LTS)
    • openHAB version: 4.0.3
  • Issue of the topic: I have Ephemeris default holidays configured via ephemeris.cfg and they seem to work without issues. I want to add some extra holidays via $OH_CONF/services/holidays.xml configuration file, but these holidays doesn’t seem to be taken into account. Launching the rule today should trigger that its a bank holiday or at least that’s what I’m trying to achieve.
  • Please post configurations (if applicable):

ephemeris.cfg:

country=es
region=m
city=mad
dayset-workday=[MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY]
dayset-weekend=[SATURDAY,SUNDAY]

/etc/openhab/services/holidays.xml:

<?xml version="1.0" encoding="UTF-8"?>
<tns:Configuration hierarchy="es" description="Spain" 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>
    <!-- School holidays -->
    <tns Fixed month="OCTOBER" day="13" descriptionPropertiesKey="School holiday" />
  </tns:Holidays>
</tns:Configuration>

Test rule:

rule "Test rule"
when
  Time cron "0 0 0 * * *"
then
  logInfo("Test rule", "Ephemeris: " + Ephemeris.isBankHoliday)
  logInfo("Test rule", "Ephemeris day: " + Ephemeris.getBankHolidayName)
end
  • If logs where generated please post these here using code fences:
    When running the above test rule, I get the following in the openhab.log file
2023-10-13 12:04:48.350 [WARN ] [de.jollyday.util.ClassLoadingUtil   ] - Could not load class with current threads context classloader. Using default. Reason: ClassNotFoundException: de.jollyday.impl.DefaultHolidayManager
2023-10-13 12:04:48.364 [WARN ] [de.jollyday.util.ClassLoadingUtil   ] - Could not load class with current threads context classloader. Using default. Reason: ClassNotFoundException: de.jollyday.datasource.impl.XmlFileDataSource
2023-10-13 12:04:48.395 [WARN ] [de.jollyday.util.XMLUtil            ] - Could not create JAXB context using the current threads context classloader. Falling back to ObjectFactory class classloader.
2023-10-13 12:04:48.662 [WARN ] [de.jollyday.util.ClassLoadingUtil   ] - Could not load class with current threads context classloader. Using default. Reason: ClassNotFoundException: de.jollyday.parser.impl.ChristianHolidayParser
2023-10-13 12:04:48.671 [WARN ] [de.jollyday.util.ClassLoadingUtil   ] - Could not load class with current threads context classloader. Using default. Reason: ClassNotFoundException: de.jollyday.parser.impl.FixedParser
2023-10-13 12:04:48.694 [INFO ] [.openhab.core.model.script.Test rule] - Ephemeris: false
2023-10-13 12:04:48.704 [INFO ] [.openhab.core.model.script.Test rule] - Ephemeris day: null

I don’t know why you see those warnings, but I believe you need to explicitly supply the path of your holiday definition:

logInfo("Test rule", "Ephemeris: " + Ephemeris.isBankHoliday("/etc/openhab/services/holidays.xml"))

I’ve tried setting the full file path in the function call, but it seems to complain regarding the file itself:

2023-10-13 13:10:02.014 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'test-1' failed: Cannot instantiate configuration from URL 'file:/etc/openhab/services/holidays.xml'. in test

File is there and its accessible for the openhab user:

$ ls -l /etc/openhab/services/holidays.xml
-rw-r--r-- 1 openhab openhab 1439 Oct 13 11:59 /etc/openhab/services/holidays.xml

Not sure why it doesn’t like it. :pensive:

Okay, I found two issues:

  • First, I ran your XML through a validator and it didn’t pass. In line 5 you need to change <tns Fixed to <tns:Fixed. This is the reason for the error.
  • Second, you need to rename your file from “holiday.xml” to “holidays-es.xml”. Otherwise it will not work as intended.

Argh, sorry I didn’t saw the typo at first sight. Thanks for pointing it out, it now works as expected.