I am trying to get to grips with OH 2.1.0 after having stumbled along with 1.8 for a couple of years.
Now I have run into problems with rules. They do not seem to fire at all, not even the simplest.
My item definition is made in Paper UI:
It works because I can see the number changing in HABPanel and I see changes in the Events log.
Here are two rules:
// rule to test the visibility of items
rule "Log temp change in store"
Item Store_temp_fryk received update
logInfo("Temperature changing: ", Store_temp_fryk.toString)
and here is another:
rule "Persistence Demo"
Time cron "0 * * * * ?"
logInfo("PersistenceDemo", "2 minutes ago, the temperature was " + Store_temp_fryk.historicState(now.minusMinutes(2)) + " degrees.")
None of them generate any output in the logs. I have also tried with items defined in the .items file from an 1.X binding but no success there either. When updating a rule I also do not get any log entry either, like I did get in OH 1.8 “rule XXX updated”.
For these rules I should not have to define any special imports, right?
What is broken and how to fix it?
I am running Openhabian on an RPi3. Everything else seems to work fine.
What really makes me wonder is the missing log-out while saving.
Where are you saving and what log are you looking at (on the Karaf-Console using log:tail would show the running entries from both openhab and events.log)?
Is this a typo (“Store_fryk_temp” defined, but “Store_temp_fryk”)?
Only if Store_temp_fryk is defined using PaperUI, Habmin, or the REST API some other way. If that Item is in a .items file that indicates a real problem, assuming you are running ESH Design 0.8.
That sounds like you are trying to use version 0.9 of ESH Designer which is hopelessly broken and you should not use it. If you are using 0.8 then something else is going on. Either you have some syntax error further up in the file or you have your files in the wrong folders or something like that.
Since we see Store_temp_fryk updating in events.log we can assume that the Item is defined properly. What do you see when you change and reload the .rules file in openhab.log?
I’m not familiar with these folders. Are they openHABian specific? Typically one saves to /etc/openhab2/items and /etc/openhab2/rules
The error message ‘field is undefined’ appears regardless if the item is defined in .items or in the paperUI.
No, I’m using Designer 0.8.0 on a Mac OS 10.12.6 Sierra
The rules files are as quoted above, there is no other content.
When I reload the .rules files, nothing happens in the log.
Yes they are openHABian specific but they are being mirrored to /etc/openhab2/items and /rules respectively. I have checked that they are there and I have used used ‘nano’ and’touch’ to change the .rules files. No reaction in the log.
If I ‘touch’ the .items file this is immediately reflected in the log.
So maybe there is something wrong with the rules engine. Is there any other way than to re-install openHABian?
That is telling. OH is not seeing your rules files at all.
What are the ownership and permissions on the .rules files? That is far more likely than there being something wrong with Rules Engine. In all the time I’ve contributed to the OH forums (starting way back in 1.6 days) I’ve never seen a problem the Rules Engine simply not working.
First, check the permissions on the files. Then check that the link to /etc/openhab2/rules is set up correctly.
Well, something was broken in my installation.
Re-installing OpenhabianPi from the beginning solved the problem and now everything is working as expected. Thank you for spending time on this!
But… It seems that there is a flaw in Eclipse Smarthome Designer 0.8.0. If I create a .rules file there and store it I get an error message that the file is defective and only contains an EOF. The rule is loaded but is not operative.
Changing the file extension to something else in the Mac Finder and back again or using ‘touch’ or ‘nano’ in the terminal window immediately corrects this problem and the rule starts working. I think this is already known?
Assuming you are editing the file over samba, this is a flaw in samba not ESH Designer. Two file events get triggered for every save, one when the file starts to be saved and another when the file is done being saved. The error you see is generated when OH tries to read the file after the first file change event.