Openhab 3 - Rule does not trigger

Hello all,

I have rebuilt my Openhab 3 and now it does not want to fully execute my previous working programming.

I have number items for the status of the control commands in the shuttercommands.rules, which trigger rules in the shuttercontrol.rules. Unfortunately, only the number items are set, but the rules in shuttercontrol.rules are not triggered.

Haus.items

Rollershutter KG_Rollladen_Buero "KG Rollladen Büro"
Number KG_Rollladen_Buero_UP
Number KG_Rollladen_Buero_DOWN
Number KG_Rollladen_Buero_STOP
_____________________________________________
Rollladenbefehle.rules

rule "KG Rollladen Buero HOCH/RUNTER/STOP"
when
    Item KG_Rollladen_Buero received command
then
        switch(receivedCommand.toString.toUpperCase){
            case "UP": {
             KG_Rollladen_Buero_UP.postUpdate(1)
             logInfo ("KG-R-B-UP - check", "Variablenstatus ist: " + KG_Rollladen_Buero_UP.state )
            }
            case "STOP": {
             KG_Rollladen_Buero_UP.postUpdate(0)
             KG_Rollladen_Buero_DOWN.postUpdate(0)
             logInfo ("KG-R-B-STOP - check", "Variablenstatus ist: " + KG_Rollladen_Buero_STOP.state )
             sendCommand (ArduMEGA, '<KG_Rollladen_Buero_STOP,>');
             KG_Rollladen_Buero_STOP.postUpdate(1)
            }
            case "DOWN": {
             KG_Rollladen_Buero_DOWN.postUpdate(1)
             logInfo ("KG-R-B-DOWN - check", "Variablenstatus ist: " + KG_Rollladen_Buero_DOWN.state )             
            }      
        } 
end
_____________________________________________
Rollladensteuerung.rules

rule "KG_Rollladen_Buero_UP"
when
    Item KG_Rollladen_Buero_UP received update or
    Item KG_Rollladen_Buero_UP changed or
    Time cron "0 0/1 * 1/1 * ? *"  //every Minute 
then
	createTimer(now.plusSeconds(2)) [|
		if (KG_Rollladen_Buero_UP.state == 1 && KG_Rollladen_Buero_STOP.state == 1){
				KG_Rollladen_Buero_STOP.postUpdate(0)
				 logInfo("KG-R-B-UP if ausgeführt", "Variablenstatus ist: ", KG_Rollladen_Buero_UP.state.toString )
				 sendCommand(ArduMEGA, "<KG_Rollladen_Buero_UP,>");
				 createTimer(now.plusSeconds(40)) [| 
					KG_Rollladen_Buero_UP.postUpdate(0) 
					sendCommand(KG_Rollladen_Buero, STOP)
				 ]
    }]
end 

You do not have logging entry direct after ‘then’ in your rules … How do you know that the rules are not triggered at all ? E.g. your second rule should / must be triggered as it has a cron entry so thte state of variables in the if resp. switch / case must have other values as expected ?
Add more logging entries in your rule to get more information about what is going on.

Hello Wolfgang_S,

I’ve been busy with business and just getting back to programming, sorry.
I will have more information texts generated.

Following are the error messages when I reboot the Raspberry:

2021-04-02 16:11:30.942 [WARN ] [org.eclipse.jetty.server.HttpChannel] - /rest/sitemaps/events/subscribe

java.lang.NullPointerException: null

	at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267) ~[?:?]

	at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234) ~[?:?]

	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) ~[?:?]

	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160) ~[?:?]

	at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:216) ~[?:?]

	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301) ~[?:?]

	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:220) ~[?:?]

	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) ~[bundleFile:3.1.0]

	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:276) ~[?:?]

	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:852) ~[bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:544) ~[bundleFile:9.4.20.v20190813]

	at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71) ~[bundleFile:?]

	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) ~[bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:536) ~[bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235) ~[bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1581) ~[bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1307) ~[bundleFile:9.4.20.v20190813]

	at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:293) ~[bundleFile:?]

	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) ~[bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:482) ~[bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549) ~[bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) ~[bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1204) ~[bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) ~[bundleFile:9.4.20.v20190813]

	at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80) ~[bundleFile:?]

	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.Server.handle(Server.java:494) ~[bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:135) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782) [bundleFile:9.4.20.v20190813]

	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918) [bundleFile:9.4.20.v20190813]

	at java.lang.Thread.run(Thread.java:834) [?:?]

Earlier, the roller shutters in the office and on the terrace worked, and then nothing worked when I tried to integrate the 3rd roller shutter in the living room couch. Again, no error message is displayed, but no commands are sent to the Arduino except for the STOP functions.

.rule 1
var Timer t_Rolllaeden = null

rule "KG Rollladen Buero HOCH/RUNTER/STOP"
when
    Item KG_Rollladen_Buero received command
then
        switch(receivedCommand.toString.toUpperCase){
            case "UP": {
			 KG_Rollladen_Buero_UP.postUpdate(1)
             logInfo ("KG-R-B-UP - check", "Variablenstatus ist: " + KG_Rollladen_Buero_UP.state)
            }
			
            case "STOP": {
             KG_Rollladen_Buero_UP.postUpdate(0)
			    logInfo ("KG-R-B-UP - check", "Variablenstatus ist: " + KG_Rollladen_Buero_UP.state)
             KG_Rollladen_Buero_DOWN.postUpdate(0)
                logInfo ("KG-R-B-DOWN - check", "Variablenstatus ist: " + KG_Rollladen_Buero_DOWN.state)    
			 sendCommand (ArduMEGA, "<KG_Rollladen_Buero_STOP,>");
             KG_Rollladen_Buero_STOP.postUpdate(1)
			 logInfo ("KG-R-B-STOP - check", "Variablenstatus ist: " + KG_Rollladen_Buero_STOP.state)
            }
			
            case "DOWN": {
			 KG_Rollladen_Buero_DOWN.postUpdate(1)
             logInfo ("KG-R-B-DOWN - check", "Variablenstatus ist: " + KG_Rollladen_Buero_DOWN.state)             
            }      
        } 
end


rule "EG Rollladen Terrasse HOCH/RUNTER/STOP"
when
    Item EG_Rollladen_Terrasse received command
then
        switch(receivedCommand.toString.toUpperCase){
            case "UP": {
             EG_Rollladen_Terrasse_UP.postUpdate(1)
             logInfo ("EG-R-T-UP - check", "Variablenstatus ist: " + EG_Rollladen_Terrasse_UP.state)   
			}
            
            case "STOP": {
             EG_Rollladen_Terrasse_UP.postUpdate(0)
			    logInfo ("EG-R-T-UP - check", "Variablenstatus ist: " + EG_Rollladen_Terrasse_UP.state) 
             EG_Rollladen_Terrasse_DOWN.postUpdate(0)
                logInfo ("EG-R-T-DOWN - check", "Variablenstatus ist: " + EG_Rollladen_Terrasse_DOWN.state)   
			 sendCommand (ArduMEGA, "<EG_Rollladen_Terrasse_STOP,>");
			  t_Rolllaeden = null
			  t_Rolllaeden = createTimer (now.plusSeconds(1), [
				sendCommand (ArduMEGA, "<EG_Rollladen_Terrasse_U_E,>");
				sendCommand (ArduMEGA, "<EG_Rollladen_Terrasse_D_E,>");
					t_Rolllaeden = null
				 ])
             EG_Rollladen_Terrasse_STOP.postUpdate(1)
			 logInfo ("EG-R-T-STOP - check", "Variablenstatus ist: " + EG_Rollladen_Terrasse_STOP.state)
            }
			
            case "DOWN": {
             EG_Rollladen_Terrasse_DOWN.postUpdate(1)
             logInfo ("EG-R-T-DOWN - check", "Variablenstatus ist: " + EG_Rollladen_Terrasse_DOWN.state)   		 
            }    
        } 
end


.rule 2
var Timer t_Rolllaeden = null

rule "KG_Rollladen_Buero_UPDOWN"
when
    Item KG_Rollladen_Buero_UP changed or
    Item KG_Rollladen_Buero_DOWN changed or
    Time cron "0 0/1 * 1/1 * ? *" 
then		
	t_Rolllaeden = createTimer (now.plusSeconds(2), [
		if (KG_Rollladen_Buero_UP.state == 1 && KG_Rollladen_Buero_STOP.state == 1 && EG_Rollladen_Terrasse_STOP.state == 1 && EG_Rollladen_Wohnzimmer_Couch_STOP.state == 1 && EG_Rollladen_Esszimmer_STOP.state == 1 && EG_Rollladen_Kueche_Einfahrt_STOP.state == 1 && EG_Rollladen_Kueche_Strasse_STOP.state == 1 && OG_Rollladen_Zimmer_Strasse_STOP.state == 1 && OG_Rollladen_Zimmer_Garten_STOP.state == 1 && OG_Rollladen_Bad_STOP.state == 1 && DG_Rollladen_Schlafzimmer_STOP.state == 1 && DG_Rollladen_Bad_STOP.state == 1){
			     t_Rolllaeden = null	
				 KG_Rollladen_Buero_STOP.postUpdate(0)
				 logInfo ("KG-R-B-UP if ausgeführt", "Variablenstatus ist: " + KG_Rollladen_Buero_UP.state )
				 sendCommand (ArduMEGA, "<KG_Rollladen_Buero_UP,>");
				 
				 t_Rolllaeden = createTimer (now.plusSeconds(40), [
					KG_Rollladen_Buero_UP.postUpdate(0) 
					sendCommand (KG_Rollladen_Buero, STOP)
					t_Rolllaeden = null
				 ])
        }
        else if (KG_Rollladen_Buero_DOWN.state == 1 && KG_Rollladen_Buero_STOP.state == 1 && EG_Rollladen_Terrasse_STOP.state == 1 && EG_Rollladen_Wohnzimmer_Couch_STOP.state == 1 && EG_Rollladen_Esszimmer_STOP.state == 1 && EG_Rollladen_Kueche_Einfahrt_STOP.state == 1 && EG_Rollladen_Kueche_Strasse_STOP.state == 1 && OG_Rollladen_Zimmer_Strasse_STOP.state == 1 && OG_Rollladen_Zimmer_Garten_STOP.state == 1 && OG_Rollladen_Bad_STOP.state == 1 && DG_Rollladen_Schlafzimmer_STOP.state == 1 && DG_Rollladen_Bad_STOP.state == 1){
                    t_Rolllaeden = null
                    KG_Rollladen_Buero_STOP.postUpdate(0)
                    logInfo ("KG-R-B-DOWN if ausgeführt", "Variablenstatus ist: " + KG_Rollladen_Buero_DOWN.state )
                    sendCommand (ArduMEGA, "<KG_Rollladen_Buero_DOWN,>");

                    t_Rolllaeden = createTimer (now.plusSeconds(40), [
                        KG_Rollladen_Buero_DOWN.postUpdate(0) 
                        sendCommand (KG_Rollladen_Buero, STOP)
                        t_Rolllaeden = null
                ])
    }])
end 



rule "EG_Rollladen_Terrasse_UPDOWN"
when
    Item EG_Rollladen_Terrasse_UP changed or
    Item EG_Rollladen_Terrasse_DOWN changed or
    Time cron "0 0/1 * 1/1 * ? *"
then	
	t_Rolllaeden = null
    t_Rolllaeden = createTimer (now.plusSeconds(3), [
		if (EG_Rollladen_Terrasse_UP.state == 1 && KG_Rollladen_Buero_STOP.state == 1 && EG_Rollladen_Terrasse_STOP.state == 1 && EG_Rollladen_Wohnzimmer_Couch_STOP.state == 1 && EG_Rollladen_Esszimmer_STOP.state == 1 && EG_Rollladen_Kueche_Einfahrt_STOP.state == 1 && EG_Rollladen_Kueche_Strasse_STOP.state == 1 && OG_Rollladen_Zimmer_Strasse_STOP.state == 1 && OG_Rollladen_Zimmer_Garten_STOP.state == 1 && OG_Rollladen_Bad_STOP.state == 1 && DG_Rollladen_Schlafzimmer_STOP.state == 1 && DG_Rollladen_Bad_STOP.state == 1){
				t_Rolllaeden = null
				 EG_Rollladen_Terrasse_STOP.postUpdate(0)
				 logInfo ("EG-R-T-UP if ausgeführt", "Variablenstatus ist: " + EG_Rollladen_Terrasse_UP.state )
                 sendCommand (ArduMEGA, "<EG_Rollladen_Terrasse_U_V,>");
                 sendCommand (ArduMEGA, "<EG_Rollladen_Terrasse_D_V,>");
				t_Rolllaeden = createTimer (now.plusSeconds(1), [
					sendCommand (ArduMEGA, "<EG_Rollladen_Terrasse_UP,>");
					t_Rolllaeden = null
				])
				t_Rolllaeden = createTimer (now.plusSeconds(40), [ 
					EG_Rollladen_Terrasse_UP.postUpdate(0) 
					sendCommand (EG_Rollladen_Terrasse, STOP)
					t_Rolllaeden = null
				])
        }
        else if (EG_Rollladen_Terrasse_DOWN.state == 1 && KG_Rollladen_Buero_STOP.state == 1 && EG_Rollladen_Terrasse_STOP.state == 1 && EG_Rollladen_Wohnzimmer_Couch_STOP.state == 1 && EG_Rollladen_Esszimmer_STOP.state == 1 && EG_Rollladen_Kueche_Einfahrt_STOP.state == 1 && EG_Rollladen_Kueche_Strasse_STOP.state == 1 && OG_Rollladen_Zimmer_Strasse_STOP.state == 1 && OG_Rollladen_Zimmer_Garten_STOP.state == 1 && OG_Rollladen_Bad_STOP.state == 1 && DG_Rollladen_Schlafzimmer_STOP.state == 1 && DG_Rollladen_Bad_STOP.state == 1){
                t_Rolllaeden = null
                EG_Rollladen_Terrasse_STOP.postUpdate(0)
                logInfo ("EG-R-T-DOWN if ausgeführt", "Variablenstatus ist: " + EG_Rollladen_Terrasse_DOWN.state )
                 sendCommand (ArduMEGA, "<EG_Rollladen_Terrasse_U_V,>");
                 sendCommand (ArduMEGA, "<EG_Rollladen_Terrasse_D_V,>");
				 
				t_Rolllaeden = createTimer (now.plusSeconds(1), [
					sendCommand (ArduMEGA, "<EG_Rollladen_Terrasse_DOWN,>");
					t_Rolllaeden = null
				])
                
                t_Rolllaeden = createTimer (now.plusSeconds(40), [ 
                    EG_Rollladen_Terrasse_DOWN.postUpdate(0) 
                    sendCommand (EG_Rollladen_Terrasse, STOP)
					t_Rolllaeden = null
                ])
        }
        ])
end 

Make sure you are running the correct version of Java.
My rules did not want to fire with Java 16. Worked again when i went down to Java 11.