Define custom ephemeris to use in rules

Hi,

I want to create a schedule based on the time of the year. For example, let say I want my Christmas lights set to ON at sunset everyday but only during the following period: from December 15th to January 5th of every year.

I understand I can create a custom ephemeris file and use isBankHoliday(<datetime>, <file>) in a rule to check if the date is present in the custom file. Is there a way to do this from the configuration UI instead?

<?xml version="1.0" encoding="UTF-8"?>
<tns:Configuration hierarchy="ca" description="Canada"
    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="DECEMBER" day="15" descriptionPropertiesKey="Christmas" />
        <tns:Fixed month="DECEMBER" day="16" descriptionPropertiesKey="Christmas" />
        ...
        <tns:Fixed month="JANUARY" day="4" descriptionPropertiesKey="Christmas" />
        <tns:Fixed month="JANUARY" day="5" descriptionPropertiesKey="Christmas" />
    </tns:Holidays>
</tns:Configuration>

Hardware: armv7/1GB RAM/32GB SD
OS: openHABian 3.3.0
Java Runtime Environment: OpenJDK Runtime Environment Zulu11.43+88-CA (build 11.0.9+11-LTS)
openHAB version: 3.3.0

1 Like

No, not yet. Maybe not ever, it’s a hard thing to implement.

Thanks for the response Rich. At the very least, I can define at the rule level the script that will check for a holiday in a specific file with isBankHoliday(<datetime>, <file>)

Correct. In fact, that’s the only way you can check for your custom holidays. I don’t think any other part of OH will be aware of your custom file.

For the same use case (seasonally turning on my Christmas lights), I have used the Blockly Ephemeris “days until holiday named” Christmas block to make this work. I would show the Blockly but I haven’t figured out how to do it other than with a screen image, which I understand to be bad form in this forum. But I have an AND logic block with two comparison subblocks. The first compares the days until Christmas to 15 and the second to 353 (365-12). Seems a lot easier than the custom ephemeris file for this use.

The custom file should work well for another use case. I turn my outside lights to my alma maters colors on their game days. In the past I have either read my calendar using the icalendar binding or used a textual map file with the dates I manually entered. It should also be good for other dates that are celebrated but are not bank holidays, such as St. Patrick’s Day, when I turn my lights green or patriotic days that are not bank holidays such as Flag Day in the US. Thanks for sharing your approach

Click the Code tab and you will find the text of the rule. But for Blockly it’s often helpful to post both the YAML text and the screenshot.

1 Like