Openhab2 Rules not triggered

Hi,
i just started testing openhab2 and have some issues with the rules engine. It seems that if there is an error in a rules it is not showing up in the logs (i used start_debug.sh under ubuntu 14.04).

After i played around i got to a point that everything was working. I just restarted the server and the rules do not get triggered (no entry in the log).

An example of a rule is triggered by a motion sensor. The motion sensor (z-wave) appears in the log but the rule is not triggered.

Can you help me to debug the issues?

Thanks!

Regards
Mike

Example rule:

// Imports
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

// Global Variables
var Timer waitTimer = null
var boolean lightIsOn = false

rule "Hallway light on"
when
        Item Hallway_Movement changed from CLOSED to OPEN
then
        logInfo("TEST", "TEST123")
        logInfo("rules", "Hallway_Lux.state Hallway light on: "+Hallway_Lux.state)
        if (Hallway_Lux.state < 40 || lightIsOn) {
                logInfo("rules", "Hallway light on sendCommand(hue_LCT001_0017881ca34a_3, ON)")
                if (!lightIsOn) {
                        sendCommand(hue_LCT001_0017881ca34a_3, ON)
                }
                sendCommand(Hallway_Movement, CLOSED)

                if (waitTimer != null) {
                        logInfo("rules", "Hallway light cancelling timer")
                        waitTimer.cancel
                }

                waitTimer = createTimer(now.plusMinutes(2))[|
                        logInfo("rules", "Hallway light sendCommand(hue_LCT001_0017881ca34a_3, OFF)")
                        sendCommand(hue_LCT001_0017881ca34a_3, OFF)
                        lightIsOn = false
                ]
        }

end

This rule is currnetly not triggereda although i see in the logs:

2015-09-23 21:17:26.537 [INFO ] [runtime.busevents ] - Hallway_Movement state updated to OPEN

I have the same romo for another room and it is currently working fine. Also this rule worked for a while and then stopped working after a restart of openhab2.

Am i doing something wrong?

I found out that the imports are for the openhab1 and have changed in openhab2 due to the move to eclipse smart home. But it is also not longer necessary to import standard classes, see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=425456

You are right, the default imports are not required anymore, but they also should not harm.

Are these rules that you were successfully using on openHAB 1 and you never had problems there?
I have no good idea what the problem might be.
To analyze a bit further, you might want to reduce your trigger condition to Item Hallway_Movement changed to OPEN or even Item Hallway_Movement changed and see if this is triggered more reliably.

Regards,
Kai

Hi Kai,
thanks for the reply.

I just started testing openhab and directly used openhab2. I made some smaller tests with openhab1 but also had problems. Could be because of the hue lamps items file i build for openhab1. In openhab2 i did not need that, becuase they there autodetected.

I made a lot of different tests. Also i tested on just changed or updated and different item types. But everytime i had the same problem. It sometimes works and sometimes not.

I am currently hoping that the zwave binding for openhab2 (ZWave status under OH2) may help.

Regards
Mike

Hi Mike,

For rules it should not matter at all, which bindings are used - they are defined and triggered completely independent from them.
So the best is trying to find a reproducible scenario, where a rule is not triggered although you would expect it to. With such a setup, one can then step through the rule engine code with the debugger to see what is happening exactly.

Regards,
Kai

Hi Kai,
i found some time to try it but unfortunately i am not able to set it up. I followed the guide from https://github.com/openhab/openhab2/blob/master/docs/sources/development/ide.md but did not manage to have the z-wave binding in there. It seemed that most bindings are available if i use “openhab2 dev” instead of “openHAB_with_ESH” but still not everything seemed to be available.

Al least the configuration seems to be read.

I will try again if i find some time.

Regards
Mike

Hi Kai,
i found some time to try it but unfortunately i am not able to set it up. I followed the guide from https://github.com/openhab/openhab2/blob/master/docs/sources/development/ide.md but if i start it it has 100 Errors

But i played a bit arround with the config files. It seems to be constantly working now, even after a restart.

The only thing i did not manage to setup was the KFOB remote. Otherwise all three motion detectors are working.

I would really like to have improved error reporting on rules. If you get an error it only states that there is an error, but the line in the script seems not to be logged. Is there a way to do this?

Regards
Mike