Rules in OH2

I am looking at OH2 after having a successful OH1 installation. I have set up OH2 on a seperate raspi. It seems nice enough after some getting used to - but I am really struggling with rules;

In OH1 I would edit my xx.rules file and define my rules there. It seems that this wont work in OH2 and I need to use the graphical UI in Habmin - is that correct ?

I dont understand the UI - and the lack of docu has made me look at the button where it seem I can just edit the rules code directly. However, I dont seem to be able to save this?

Can anyone point me to some basic guidance to this ? - how does this Work in OH2 ?

I would really like to set up just a simple rule - and then start from there - to make sure it works.

I now tried to install Eclipse Designer - and can edit “everything” there - but my rules are not triggered like they were in OH1 - in fact, it seems like nothing happens at all ?

In the log, I can only see
2016-08-12 18:00:32.803 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘avfager.rules’

when I have updated the rules - but not even the most simple rule is run.

What could I be missing out on here ? - how to trace what is happening ?

Running OpenHab2 on RP3 with newest OS and OH files…

Looks like I’m having the same issue.
For me rules which should be triggered by an item-state change are not triggered, however triggering a rule with a cron-statement works.

My test rule looks like that:

rule “CheckTestSomething”

when
Item TestSomething changed to ON or Time cron "50 * * * * ?"
then
try {
logInfo(“CheckTestSomething”,“TestSomething = {}”, TestSomething)

  } 

finally{

  }

end

The rule should be triggered by the switch “TestSomething” changing to ON or by the cron-statement every minute (at 50 seconds).

The output of the log is:

19:26:50.222 [INFO ] [home.model.script.CheckTestSomething] - TestSomething = TestSomething (Type=SwitchItem, State=ON, Label=Test, Category=null, Groups=[EG_Wohnzimmer])
19:27:04.116 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘TestSomething’ received command OFF
19:27:04.143 [INFO ] [marthome.event.ItemStateChangedEvent] - TestSomething changed from ON to OFF
19:27:10.783 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘TestSomething’ received command ON
19:27:10.801 [INFO ] [marthome.event.ItemStateChangedEvent] - TestSomething changed from OFF to ON
19:27:50.016 [INFO ] [home.model.script.CheckTestSomething] - TestSomething = TestSomething (Type=SwitchItem, State=ON, Label=Test, Category=null, Groups=[EG_Wohnzimmer])

The Switch has been set to OFF at second 04 and set to ON at second 10, the rule did NOT trigger by the switch. Only the cron-statement triggers it.

Does that correlate with your finding?

If anybody could point me to MY mistake, I would be happy!

No.

OH2 rules should work the same as OH1. You can use HABmin if you like, and in this respect HABmin works the same as in OH1 and produces OH1 rule files.

OH2 will also have a new rule system, but the OH1 rules should continue to work the same.

Correct, the rules (should) work as in OH1. I have seen them working on my system.
However, as of some weeks ago, on the chnage to a new nigthly I have been observing the above mentioned problems with rules. I even did a complete reinstall of my RaspBerry2 (including OS and OH2).
Maybe @martindk is observing the problem I have. In my case I believe the problem to be myself, however I can’t figure out what I’m doing wrong.

Searched in the Debug-Log:

2016-08-16 20:31:41.732 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'CheckNew.rules’
2016-08-16 20:31:41.734 [DEBUG] [org.eclipse.jetty.jmx.ObjectMBean ] - Attribute Annotation found for: getHandler
2016-08-16 20:31:41.736 [DEBUG] [org.eclipse.jetty.jmx.ObjectMBean ] - defineAttribute handler false:true:class org.eclipse.jetty.rewrite.handler.RewriteHandler:Wrap$
2016-08-16 20:31:41.737 [DEBUG] [org.eclipse.jetty.jmx.ObjectMBean ] - passed convert checks handler for type interface org.eclipse.jetty.server.Handler
2016-08-16 20:31:41.739 [DEBUG] [org.eclipse.jetty.jmx.ObjectMBean ] - Influenced by: org.eclipse.jetty.server.handler.AbstractHandlerContainer
2016-08-16 20:31:41.740 [DEBUG] [org.eclipse.jetty.jmx.ObjectMBean ] - Annotations not found for: org.eclipse.jetty.server.handler.AbstractHandlerContainer
2016-08-16 20:31:41.741 [DEBUG] [org.eclipse.jetty.jmx.ObjectMBean ] - Influenced by: org.eclipse.jetty.server.handler.AbstractHandler
2016-08-16 20:31:41.742 [DEBUG] [org.eclipse.jetty.jmx.ObjectMBean ] - Influenced by: org.eclipse.jetty.util.component.ContainerLifeCycle
2016-08-16 20:31:41.745 [DEBUG] [org.eclipse.jetty.jmx.ObjectMBean ] - Method Annotation found for: dump
2016-08-16 20:31:41.746 [DEBUG] [org.eclipse.jetty.jmx.ObjectMBean ] - defineOperation dump false:UNKNOWN:Dump the object to a string
2016-08-16 20:31:41.747 [DEBUG] [org.eclipse.jetty.jmx.ObjectMBean ] - Method Cache: dump()
2016-08-16 20:31:41.749 [DEBUG] [org.eclipse.jetty.jmx.ObjectMBean ] - Method Annotation found for: dumpStdErr
2016-08-16 20:31:41.750 [DEBUG] [org.eclipse.jetty.jmx.ObjectMBean ] - defineOperation dumpStdErr false:UNKNOWN:Dump the object to stderr
2016-08-16 20:31:41.751 [DEBUG] [org.eclipse.jetty.jmx.ObjectMBean ] - Method Cache: dumpStdErr()
2016-08-16 20:31:41.752 [DEBUG] [org.eclipse.jetty.jmx.ObjectMBean ] - Influenced by: org.eclipse.jetty.util.component.AbstractLifeCycle
2016-08-16 20:31:41.753 [DEBUG] [org.eclipse.jetty.jmx.ObjectMBean ] - Attribute Annotation found for: getStopTimeout
2016-08-16 20:31:41.754 [DEBUG] [org.eclipse.jetty.jmx.ObjectMBean ] - defineAttribute stopTimeout false:false:class org.eclipse.jetty.rewrite.handler.RewriteHandler$
2016-08-16 20:31:41.756 [DEBUG] [org.eclipse.jetty.jmx.ObjectMBean ] - DeclaredSetter:
2016-08-16 20:31:41.756 [DEBUG] [er.antlr.AbstractInternalAntlrParser] - Parsing took: 14 ms
2016-08-16 20:31:41.758 [DEBUG] [.linking.impl.AbstractCleaningLinker] - beforeModelLinked took: 0ms

That sounds to me as if the rule could not be parsed and is dumped to StandardError.

…and using the nigthly from today (Aug 16) it even prints a warning when the rule should be triggered by switching the item

22:29:47.726 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener ‘[org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleEngineImpl@e785b0, TestSomething, null]’ about state update of item java.lang.NullPointerException: {}

OK - my original question was answered - and solved, somehow; I fiddled with file rights on my Raspi3 and suddenly rules in my .rules file started being triggered (and I recieved a test-tweet)…
However, I had spent so much time configuring, learning etc. and in the meanwhile my Family grew annoyed with the various switches not working, so I gave it up.

I will look into OH2 when I get a proper test-setup with a seperate box and zwave controller to play with. Hopefully OH2 wil also have matured somewhat in the meantime as well as be better documented.

I am back at OH1 for now :sob:

Has anyone has an update to the problem. I copied a .rules file from OH1 to conf/rules folder. I see the event is triggered as expected

2016-10-16 16:27:30.492 [ItemCommandEvent          ] - Item 'AVR_Program' received command ENTERTAIN
2016-10-16 16:27:30.512 [ItemStateChangedEvent     ] - AVR_Program changed from TUNER to ENTERTAIN

but the rules doesn’t get triggered

rule "Activate AVR Tuner"
when
	Item AVR_Program received command "TUNER"
then
	logInfo("AVR", "Activate Program Tuner")
end

This works with OH1, but not with OH2. I checked permissions for the .rules files and they are set to root - even openhab:openhab doesn’t make a difference.

Rules get updated when editing

2016-10-16 16:59:01.891 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'scenes.rules'

but nothing happens on the event. :sob:

Sorry, driving, so brief. Do you have a .map file in the transform directory? Not sure if it’s still used in oh2