Ephemeris isWeekend() says undefined

  • Platform information:
    • Hardware: Linux/5.15.84-v7+ (arm)
    • OS: openhabian
    • Java Runtime Environment: 11.0.18
    • openHAB version: 3.4.1
  • Issue of the topic: Ephemeris.isWeekend() is undefined


  name: "s1OnWeekday",
  triggers: [
  execute: (event) => {
    let daniel = items.getItem("daniel_Online").state;
    let julia = items.getItem("julia_Online").state;

    console.log(!actions.Ephemeris.isWeekend(), !actions.Ephemeris.isBankHoliday(), (daniel == "ON" || julia == "ON"));

    if (
      !actions.Ephemeris.isWeekend() &&
      !actions.Ephemeris.isBankHoliday() &&
      (daniel == "ON" || julia == "ON")
    ) {


2023-02-19 13:52:01.013 [INFO ] [nhab.automation.script.file.rules.js] - ****************=>

2023-02-19 13:52:01.017 [WARN ] [emeris.internal.EphemerisManagerImpl] - This dayset is not configured : weekend

2023-02-19 13:52:01.047 [INFO ] [nhab.automation.script.file.rules.js] - undefined true true

2023-02-19 13:52:01.050 [WARN ] [emeris.internal.EphemerisManagerImpl] - This dayset is not configured : weekend

2023-02-19 13:52:01.065 [ERROR] [nhab.automation.script.file.rules.js] - Failed to execute rule s1OnWeekday-f95970a0-9fa9-484b-9f8f-de4fea01e1e5: ReferenceError: "item" is not defined: ReferenceError: "item" is not defined

at execute (rules.js:261)

at doExecute (/etc/openhab/automation/js/node_modules/openhab/rules/rules.js:242)

2023-02-19 13:52:01.072 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to execute rule 's1OnWeekday-f95970a0-9fa9-484b-9f8f-de4fea01e1e5': Fail to execute action: 1

Under “Settings” → “Ephemeris” this is set:

Is there any setting I am missing? I’m referring to this doc:

You need to download the localisation support xml file as described and add it to your function call.

In DSL it looks like this:

	Ephemeris.isBankHoliday(new DateTimeType().zonedDateTime.now().plusDays(0),"/etc/openhab/services/Holidays_de.xml" == false)

Do you have an ephemeris.cfg file? If so make sure it defines a weekend dayset. If not this looks like a bug but im not sure where.

Have you installed openhab-js manually? There were some problems with older versions so maybe that’s it.

That’s only required for custom holidays. OP has a problem with isWeekend() which should work with the default config.

Thanks for the information - I don’t have an ephemeris.cfg file as the docu states that you can set them in the UI (which I did) otherwise if no country is selected the system defaults are taken.

I’ll give it a try with the config file this evening and report if it worked.


Yes. But I remember problems using ephemeris not working if you do not provide the xml file. I might be wrong though.
The xml file could include “custom” holidays. In fact this is where the regular holidays are stored.

So I tested this and added an ephemeris.cfg file. During startup I can see this in my logs, those settings were set in UI:

2023-02-20 20:43:28.714 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Time zone set to 'Europe/Vienna'.
2023-02-20 20:43:28.847 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Location set to '47.65,12.21'.
2023-02-20 20:43:28.851 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Locale set to 'de_DE'.
2023-02-20 20:43:28.854 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Measurement system set to 'SI'.

Under $OH_CONF/services I have a ephemeris.cfg like in the documentation stated. The file contains these lines:


Under $OH_CONF/services there is a Holidays_de.xml with the content provided here

So my rule is working now for reasons I can’t get though…

The only thing I’d expect when using actions.Ephemeris.isWeekend() is that it should return a boolean value. Instead I get undefined. Anything I am missing?

could you try


For any reason it is working now … I’m not sure why it didn’t before…

I restarted via service openhab restart (I assume this doesn’t delete any cache). So now I’m having Holiday.xsd, Holidays_de.xml and Ephemeris.cfg under $OH_CONF/services.

For me this sounds like a BUG that setting country and weekend leads to undefined in OH3 JSRules ¯_(ツ)_/¯.

Now I get following output:

2023-02-20 22:00:00.336 [INFO ] [nhab.automation.script.file.rules.js] - ****************=>
2023-02-20 22:00:00.394 [INFO ] [nhab.automation.script.file.rules.js] - christian.GOOD_FRIDAY false false true

From this

console.log(actions.Ephemeris.getNextBankHoliday(), actions.Ephemeris.isWeekend(), actions.Ephemeris.isBankHoliday(), (daniel == "ON" || julia == "ON"));

So now I can turn on my lights more precisely based on workday or holiday. You’ll know:
Happy wife, happy life :slight_smile:

Thanks for your help, it’s very appreciated!

As far as I remember I did the following:

  • openhabian install openhab-js via openhabian-config
  • setting Ephemeris under settings via UI
  • calling actions.Ephemeris.isWeekend() will be undefined.

If you did this some months ago or more you may need to update openhab-js (there’s an option in openhabian-config).

I updated OH to 3.4.1 after release (8th of Jan according to GitHub) and I updated my ressources to the latest version of openhab-js in package.json and installed all dependencies. So they were up to date.

The only thing I haven’t tested so far is, whether or not I set lang, location etc. in system settings (not OH). As the documentation states If no country is provided the service uses your system default locale settings.

i had the same, but it worked when setting country/region in regional settings

with a new installation, i ran into the same problem.
keep trying to save the ephemeris settings in settings, but gave same error:

[emeris.internal.EphemerisManagerImpl] - This dayset is not configured : weekend

after checking /openhab/openhab_userdata/config/org/openhab/ephemeris.config i noticed that the default weekend settings were not saved, after adding friday to it, it saved it, and the error went away.
so i removed friday and it got updated aswell.
hopes this helps who ran into the same.