On my Debian Linux system Ephemeris.isBankHoliday today returns false.
I use a patched Holidays_de.xml where I added SHROVE_MONDAY as
<tns:ChristianHoliday type="SHROVE_MONDAY" />
In the rules file, I use following code:
val String holidayxml = '/etc/openhab2/services/Holidays_de.xml'
val String FeiertagName = Ephemeris.getBankHolidayName(0, holidayxml)
val String FeiertagDesc = Ephemeris.getHolidayDescription(FeiertagName)
logInfo("Holiday", "Heutiger Feiertagsname: "+FeiertagDesc)
logInfo("Holiday", "isBankHoliday: "+Ephemeris.isBankHoliday(0, holidayxml))
if (Ephemeris.isBankHoliday(0, holidayxml) == true) {
....
}
While FeiertagDesc is shown as “Aschermontag”, isBankHoliday returns false.
Since EASTER_MONDAY is 49 days away, I changed the “0” everywhere to 49 and now isBankHoliday returns true.
But why doesn’t it accept my SHROVE_MONDAY? Especially if getBankHolidayName/getHolidayDescription seem to accept SHROVE_MONDAY?
As a workaround I currently use
if (Ephemeris.isBankHoliday(0, holidayxml) == true || FeiertagDesc !== null) {
but I’d like to understand, why isBankHoliday doesn’t work for me.
Greetings
Roland
Bonus question: Any idea how to change the description of SHROVE_MONDAY from “Aschermontag” to “Rosenmontag”? I placed a modified holiday_descriptions_de.properties in /etc/openhab2/services, but I don’t know how to tell OpenHAB how to use it.
val filename = "Ephemeris"
rule "Ephemeris started rule"
when
Item TestEphemeris changed
then
if (Ephemeris.isBankHoliday(0,"/etc/openhab2/services/Holidays_gr.xml") ) {
logInfo(filename,"February 25") // not working
}
if ( Ephemeris.isBankHoliday(1,"/etc/openhab2/services/Holidays_gr.xml") ) {
logInfo(filename,"February 26") // not working
}
if (!isWeekend(5)) {
logInfo(filename,"Ημέρα της εβδομάδας") // OK
}
if (isWeekend(4)) {
logInfo(filename,"Αύριο είναι το Σαββατοκύριακο") // OK
}
if (isInDayset("school",0))// deytera me paraskeuh
{
logInfo(filename,"Υπάρχει σχολείο σήμερα") // OK
}
end
var datetime = new DateTimeType().zonedDateTime.now().plusDays(1)
if (Ephemeris.isBankHoliday(datetime, "/etc/openhab2/services/myPlan.xml") == true) {
...
}
Greetings
Roland
val datetime = new DateTimeType().zonedDateTime.now().plusDays(1)
val isHoliday = isBankHoliday(datetime, "/etc/openhab2/services/myPlan.xml")
logInfo("ephemerisRules", isHoliday)
results in the error
An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.LogAction.logInfo(java.lang.String,java.lang.String,java.lang.Object) on instance: null
I will try to investigate some more,
Greetings,
Felix
I’m not fully sure about the difference between “val” and “var”, but I think that the DateTimeType is not a value but a variable…
So you may try to use “var” here.