OH2 upgrade to 2.1 rules issues

Hi,

Upgraded to OH 2.1 and have issues with my rules and I cannot find the problem (they worked fine with 2.0)

Created a basic rule

rule "Test rule" 
when
	Item Plug1Switch received command
then
	logInfo("test", "Test logging")
end

The log says:

17:16:32.570 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'test.rules'
17:16:32.599 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'test.rules' is either empty or cannot be parsed correctly!
17:16:32.795 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'test.rules'

I have tried to manipulate with spaces, tabs, CR/LF, encoding (ANSI/UTF-8)ā€¦etc
Running OH2 on Raspberry Pi
Editing the files on Windows with Notepad++ from Samba share

When editing on RPi with nano it seems to work fine.

Any ideas whatā€™s wrong?

The reason seems to be to way your editor is handling files while working with them.

Could be soā€¦but have been working perfectly before upgrading to OH 2.1.
I have seen others having problem with parsing of config files after upgrading.
Any proposals on additions/changes of Samba conf?

Currently it looks like:

[openHAB Home]
    comment= openHAB Home
    path=/usr/share/openhab2
    browseable=Yes
    valid users = openhab
    #admin users = openhab
    read list = openhab
    write list = openhab
    force user = openhab
    force group = openhab
    writeable=Yes
    only guest=no
    create mask=0777
    directory mask=0777
    public=no

[openHAB Config]
    comment= openHAB Site Config
    path=/etc/openhab2
    browseable=Yes
    valid users = openhab
    #admin users = openhab
    read list = openhab
    write list = openhab
    force user = openhab
    force group = openhab
    writeable=Yes
    only guest=no
    create mask=0777
    directory mask=0777
    public=no

Iā€™ve had these issues since I started with OpenHAB. I edit my conf-files in Notepad++ (Samba share).

However, despite these error messages, all my rules operate normally. So as long as you get ā€œLoading model ā€˜test.rulesā€™ā€ eventually, you can ignore the previous error.

Sure, but if it cannot parse the file when editing via Samba/Notepad++ with OH 2.1 something have been changed since 2.0 since it worked flawless before.

Anyone having working editing over Samba? Any other Samba configuration or a glitch in OH?

Iā€™m using Samba to connect to openHABian (using default Samba settings) and editing with Visual Studio (with openHAB plugin) on OS X.

Every time I save a .rules file, I get the same error:

2017-07-20 00:09:28.648 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'alarm.rules' is either empty or cannot be parsed correctly!

And, in case anyoneā€™s wondering if I just suck at writing rules (which would be a fair guess :grinning: ), hereā€™s a sample rule that was saved alone, in its own file, without any whitespaces after any lines of text or the end of the file:

rule "rules dont work"
when
	Item DeskSwitch changed to ON
then
	sendCommand(DeskSwitch, OFF)
end

The rule does execute despite the warning in the log.

I didnā€™t notice this behavior before upgrading to 2.1.

@Dome thanks for your confirmation - then we are getting the same error (not present in OH 2.0).

I have testedā€¦

  1. Notepad++ using Samba share = Not working
  2. VS Code with extension using Samba share = Not working
  3. Atom using Samba share = Not working
  4. Nano on RPi = Working
  5. Vi on RPi = Working

So it has to be something with Samba that openHAB 2.1 doesnā€™t likeā€¦question is what and how to solve it?!

Try copying a file to your pc, editing it, copying if back somewhere different on the openhab server and then copying it (not with samba) back into the correct location

If that works it hints itā€™s not samba. I suspect itā€™s that oh2.1 is attempting to grab the edited file while samba still has it locked to commit the updated version

@benhelps that works fine - as you suspected :slight_smile:
Is OH 2.1 too quick to reload then - is it possible to configure a reload delay in OH 2.1 ?

1 Like

Good question - way above my pay grade :stuck_out_tongue:

The problem is that the samba file system creates 2 events for a new or changed file while saving a file. The first event is caught by the filewatcher but at that time the file is still empty, then there is that second event and the file gets parsed normally. From a java perspective there is no chance of distinguishing those two events, so we have to live with that warning while working on a remote filesystem like samba which creates such 2 events.

3 Likes

Thanks for the good explaination @triller-telekom