[WIP] Ephemeris Documentation

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.

Currently I use Caldav for this

Me too, I thought that would be a good alternative though

I’ve created the PR.

Please add any further comments and edits there.

1 Like

How to use holiday_descriptions.properties ?

/Mike

2 Likes

@mashborn Did you ever get the xml file to be found? I’m running into the same issue on OH 2.5 stable (openhabian).

use

getHolidayDescription(holiday name)

Jollyday defines a mapping between the holiday name and a description. This will return the description based on the holiday name returned by getBankHolidayName

I’m trying to make it work
but I haven’t succeeded
/etc/openhab2/services/Holidays_gr.xml

<?xml version="1.0" encoding="UTF-8"?>

<tns:Configuration hierarchy="gr" description="Greece"

    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>

        <tns:Fixed month="JANUARY" day="1" descriptionPropertiesKey="NEW_YEAR"/>

        <tns:Fixed month="JANUARY" day="6" descriptionPropertiesKey="THEOPHANY"/>

        <tns:Fixed month="JANUARY" day="12" descriptionPropertiesKey="CHRIS_BIRTHDAY"/>

        <tns:Fixed month="JANUARY" day="20" descriptionPropertiesKey="Chris_test"/>

        <tns:Fixed month="JANUARY" day="30" descriptionPropertiesKey="THREE_HIERARCHS"/>

        <tns:Fixed month="FEBRUARY" day="25" descriptionPropertiesKey="February_25"/>

        <tns:Fixed month="FEBRUARY" day="26" descriptionPropertiesKey="February_26"/>

        <tns:Fixed month="MARCH" day="6" descriptionPropertiesKey="GEORGE_BIRTHDAY"/>

        <tns:Fixed month="MARCH" day="25" descriptionPropertiesKey="ANNUNCIATION"/>

        <tns:Fixed month="MAY" day="1" descriptionPropertiesKey="LABOUR_DAY"/>

        <tns:Fixed month="MAY" day="4" descriptionPropertiesKey="KONSTANTINE_BIRTHDAY"/>

        <tns:Fixed month="MAY" day="6" descriptionPropertiesKey="OLGA_BIRTHDAY"/>

        <tns:Fixed month="AUGUST" day="15" descriptionPropertiesKey="ASSUMPTION_DAY"/>

        <tns:Fixed month="OCTOBER" day="28" descriptionPropertiesKey="OCHI"/>

        <tns:Fixed month="DECEMBER" day="25" descriptionPropertiesKey="CHRSITMAS"/>

        <tns:Fixed month="DECEMBER" day="26" descriptionPropertiesKey="STEPHENS"/>

        <tns:ChristianHoliday type="EASTER" chronology="JULIAN"/>

        <tns:ChristianHoliday type="CLEAN_MONDAY"

            chronology="JULIAN" />

        <tns:ChristianHoliday type="GOOD_FRIDAY"

            chronology="JULIAN" />

        <tns:ChristianHoliday type="EASTER_MONDAY"

            chronology="JULIAN" />

        <tns:ChristianHoliday type="WHIT_MONDAY"

            chronology="JULIAN" />

    </tns:Holidays>

</tns:Configuration>

items
Switch TestEphemeris “Test Switch”

rules

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

i’m trying


but not work
thanks

Hi @jcosta46,

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>.

I think we should add a note to the docs.

I added this to my ephemeris.cfg

org.openhab.ephemeris:dayset-weekend = [SATURDAY,SUNDAY]
org.openhab.ephemeris:dayset-school = [MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY]
org.openhab.ephemeris:country = [DE]

This is how my config looks under PaperUI:

I have no idea how to fix this. Whatever I do either in PaperUi or in ephemeris.cfg - the result is broken like in the screenshot.

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

Try

new DateTimeType().zonedDateTime.now().plusDays(1)

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

Errors in the log?

@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

Hope this helps?

new DateTimeType().zonedDateTime.now().plusDays(1)

works fine - thank you!

Could you please also correct the documentation at
(https://www.openhab.org/docs/configuration/actions.html#ephemeris)
It still says
…This action is broken in OH 2.5.x. Use getNextBankHoliday(, ) instead by replacing with ZonedDateTime.now().plusDays()

It’s easy, just click on the link at the bottom of the page, this is a community driven project.

grafik

1 Like

Thanks for the hint - done

2 Likes