openhab / openhab-core

Core framework of openHAB
https://www.openhab.org/
Eclipse Public License 2.0
912 stars 420 forks source link

Ephemeris doesn't support Jewish calendar and holidays #2394

Closed lebovitz closed 3 years ago

lebovitz commented 3 years ago

Running OH3 and configured Ephemeris in the MainUI to Israel and the weekend days as well (no region for Israel). Also created ephemeris.cfg in /conf/services to include: country=il dayset-workday=[SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY] dayset-weekend=[FRIDAY,SATURDAY]

Holiday_il.xml in the above directory is configured as: `<?xml version="1.0" encoding="UTF-8"?> <tns:Configuration hierarchy="il" description="Israel" 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">

` And trying to run the following rule from scratchPad: `var logger = Java.type("org.slf4j.LoggerFactory").getLogger("org.openhab.model.script.Rules.TimeOfDay"); scriptExtension.importPreset("default"); this.Ephemeris = (this.Ephemeris === undefined) ? Java.type("org.openhab.core.model.script.actions.Ephemeris") : this.Ephemeris; this.ZonedDateTime = (this.ZonedDateTime === undefined) ? Java.type("java.time.ZonedDateTime") : this.ZonedDateTime; logger.info("Is today a holiday? " + Ephemeris.isBankHoliday(ZonedDateTime.now().minusDays(6), '/volume1/public/openHAB/conf/services/Holiday_il.xml')); logger.info("Is today a weekend? " + Ephemeris.isWeekend(ZonedDateTime.now())); logger.info("Next holiday? " + Ephemeris.getNextBankHoliday('/volume1/public/openHAB/conf/services/Holiday_il.xml')); logger.info("Rosh Hashsana in? " + Ephemeris.getDaysUntil("ROSH_HASHANA", '/volume1/public/openHAB/conf/services/Holiday_il.xml'));` Expected to see a “true” answer for the today is holiday (6 days ago was SHAVUOT), and definitely expected to see the next holiday which is not May/22 (a year from now). Same for the number of days until ROSH_HASHANA. What I get are 3 warning lines and answers that seem to indicate that the “fixed” holiday is recognized but the Jewish holidays are not: `2021-05-23 18:20:02.779 [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 2021-05-23 18:20:02.784 [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 2021-05-23 18:20:02.793 [WARN ] [de.jollyday.util.XMLUtil ] - Could not create JAXB context using the current threads context classloader. Falling back to ObjectFactory class classloader. 2021-05-23 18:20:02.861 [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 org.apache.aries.jax.rs.whiteboard_1.0.9 2021-05-23 18:20:02.867 [INFO ] [openhab.model.script.Rules.TimeOfDay] - Is today a holiday? false 2021-05-23 18:20:02.883 [INFO ] [openhab.model.script.Rules.TimeOfDay] - Is today a weekend? false 2021-05-23 18:20:02.888 [INFO ] [openhab.model.script.Rules.TimeOfDay] - Next holiday? Test Birthday 2021-05-23 18:20:02.892 [INFO ] [openhab.model.script.Rules.TimeOfDay] - Rosh Hashsana in? -1` Downloaded the source code for Jollyday and it seems there's no where a reference to any Jewish calendar. Though the XSD file does indicate Jewish holidays. I managed to write a Javascript file that fills the gap, but the bug still stands as there's no support for a Jewish calendar / holidays in Ephemeris.
clinique commented 3 years ago

Maybe you could submit a PR taking care of Jewish calendar to Jollyday project, so you cure it at the root ?

lebovitz commented 3 years ago

My code is based on this website which says it's freely usable for non-profit purposes: http://www.david-greve.de/luach-code/jewish-java.html

I must say I don't know how Jollyday is built and have never used GitHub / submitted PR. I have no problem providing my code in Javascript / Java, however once again - I don't have enough Java experience to make sure my code is up to your standards.

Then there's the warnings I got which should be handled, and I'm not they are related.

clinique commented 3 years ago

Sorry but this is not an openhab issue but rather a Jollyday issue. May I ask you to close it ?

lebovitz commented 3 years ago

OK. I opened this bug at the suggestion of Rikoshak. I assume he meant the warnings I got, and not the missing support for Jewish calendar.