Here is the rule. It failes to run. running latest 2.0 build. what can i do to test?
Time cron "0 0/1 * 1/1 * ? *"
when I save this file I get this in the logs
2017-01-24 11:41:56.462 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘test.rules’ is either empty or cannot be parsed correctly!
2017-01-24 11:41:56.477 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'test.rules’
2017-01-24 11:41:56.667 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘test.rules’
I’m pretty sure there isn’t a println action. Try:
logInfo("Test", "Entered test")
There also might be something weird with your cron expression. I’m not great with cron but I’ve never seen “1/1” in the “Day of the Month” field.
Try a simpler cron expression then. The error is complaining about the rule file not being parsable.
Also make sure there are no hidden characters floating around in the file that might be causing the parser trouble.
i made the change to the failing test.rules as you suggested to be as below. when i first saved the changes it did NOT give me the error.
I noticed that there was a blank line after the “end” so i deleted it and saved and it gave me the error again.
OK this is something.
IF i restart OH2 and add the extra line back in it does NOT give me the empty error ANY further change to that file gives me that error.
so it looks like I have change the file once without the empty error. ANY other changes generate that error
Time cron “0 0 23 * * ?”
logInfo(“Test”, “Entered test”)
2017-01-25 10:01:04.416 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'test.rules’
2017-01-25 10:01:04.494 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'test.rules’
2017-01-25 10:01:04.641 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'test.rules’
2017-01-25 10:01:04.758 [DEBUG] [ulation.internal.HueEmulationServlet] - 10.1.1.5: GET /api/discovery.xml
2017-01-25 10:01:11.985 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'test.rules’
2017-01-25 10:01:11.987 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘test.rules’ is either empty or cannot be parsed correctly!
2017-01-25 10:01:11.998 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'test.rules’
2017-01-25 10:01:12.285 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘test.rules’
OK, this is pointing to one of the following:
There is a special character or something like that floating around in that file. Try creating a brand new file and type in (don’t copy) the code over. Use a native editor on the machine where OH is running (nano, vi, Notepad, Notepad++).
Corrupt or failing file system. If you are on a Raspberry Pi errors like this can point to a failing SD card.
Raspberry Pi with insufficient power supply.
Just to be clear. There is nothing syntactically wrong with the rule as posted.
remember it works the first time i change the file after a OH2 restart. and subsequent changes are flagged empty. sounds like a variable not getting cleared.
I’ve seen plenty of people report errors that rules files are not loaded at all. I’ve never seen one where it loads the first time and fails after subsequent reboots EXCEPT for one time and the cause was a failing SD card.
found a single extra space after the “when” removed it and now its clean
ok new info. when I use notepad++ to edit the file on my ubuntu server installed on a VM HD it gives me the error with just adding blank line at the end of the file. if i make the SAME change in vi directly it works clean… looks like Notepad++ is adding something
What encoding are you using in Notepad++?
Have you considered using Designer? At a minimum I strongly recommend Designer to check the syntax of your files when you run into problems.
An extra space in any of those locations should not be causing any problems.
very intresting as i a seeing the same thing.
curious if anyone solved this yet.
i have tried designer but i dont think its been upgraded for OH2 right? it doesn’t feel like it.
it doesn’t even recognize sendMail as a rule command.
am I using it wrong? the .8 version
Don’t think you are doing anything wrong. The .8 version does not recognize all syntax (such as your sendMail example), but it is still better than nothing for me. 0.9 version seems to remain broken and no fix is insight as far as I know. Just ignore the few syntax warnings (in my case not that many).
By the way I do get this error “…empty or cannot be parsed correctly!” on a lot of my conf files. I exclusively use designer, but still. However, the upside, this error does not seem to impact any functionality of OH2.
I just hope that these ‘little’ errors and inconveniences (and there are a lot of "just ignore’ and undocumented tips and tricks) do not add up to that many that the whole project will become balked down by it.
Well whenever i make changes and save in OSX Textwrangler or Windows Notepad++ or designer, i have these errors not only on rules file but also on items and some other config files. What i do is i open the file in “vi” and :wq, save and exit. Then it accepts the file without an error. Still cannot understand what is the real problem.
OK, at last i found the problem for my situation. In the rules file, there should be no whitespaces, either space or tab at the end of each and every line, and at the end of the file. So, check every line for the extra spaces at the end, remove them, and also at the end of the file remove any empty lines. Now it works with TextWrangler, Notepad++ and Designer without any problems.
Just in case anyone is reading this looking for a solution and the above didn’t help: I have additional information.
I’ve been scratching my head over this for a long time now. I’m running openHabian and am using a Mac and VS Code. Even after scouring my .rules files for blank lines or extra spaces this error just wouldn’t go away. Then it dawned on me that it might be some problem with file encoding. I then did the following for every file, using VS Code:
- Copied the code
- Created a new file (right click on rules folder --> New File)
- Pasted the code and saved the file
- Deleted the old file
And the error message was gone!
Copying the files did not solve the problem btw… I had to create new ones.
I’m sorry to say that this does not solve the problem after all.
But there is definitely something strange going on here. The “copy & paste to a new file” trick seemingly works at first. The file is then saved without openHab logging the error. Subsequent presses of Ctrl + S lead to the single log entry
2017-11-26 23:08:47.623 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'xyz.rules'
So… still no error. Removing any character in VS Code, adding it again (so, in effect, no change) and pressing Ctrl + S leads to:
2017-11-26 23:06:36.346 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'xyz.rules'
2017-11-26 23:06:36.357 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'xyz.rules' is either empty or cannot be parsed correctly!
2017-11-26 23:06:36.796 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'xyz.rules'
I get the same thing and often ignore it although would love to get rid of these warnings. I just tried creating a new rules file with VSCode and get the same empty parsing error with rule.
rule "Testing Rules"
No extra spaces or anything that I can see that would result in the Warning.
I guessing you are accessing your files remotely through Samba. If so, please rest assured that this is an issue caused by Java that is benign and does not cause any trouble. If you search the forum you can find more technical explanations, but in a nutshell, the rules file is read immediately when it is touched by the file system, and at that point, the write process (when you save a file) is not yet finished, which then causes the warning. However, when the write process has ended your file is read again, this time successfully (except for user errors of course ) and you can see the corresponding log messages immediately following the warning. Apparently a feature connected to Java and hence it will likely stay like this forever. SImply put: just ignore it. Hope that helps.
I copied a very easy rule from OH1 to OH2, the items haven´t changed since then:
Item Schuko_OG_Gang received command ON
In OH1 the rule was executed without any problems, but no, nothing happens, Schuko_OG_Gang turns on but that is all. In the logs i get the following:
2017-12-28 17:21:39.010 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘Weihnachtsbeleuchtung.rules’
2017-12-28 17:21:39.039 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘Weihnachtsbeleuchtung.rules’ is either empty or cannot be parsed correctly!
2017-12-28 17:21:39.251 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘Weihnachtsbeleuchtung.rules’
I don´t see the mistake. Can you please give me a hint?