Ephemeris binding?

Excellent! That’s all I was waiting for before submitting the docs as a PR. I’ll watch for it today or tomorrow.

The Ephemeris docs are now live!

5 Likes

I’m on 2.5-stable now and interested in adding “school holidays” for some rules (the kids don’t like moving shutters while sleeping in…) - but I don’t get how to configure this. Do I need to add an XML-file? or can we access some online database and configure the location for it?

School holidays may not be addressed by Ephemeris for two reasons :

  • Ephemeris only sets the status of a given and unique day (not a day range)
  • I suspect in your country, if it’s like mine, school holidays start/end date can change from one year to another

So, to address this, I prefer using a dedicated CALDAV file.

1 Like

all right. I already have something like that in place (still a bit too manual). If I find the time, I could perhaps come up with a live interpretation of some online database for (german) school holidays based on location and post it here in the forum.
I was just confused from your post:

but perhaps you just meant something like boxing day or other fixed holidays… :wink:

You’re right. It was confusing :wink:

1 Like

You could use one entry for each day so it’s not impossible for Ephemeris to support, but CalDav would be more flexible. Though if you have access to an online list of days that can be pulled down and parsed, it would be relatively easy to write a script that pulls it down and generates the XML for you. You just need to remember to rerun/replace the XML when the new year starts.

You need to create a custom XML file somewhere that your openHAB instance can read it.

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.