Ephemeris binding?

According to the OpenHAB 2.5 release blog, it should be possible to use Ephemeris with birthdays:

It provides information about the days: Is it a weekday or weekend? Is it a bank holiday? Is it anybody’s birthday or maybe time to carry the trash outside?

But how? I can’t find it in the docs.

oh I feel stupid :confounded: I overlooked the example.

Please tick the solution, thanks

I can’t, I’m not the topic starter

1 Like

Hi all,

honestly even with documentation or Samples I’m not making it :frowning:

I like to see if a specific date is a holiday and if true, which one.
getBankHolidayName(<datetime>) would be the one, but I do not manage to specify a date properly.
e.g. which Holiday would be 25th December of actual year?

On the other hand, how to get 1st Advent for Christmas lights??

Looking forward someone already managed this?

It’s always most helpful to us helping you if you post what I’ve actually tried.

I believe you need to use a ZonedDateTime Object. So to get December 25th of this year it would look something like

getBankHolidayName(ZonedDateTime.now.withMothOfYear(12).withDayOfMonth(25))

You may need to import java.time.ZonedDateTime. In anticipation of the removal of Joda DateTime in future versions of OH, Ephemeris was written to use ZonedDateTime instead.

If Advent is not an official bank holiday in your configured region, you need to create a custom XML file to define it and query that XML file instead of the default one.

Hi,

thanks, and sure thing I should have posted this, even there where many tries.
Unfortunatelly your string haven’t work either. But I’ve got it working with

Ephemeris.getBankHolidayName(new DateTimeType(“2020-12-25”).zonedDateTime)

Now I am trying to use custom or even any XML file, but stuck with this now :-/

logInfo(“Test”, “File {}”, Ephemeris.getBankHolidayName(new DateTimeType(“2020-12-22”).zonedDateTime), ‘services/holiday.xml’)
logInfo(“Test”, “File 2 {}”, Ephemeris.getBankHolidayName(new DateTimeType(“2020-12-22”).zonedDateTime), ‘d:/OpenHAB/conf/services/holiday.xml’)

I’m running OpenHAB on a Windows System, as calling a file is different to Linux :wink:

Logs?

Yes, to test results?

logInfo(“Test”, “Line 1: {}”, Ephemeris.getBankHolidayName(new DateTimeType(“2020-12-25”).zonedDateTime))

result properly into

21:29:01.438 [INFO ] [g.eclipse.smarthome.model.script.Test] - Line 1: FIRST_CHRISTMAS_DAY

Faulty logs from above

21:29:01.469 [INFO ] [g.eclipse.smarthome.model.script.Test] - File null
21:29:01.563 [INFO ] [g.eclipse.smarthome.model.script.Test] - File 2 null

I don’t use custom xml files but I know others do and it works for them. Assuming the path to that file is correct I don’t have any further suggestions. There is no error so it seems like it’s finding the file. Are you certain that the holiday is correctly defined on 12/22?

Shame on me :see_no_evil: to much testing and copy/paste errors, as for sure it should be 12/25

Changed this

logInfo(“Test”, “Line 1: {}”, Ephemeris.getBankHolidayName(new DateTimeType(“2020-12-25”).zonedDateTime))
logInfo(“Test”, “File {}”, Ephemeris.getBankHolidayName(new DateTimeType(“2020-12-25”).zonedDateTime), ‘holiday.xml’)
logInfo(“Test”, “File 2 {}”, Ephemeris.getBankHolidayName(new DateTimeType(“2020-12-25”).zonedDateTime), ‘OpenHAB/conf/services/holiday.xml’)

and have been happy as it shows up now

21:52:22.152 [INFO ] [g.eclipse.smarthome.model.script.Test] - Line 1: FIRST_CHRISTMAS_DAY
21:52:22.167 [INFO ] [g.eclipse.smarthome.model.script.Test] - File FIRST_CHRISTMAS_DAY
21:52:22.183 [INFO ] [g.eclipse.smarthome.model.script.Test] - File 2 FIRST_CHRISTMAS_DAY

So I changed entry within holiday.xml to ensure it’s working,

<tns:Fixed month=“DECEMBER” day=“25” descriptionPropertiesKey=“FIRST1_CHRISTMAS_DAY”/>

But nothing changed in log, it’s still FIRST_CHRISTMAS_DAY

I’ve already restarted OpenHAB to ensure XML it newly used.

That’s not what the “descriptionPropertiesKey” does. That attribute references a properties file that has a nicer version of the holiday name. See https://github.com/svendiedrichsen/jollyday/tree/master/src/main/resources/descriptions. I’m not sure what get’s returned when the property doesn’t exist. I’m also not sure how to define your own .properties file.

I would test with a day that is not in the county bank holiday list.

Hmm,
I haven’t had properties-file in my system, placed it now to services folder as well.
Also I changed to default name “holidays_de.xml” and added a new item, did a restart of OH, bt still no success

New Item

<tns:Fixed month=“DECEMBER” day=“24” descriptionPropertiesKey=“GIFT_CHRISTMAS_DAY”/>

logInfo(“Test”, “Day 24: {}”, Ephemeris.getBankHolidayName(new DateTimeType(“2020-12-24”).zonedDateTime))
logInfo(“Test”, “Day 25: {}”, Ephemeris.getBankHolidayName(new DateTimeType(“2020-12-25”).zonedDateTime))
logInfo(“Test”, “File 24: {}”, Ephemeris.getBankHolidayName(new DateTimeType(“2020-12-24”).zonedDateTime), ‘services/Holidays_de.xml’)
logInfo(“Test”, “File 25: {}”, Ephemeris.getBankHolidayName(new DateTimeType(“2020-12-25”).zonedDateTime), ‘services/Holidays_de.xml’)
logInfo(“Test”, “File2 25: {}”, Ephemeris.getBankHolidayName(new DateTimeType(“2020-12-25”).zonedDateTime), ‘d:/OpenHAB/conf/services/Holidays_de.xml’)

Log

22:21:13.543 [INFO ] [g.eclipse.smarthome.model.script.Test] - Day 24: {}
22:21:13.552 [INFO ] [g.eclipse.smarthome.model.script.Test] - Day 25: FIRST_CHRISTMAS_DAY
22:21:13.562 [INFO ] [g.eclipse.smarthome.model.script.Test] - File 24: null
22:21:13.570 [INFO ] [g.eclipse.smarthome.model.script.Test] - File 25: FIRST_CHRISTMAS_DAY
22:21:13.581 [INFO ] [g.eclipse.smarthome.model.script.Test] - File2 25: FIRST_CHRISTMAS_DAY

It looks like information is read somewhere else than from file? As descriptionPropertiesKey is shown up in log, I won’t expect a dependency to country_descriptions_de.properties ?

I’ve just found the (further) mistake and got it working.
I have to provide full path to file and to set brackets at right place.

WRONG

logInfo(“Test”, “Day25: {}”, Ephemeris.getBankHolidayName(new DateTimeType(“2020-12-25”).zonedDateTime), ‘d:/OpenHAB/conf/services/Holidays_de.xml’)

WORKING

logInfo(“Test”, “Day 25: {}”, Ephemeris.getBankHolidayName(new DateTimeType(“2020-12-25”).zonedDateTime, ‘d:/OpenHAB/conf/services/Holidays_de.xml’))

Obvious but just hidden.

From the docs:

You can place these XML files anywhere on your file system that openHAB has permission to read. In the calls to the Actions, use the fully qualified path.

Yep,
I’d read this,but it haven’t worked because of error wih brackets, which wasn’t recognized by VSC either. Anyway, this one is working now.

As Advent weekends are not included I’m trying to create a custom xml, but these days are not fixed ones.
I already posted this in knx-user-forum (german one) but probably some here also has some tipp or knows where the issue is??

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

<tns:Configuration hierarchy=“de” description=“Germany” 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:RelativeToFixed descriptionPropertiesKey=“FIRST_ADVENT”>
tns:WhichFOURTH</tns:Which>
tns:WeekdaySUNDAY</tns:Weekday>
tns:WhenBEFORE</tns:When>
<tns:date month=“DECEMBER” day=“25”/>
</tns:RelativeToFixed>
<tns:RelativeToFixed descriptionPropertiesKey=“SECOND_ADVENT”>
tns:WhichTHIRD</tns:Which>
tns:WeekdaySUNDAY</tns:Weekday>
tns:WhenBEFORE</tns:When>
<tns:date month=“DECEMBER” day=“25”/>
</tns:RelativeToFixed>
<tns:RelativeToFixed descriptionPropertiesKey=“THIRD_ADVENT”>
tns:WhichSECOND</tns:Which>
tns:WeekdaySUNDAY</tns:Weekday>
tns:WhenBEFORE</tns:When>
<tns:date month=“DECEMBER” day=“25”/>
</tns:RelativeToFixed>
<tns:RelativeToFixed descriptionPropertiesKey=“FOURTH_ADVENT”>
tns:WhichFIRST</tns:Which>
tns:WeekdaySUNDAY</tns:Weekday>
tns:WhenBEFORE</tns:When>
<tns:date month=“DECEMBER” day=“25”/>
</tns:RelativeToFixed>
</tns:Holidays>
</tns:Configuration>

For debugging the XML file you might need to ask over at the Jollyday github project. At this point you are probably among the most experienced with Ephermeris on this forum. I don’t know that many have created custom XML files yet and even fewer have attempted to create relative holiday dates. I know it’s possible though.

You might look at the example xml files on Jollyday for various countries and see if there is something different between your XML and relative dates in the various country XML files.

1 Like

Just for information, after I read through various xml’s I’ve found something I can use and which solves this issue for me. Thanks for support and hints.