I’m trying to make for testing purposes a simple script that will return in the log the holiday according to date from a custom Holidays XML file.
every time I run the script all I get in the log is:
[clipse.smarthome.model.script.events] - holiday is null
here is my script:
rule "ephemeris test"
when
Item mqtt_topic_e4df1f67_click received update
then
if (mqtt_topic_e4df1f67_click.state == 'long')
{
logWarn("events", "holiday is " + Ephemeris.getBankHolidayName(2020-05-01,'/etc/openhab2/services/Holidays_il.xml'))
logWarn("events", "is time " + now)
}
end
As you see I configured two holidays the system should automatically recognize (accroding to the Holiday.xsd here: https://github.com/svendiedrichsen/jollyday/blob/master/src/main/xsd/Holiday.xsd) and one holiday with a fixed date and I cant make the rule recognize any of them.
The Ephemeris day sets are working normally.
Any help would be appreciated.
2020-05-01 is essentially meaningless. It’s not a number, it’s not a String, and it’s not a ZonedDateTime, the latter of which is what getBankHoliday actually needs.
As documented in the docs:
getNextBankHoliday(<offset>, <file>) name of the next bank holiday after <offset> days from today defined in <file> . This action is broken in OH 2.5.x. Use getNextBankHoliday(<datetime>, <file>) instead by replacing <datetime> with ZonedDateTime.now().plusDays(<offset>)
Ok, I figured that one out, it’s supposed to be withDayOfMonth(1).
However the original problem of not recognizing the custom holidays file still occurs, I still get holiday is false in the log.
It seems that the issue was is that I was trying to read the file from the wrong directory, it’s supposed to be /srv/openhab2-conf/services/Holidays_il.xml instead of what I’ve been using.