openHAB 3.0 Milestone 4 discussion

Hello,
i always get this error:

script execution of rule with UID 'ephemeris-1' failed: An error occurred during the script execution: Could not invoke method: org.openhab.core.model.script.actions.BusEvent.postUpdate(org.openhab.core.items.Item,org.openhab.core.types.State) on instance: null in ephemeris

how do i know which rule is ephermis-1 ??? and what is there all about?

Iā€™ve reverted to 2037 - looks much better for now.

There is an issue to address that and use the rule name instead of UID in those errors. In the mean time you can query the REST API for the rule with that UID and you should be able to tell from the JSON you get back which rule is the problem.

I would expect you have a rule names or containing ā€œephemerisā€ in the name.

@rlkoshak How do I query the rule Id via rest?

Much more complex and less legible than just copy/paste files to this forumā€¦ A bulk export/import would be welcome.

Just open thƩ rules page to see the mapping rule name / rule UID,

Go to Developer Tools ā†’ API Explorer and scroll down to the Rules section. They are interactive docs so you can issue the query from there.

Itā€™s no more or less legible than the .things file syntax and .rules file syntax. Donā€™t confuse familiarity with legibility.

And itā€™s not more complex than opening a text editor, opening the .rules file, and copy and paste the rule into the forum.

The steps are literally just open MainUI, browse to the rule, click on ā€œcodeā€, copy and paste the rule into the forum. Thereā€™s only one extra click.

Iā€™ve already opened an issue for import of the YAML files.

I donā€™t know if there is an issue for bulk import/export. Iā€™m not sure it makes a lot of sense. If you are working with bulk like that it may make more sense to use the raw JSON and REST API, the JSONDB files themselves, or just stick to your text based configs in the first place. But a feature request can be made by anyone.

Iā€™m having some trouble converting my OH2 DSL rules over to OH3 when they use Ephemeris.

The OH2 rule is:

rule "Weekend Morning" 
when
          Time cron "0 30 07 ? * * *"
  then
        if ((Morning_Scene.state != ON) && ((Holiday_Scene.state == ON) || Ephemeris.isWeekend || Ephemeris.isBankHoliday) {
                Morning_Scene.sendCommand(ON)
        }
end

And my corresponding OH3 rule is:

triggers:
  - id: "1"
    configuration:
      cronExpression: 0 30 7 * * ? *
    type: timer.GenericCronTrigger
conditions:
  - inputs: {}
    id: "2"
    label: Not work day
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: (Holiday_Scene.state == ON) || Ephemeris.isWeekend ||
        Ephemeris.isBankHoliday
    type: script.ScriptCondition
  - inputs: {}
    id: "4"
    configuration:
      itemName: Morning_Scene
      state: ON
      operator: "!="
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "3"
    configuration:
      itemName: Morning_Scene
      command: ON
    type: core.ItemCommandAction

But the rule fails with the less than helpful message

[ERROR] [e.automation.internal.RuleEngineImpl] - Failed to execute rule 'Weekend_Morning': null

Any suggestions?

The only code here is in the conditions. Thatā€™s the most likely source of the error. I can think of a few ways to debug this.

  1. First make sure Morning_Scene is properly defined. Iā€™m assuming you selected the Item through the UI so itā€™s probably fine but if you edited the YAML in the code tab it might have a typo or something.

  2. Simplify the script condition. Just check for Holiday_Scene first. If that works add in the isWeekend and then the isBankHoliday. That should tell you which call is failing or if there is something fundamentally wrong with the script over all if Holiday_Scene.state == ON fails.

There is nothing obviously wrong with the rule over all. But Iā€™ve no experience writing Rules DSL in MainUI so there may be something I donā€™t know that is acting weird. We need to find which of those three calls is failing to determine if a bug needs to be filed I think.

Hi Paul - I have the same issue with OH3. Setpoints via the defaultui are not working consistently (Iā€™ve only had them work once so far - and not sure why). I tried both safari and chrome as web browser with similar results.

1 Like

Where can items be imported? I donā€™t see it.

Can someone help me quick with the correct expression instead of

now.getDayOfWeek

?

I know the times library changed but donā€™t know from which to whichā€¦and canā€™t find itā€¦

i tried this

LocalDate.now().getDayOfWeek()

also not possibleā€¦

In my rule:

    logInfo("TEST", now.getDayOfWeek().toString)

Console output:

08:51:29.670 [INFO ] [org.openhab.core.model.script.TEST   ] - THURSDAY

Ok I need in OH3

toString() or getValue()

to get the name of the Day or the Integer value.

Regards

No, the toString is only necessary to print it as a string in the log statement (as it expects a string parameter). The getDayOfWeek() returns an enum as per the javadoc.

Sorry yes you are right

Hi Guys,

is it just me or does MapDB work in your M4? For me, it crashes on startup on either M3 or M4 and thus does not initialize the item states.
I found some discussion on this for M1, but nothing newer nor a solution.

Thanks!

No, working fine for meā€¦

If crashes means you see the exception in this issue:

ā€¦ then you need to remove the DB file and start from scratch.