Import DSL rules to OH 3

is it a way to import my OH 2.5 rules (DSL) to OH 3? Made a migration, 2.5 -> 3.0 via backup file and all my things and items seems to have been imported, but no rules.

They’ll get read if you didn’t move them off the rules/ dir.
Eventually restart OH.

They should be loaded, check your openhab.log. in all my tests it worked, in one of the earlier milestones I had to trigger one rule in the GUI to get them running but could not determine why.
They cannot be changed/edited via the GUI, though.

Which milestone do you use or is it the RC1? On which platform?

Just to summarize and answer both sides of this question.

Your .rules files should be read an loaded largely unchanged by OH 3. The biggest hangup will be the move from Joda DateTime to ZonedDateTime which may make some rules not load or run without errors.

But the other side of the question is to import .rules files to become MainUI rules so they can be seend and edited through the UI. In that case no, there isn’t a straight forward import at this time. You’ll have to create the rule, triggers, and copy the body of the rule into a Script Action. If the rule depends on global variables I’m not sure yet how to make those work with Rules DSL.

All of my DSL rules has this error message: INVALID_RULE
Validation of rule christmas_time-6 has failed! Action Type “script.ScriptAction” does not exist!

Example one DSL Rule:

rule "Ház adventi világítás be"
when
Channel "astro:sun:home:set#event" triggered START
then
    if (Time_Advent.state == ON) {
        sendCommand(ShellyGaragePlugRelayOutput, ON)
        sendCommand(ShellyYardPlugRelayOutput, ON)
		sendCommand(ShellyYardPoolRelayRelay1Output, ON)
		sendCommand(ShellyYardPoolRelayRelay2Output, ON)
    }
end

New Code:

triggers:
  - id: "0"
    configuration:
      event: START
      channelUID: astro:sun:home:set#event
    type: core.ChannelEventTrigger
conditions: []
actions:
  - inputs: {}
    id: script
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: |
        // context: christmas_time-6
        if (Time_Advent.state == ON) {
            sendCommand(ShellyGaragePlugRelayOutput, ON)
            sendCommand(ShellyYardPlugRelayOutput, ON)
        		sendCommand(ShellyYardPoolRelayRelay1Output, ON)
        		sendCommand(ShellyYardPoolRelayRelay2Output, ON)
        }
    type: script.ScriptAction

As all rules has same error message, I have a general issue somwhere. It would be good if I can get some hints what should I check. May be some global variables are missing like load some modules?

As a first attempt, I’d remove special characters from the rule name.

I think there is something more fundamentally wrong going on here.

Did this start suddenly or has it always been generating this error. The specific error message is complaining about the type “script.ScriptAction” not existing (see the last line of your YAML). But I checked my rules and it looks just like yours so I think the actual problem occurs elsewhere.

Maybe something like a missmatched curly brace or something like that.

If it happened all of a sudden, try restoring a backup from the /var/lib/openahb/jsondb/backup folder. If not, try removing all the rules and then add them back one by one until the error occurs again (hopefully it wont). If it continues to occur, please post your full automation.json file.

The only other weirdness I see you have a mix of tabs and spaces. That shouldn’t cause a problem but just in case, try replacing your tabs with spaces.

Hi, interesting is that I installed it again from scratch. Then I copied my things, items one by one. All things, items were online. Then I startetd to copy all rules one by one. Then all rules were in green idle status, All of them. Then I restarted the system and all rules has this error again. Then I removed the rules and stared to copy back one by one but this time it show same error again. I use windows 10 with Zulu Java 11. I do not find automation.json file but OH3 was stopped. How can I reset only the rules? I included Openhab.log. During scratch install OH rule engine starts with 2 exceptions. The I also installed Jhyton addon. Rules were copeid in after its installation and restart also. Next time either I can reset only rules or I start from scratch agan but without Jhyton addon.
openhab.log (133.6 KB)