From what I can tell so far, the only way to do that is enter a separate entry for each of those days. There is no way that I could find by studying the XSD to define something that stretches across multiple days. Looking at some of the examples and the religious holidays in the schema I notice Jollyday defines a separate entry for each day. There is no way to define a number of days.
It’s also worth noting though, that many religious holidays are also built into Jollyday so even if your country doesn’t give a bank holiday for a given religious holiday, you don’t necessarily need to manually calculate the date yourself. But as with most things like this, you will need to look at the code to verify if the calculation is correct (e.g. Orthodox Christians and Roman Catholic and Protestants calculate the date for Easter differently and I’m not knowledgeable enough to tell if the code handles it correctly).
I’ve updated the docs to cover this rutime.cfg stuff. It strikes me as kind of awkward.
Did anyone consider just having isWeekend return null if there isn’t a weekend dayset? Then we can just say “add a isWeekend dayset to ephemeris.cfg or configure it in PaperUI if that happens.” Then we don’t have to worry at all about runtime.cfg and there is only the two standard ways to config it. Hopefully the UI in OH 3 will let us create daysets that way.
Jollyday defines a mapping between the holiday name and a description. This will return the description based on the holiday name returned by getBankHolidayName
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
Unfortunately exactly the isBankHoliday(<offset>, <file>) action is broken in OH 2.5.x and will probably not working before OH 3.0 - even if it is already fixed in our code base (see https://github.com/openhab/openhab-core/issues/1374).
A small workaround is to use isBankHoliday(<datetime>, <file>) and set ZonedDateTime.now().plusDays(<offset>) for <datetime>.
thanks
could you help me
val filename = “Ephemeris”
rule "Ephemeris started rule"
when
Item TestEphemeris changed
then
var Number datetime = ZonedDateTime.now().plusDays(1)
var file = "/etc/openhab2/services/Holidays_gr.xml"
if (Ephemeris.isBankHoliday(datetime,file) ) {
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
I don’t know how to write it.
I get that
2020-02-26 01:11:48.292 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Ephemeris started rule': The name 'ZonedDateTime' cannot be resolved to an item or type; line 61, column 29, length 13
thanks
but I couldn’t make it work
i have tried this
val filename = "Ephemeris"
rule "Ephemeris started rule"
when
Item TestEphemeris changed
then
var datetime = new DateTimeType().zonedDateTime.now().plusDays(1)
var file = "/etc/openhab2/services/Holidays_gr.xml"
if (Ephemeris.isBankHoliday(new DateTimeType().zonedDateTime.now().plusDays(1),"/etc/openhab2/services/Holidays_gr.xml") ) {
logInfo(filename,"February 27") // not working
}
if (isBankHoliday(new DateTimeType().zonedDateTime.now().plusDays(1),"/etc/openhab2/services/Holidays_gr.xml") ) {
logInfo(filename,"February 27") // not working
}
if ( Ephemeris.isBankHoliday(datetime,file) ) {
logInfo(filename,"February 27") // not working
}
if (isBankHoliday(datetime,file) ) {
logInfo(filename,"February 27") // not working
}
if ( Ephemeris.isBankHoliday(datetime) ) {
logInfo(filename,"February 27") // not working
}
if (!isWeekend(5)) {
logInfo(filename,"Ημέρα της εβδομάδας") // OK
}
if (isWeekend(4)) {
logInfo(filename,"Αύριο είναι το Σαββατοκύριακο") // OK
}
if (isInDayset("school",0))
{
logInfo(filename,"Υπάρχει σχολείο σήμερα") // OK
}
end
@rlkoshak nothing Errors in the log
I had to do
sudo systemctl restart openhab2.service
now it works
thanks
val filename = "Ephemeris"
rule "Ephemeris started rule"
when
Item TestEphemeris changed
then
var datetime = new DateTimeType().zonedDateTime.now().plusDays(0)
var file = "/etc/openhab2/services/Holidays_gr.xml"
if (isBankHoliday(datetime,file) ) {
logInfo(filename,"February 28") // ok
}
if (isWeekend()) {
logInfo(filename,"Αύριο είναι το Σαββατοκύριακο") // OK
}
if (isInDayset("school",0))
{
logInfo(filename,"Υπάρχει σχολείο σήμερα") // OK
}
end
Hi all,
I’m trying to lookup some “holiday” with proper translation, but fail and hope you can advise or help
Unfortunately I have no idea how to debug further as it’s my names are simply not looked up.
My entry in *.xml <tns:FixedWeekdayRelativeToFixed which="FIRST" weekday="SUNDAY" when="BEFORE" descriptionPropertiesKey="FOURTH_ADVENT" localizedType="OFFICIAL_HOLIDAY"> <tns:day month="DECEMBER" day="25"/> </tns:FixedWeekdayRelativeToFixed>
Entry to holiday_descriptions_de.properties holiday.description.FOURTH_ADVENT = 4. Advent
This seems to be equal to the other entries.
So FOURTH_ADVENT is returned properly when using logInfo("Test", "Vierter {}", Ephemeris.getBankHolidayName((new DateTimeType("2021-12-2019").zonedDateTime), '<myPath>/holidays_de.xml'))
But I didn’t get value from logInfo("Test", "vorher: {} und nachher: {}", Ephemeris.getBankHolidayName((new DateTimeType("2020-12-20").zonedDateTime), '<myPath>/holidays_de.xml'), Ephemeris.getHolidayDescription(Ephemeris.getBankHolidayName((new DateTimeType("2020-12-20").zonedDateTime), '<myPathY/holidays_de.xml')))
Returns
20:27:42.667 [INFO ] [g.eclipse.smarthome.model.script.Test] - vorher: FOURTH_ADVENT und nachher: undefined