[SOLVED] Rules start only after rewrite the rule file

Hello I work with rules to connect Hue-devices with my LCN bus. For that purpose I create a set of rule-files, where I switch on/off an individual hue bulb, or increase/decrease the brightness. When I get working the rules ones they work fine.

After restarting the openhabian, adding an additional rule or add a new item or thing the rules stop working. In this situation I have to rewrite the rules files for all rules again with some little modifications like inserting a blank line - so there is no change inside the rules itself. After that I have to trigger the rules several times until the “fire” the first time, after that the work. Inside the log I can the each trigger event I bring on through the LCN bus, so this is the only positive thing, the LCN connection works fine and the LCN-Things are defined correctly … :smirk:

It was not possible for me to discover the mystic behind this behavior, but it seems not be correct … and it starts to annoy me … more and more :angry:.

Has anyone an idea, where there might be a problem ? Am I the only one with this problem ?

Thanks and best regards
Stef

Are there any entries in the log-file?

From my point of view there is no reported problem inside the logfiles that has anything to do with rules … :confused:

Are there any problems reported at all? Any error can impact the running of rules.

Are you seeing all the events that are supposed to trigger the rules in events.log? If the events don’t occur the rides won’t run.

Do you have long Thread::sleep or other calls that block like send http requests or executeCommandLine or loops that wait for something to happen. There is a small number of execution threads available and if you happen to have rules blocking you can run it if threads and your roles will stop executing.

Hello rlkoshak,

I restarted openhabian twice to watch at the log output. There are 3 warnings

2018-04-02 12:50:50.156 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'hue.things' is either empty or cannot be parsed correctly!
2018-04-02 12:54:18.600 [WARN ] [eclipse.jetty.servlet.ServletHandler] - 
2018-04-02 12:54:19.137 [WARN ] [org.eclipse.jetty.server.HttpChannel] - //openhabianpi:8080/rest/items

and no error messages. If I filter out all messages include statements with rules I discover the following

2018-04-02 12:53:17.314 [DEBUG] [mpl.info.InfoBundleTrackerCustomizer] - Ignore incorrect info null provided by bundle org.eclipse.smarthome.model.rule
2018-04-02 12:53:17.327 [DEBUG] [mpl.info.InfoBundleTrackerCustomizer] - Ignore incorrect info null provided by bundle org.eclipse.smarthome.model.rule.ide
2018-04-02 12:53:17.365 [DEBUG] [mpl.info.InfoBundleTrackerCustomizer] - Ignore incorrect info null provided by bundle org.eclipse.smarthome.model.rule.runtime
2018-04-02 12:53:35.127 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'Wohnzimmer_hue.rules'
2018-04-02 12:53:41.609 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'Esszimmer_hue.rules'
2018-04-02 12:53:47.961 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'Arbeitszimmer_hue.rules'
2018-04-02 12:53:48.486 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'WC_Licht.rules'
2018-04-02 12:53:56.955 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'Esstisch_hue.rules'
2018-04-02 12:54:03.479 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'Schlafzimmer_hue.rules'

Here you can see one of my rule-files (arbeitszimmer.rules)

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


import org.openhab.core.library.types.HSBType

var boolean BrightnessLoop 		= false		// Modify brightness until DimmLoop = false    
var boolean BrightnessDirection = false		// false = up, true = down
var int		BrightnessStep		= 2			// Unit is %
var Number	BrightnessSpeed		= 100		// Defines the interval to increse/decrease Unit is ms

var boolean ColorLoop 			= false    	// Modify color until ColorLoop = false
var boolean ColorDirection		= false		// false = inkrement, true = decrement
var int		ColorStep 			= 2			// Unit is °
var int		ColorSpeed			= 100		// Defines the interval to increse/decrease Unit is ms

// -------------------------------------------------------------------------------------------------------------
// Switch Light ON/OFF : Controlled by Modul 11, Relay 1
// 

rule "LightON"
    when   
            Item LCN_AZ_SW_Relay_HUE_Switch changed from NULL or
			Item LCN_AZ_SW_Relay_HUE_Switch changed from OFF or
            Item LCN_AZ_SW_Relay_HUE_Switch changed from ON
    then   
           	var HSBType currentState = HueLamp2Color.state
           	
//			logInfo("ON/OFF CurrentBrightness", String::format ("brightness = %d", currentState.brightness.intValue))
           	if (currentState.brightness.intValue == 0) {
           		HueLamp2Color.sendCommand(ON)
           		BrightnessDirection = true
           	}
           	else {
	           	HueLamp2Color.sendCommand (OFF)
    	       	BrightnessDirection = false
   	       	}
    end

// -------------------------------------------------------------------------------------------------------------
// Modify the Brightness (0 to 100%) : Controlled by Modul 11, Relay 2
//
  
rule "ChangeBrightness"
	when
			Item LCN_AZ_SW_Relay_HUE_Brightness changed from OFF to ON
	then
			BrightnessLoop = true 
			var HSBType currentState = HueLamp2Color.state
			
			var	DecimalType	hueVal	= currentState.getHue()			//
			var PercentType sat 	= currentState.getSaturation()	// new PercentType(100) // 0-100
			var	int brightness		= currentState.brightness.intValue
			while (BrightnessLoop == true) {
				if (BrightnessDirection == false) {
					if ((brightness += BrightnessStep) > 100)
						brightness = 100				}
				else {
					if ((brightness -= BrightnessStep) < 0)
						brightness = 0
				}
				logInfo("ChangeBrightness", String::format ("brightness = %d", brightness))
				HueLamp2Color.sendCommand(new HSBType(hueVal, sat, new PercentType(brightness)))
				Thread::sleep(BrightnessSpeed)
			}
	end
	
rule "StopChangeBrightness"
	when
			Item LCN_AZ_SW_Relay_HUE_Brightness changed from ON to OFF
	then
			BrightnessLoop = false
			if (BrightnessDirection == true)
				BrightnessDirection = false
			else
				BrightnessDirection = true
	end  

// -------------------------------------------------------------------------------------------------------------
// Modify the Color(angle of color) 0-360° : Controlled by Modul 11, Relay 3
//
  
rule "ChangeColor"
	when
			Item LCN_AZ_SW_Relay_HUE_Color changed from OFF to ON
	then
			ColorLoop = true 
			var HSBType currentState = HueLamp2Color.state
			
			var	int color			= currentState.hue.intValue
			var PercentType sat 	= currentState.getSaturation()	// new PercentType(100) // 0-100
			var PercentType bright	= currentState.getBrightness()	// new PercentType(100) // 0-100
			while (ColorLoop == true) {
				if (ColorDirection == false) {
					if ((color += ColorStep) > 360)
						color = 0
				}
				else {
					if ((color -= ColorStep) < 0)
						color = 360
				}
//				logInfo("changeColor", String::format ("color = %d", color))
				HueLamp2Color.sendCommand(new HSBType(new DecimalType(color), sat, bright))
				Thread::sleep(ColorSpeed)
			}
	end
	
rule "StopChangeColor"
	when
			Item LCN_AZ_SW_Relay_HUE_Color changed from ON to OFF
	then
			ColorLoop = false
			if (ColorDirection == true)
				ColorDirection = false
			else
				ColorDirection = true
	end

... and here are some events that should trigger the rule ...

> 2018-04-02 13:04:28.498 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Switch changed from OFF to ON
> 2018-04-02 13:04:29.506 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Switch changed from ON to OFF
> 2018-04-02 13:04:29.701 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Switch changed from OFF to ON
> 2018-04-02 13:04:30.599 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Brightness changed from OFF to ON
> 2018-04-02 13:04:31.732 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Brightness changed from ON to OFF
> 2018-04-02 13:04:33.008 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Brightness changed from OFF to ON
> 2018-04-02 13:04:34.006 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Brightness changed from ON to OFF
> 2018-04-02 13:04:35.114 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Switch changed from ON to OFF
> 2018-04-02 13:04:36.007 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Switch changed from OFF to ON
> 2018-04-02 13:04:36.694 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Switch changed from ON to OFF
> 2018-04-02 13:04:37.498 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Switch changed from OFF to ON
> 2018-04-02 13:04:38.512 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Switch changed from ON to OFF
> 2018-04-02 13:04:39.526 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Brightness changed from OFF to ON
> 2018-04-02 13:04:41.499 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Brightness changed from ON to OFF
> 2018-04-02 13:04:42.523 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Brightness changed from OFF to ON
> 2018-04-02 13:04:43.627 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Brightness changed from ON to OFF
> 2018-04-02 13:04:44.496 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Switch changed from OFF to ON

So if further information's are needed to solve this problem, please let me know an I will deliver them.

Thanks and best regards
Stefbert

Do those three warning lines occur together like that or did you remove other log statements? Please do not remove the other log statements as they provide context and are vital for interpreting the warning.

In particular, is there a “loading model hue.things model” (or something like that) after the warning?

This is not needed in OH 2 and actually does nothing because org.openhab.core.library.types no longer exists in OH 2. All of those classes have moved to a different package and are included by default.

It is not clear how these rules interact with each other or are complete. With your current settings “ChangeBrightness” can take over 5 seconds to complete and “ChangeColor” can take over 18 seconds to complete. And this appears to be for a single light. If you try to control more than one light with similar long-running rules you are going to run out of rule execution threads and your rules will grind to a halt. I suspect this is what is happening. Also, as written, your Rules might never exit at all until you manually stop the dimming/color changing because you don’t set BrightnessLoop to false once you reach the max/min brightness or color.

You need to use timers for this, not while loops and sleeps.

val Timer brightnessTimer = null
...

rule "ChangeBrightness"
when
    Item LCN_AZ_SW_Relay_HUE_Brightness changed from OFF to ON
then
    if(brightnessTimer != null) {
        logWarn("brightness", "The light is already dimming")
        return;
    }

    // start the loop almost immeidately
    brightnessTimer = createTimer(now.plusMillis(1), [ |
        if(BrightnessLoop) {
            val currBrightness = HueLam2Color.getStateAs(PercentType) as Number // get the brightness

            var nextBrightness = if(!BrightnessDirection) currBrightness + BrightnessStep else currBrightness - BrightnessStep
            if(nextBrightness > 100) {
                nextBrightness = 100
                BrightnessLoop = false // stop looping when we reach max brightness
            }
            if(nextBrightness < 0) {
                nextBrightness = 0
                BrightnessLoop = false // stop looping when we reach min brightness
            }

            logInfo("ChangeBrightness", nextBrightness.toString)
            HueLamp2Color.sendCommand(nextBrightness) // sending a single number in a command to a Color Item is treated as a Dimmer command

            brightnessThread.reschedule(now.plusMillis(100))
        }
        else {
            brightnessThread = null // we are done or cancelled
        }
    ])
end

Hello Rich,

thanks for the information’s. During the time while I hope that someone give me a hint like you, I tried to make the name’s inside my rules unique because till now I have just copied one file and modified the trigger conditions - so the Rule-Names appear in each file again. The result of this modification was, that the rules become faster available.
So this behavior results in a new questions about the naming conventions: Do all rules, spread over all rule-files, have to had unique rule-names, or is the scope of rule-name only inside the specific file? The same question exists for the variables defined at the beginning of an rule-file …

Okay, now to your modified sources. First, the good thing is, that the rule while “fire” after only some trigger-events. The less good thing is that I received a couple of failures. I have modified your code only by my new naming conventions to make everything unique …

var boolean AZ_BrightnessLoop 		= false		// Modify brightness until DimmLoop = false    
var boolean AZ_BrightnessDirection	= false		// false = up, true = down
var int		AZ_BrightnessStep		= 2			// Unit is %
var Number	AZ_BrightnessSpeed		= 100		// Defines the interval to increse/decrease Unit is ms

var boolean AZ_ColorLoop 			= false    	// Modify color until ColorLoop = false
var boolean AZ_ColorDirection		= false		// false = inkrement, true = decrement
var int		AZ_ColorStep 			= 2			// Unit is °
var int		AZ_ColorSpeed			= 100		// Defines the interval to increse/decrease Unit is ms

val Timer 	AZ_brightnessTimer 	= null

...

rule "AZ_ChangeBrightness"
	when
		Item LCN_AZ_SW_Relay_HUE_Brightness changed from OFF to ON
	then
    	if(AZ_brightnessTimer !== null) {
        	logWarn("brightness", "The light is already dimming")
        return;
    	}
    	// start the loop almost immeidately
    	AZ_brightnessTimer = createTimer(now.plusMillis(1), [ |
        	if(AZ_BrightnessLoop) {
            	val currBrightness = HueLam2Color.getStateAs(PercentType) as Number // get the brightness

            	var nextBrightness = if(!AZ_BrightnessDirection) currBrightness + AZ_BrightnessStep else currBrightness - AZ_BrightnessStep
            	if(nextBrightness > 100) {
                	nextBrightness = 100
               		AZ_BrightnessLoop = false // stop looping when we reach max brightness
            	}
            	if(nextBrightness < 0) {
                	nextBrightness = 0
                	AZ_BrightnessLoop = false // stop looping when we reach min brightness
            	}

            	logInfo("ChangeBrightness", nextBrightness.toString)
            	HueLamp2Color.sendCommand(nextBrightness) // sending a single number in a command to a Color Item is treated as a Dimmer command

           		brightnessThread.reschedule(now.plusMillis(100))
        	}
        	else {
            	brightnessThread = null // we are done or cancelled
        	}
    	])
end
2018-04-02 19:34:20.401 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'Arbeitszimmer_hue.rules'
2018-04-02 19:34:20.444 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'Arbeitszimmer_hue.rules' is either empty or cannot be parsed correctly!
2018-04-02 19:34:26.014 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'Arbeitszimmer_hue.rules', using it anyway:
Constant condition is always false.
Assignment to final field
2018-04-02 19:34:26.025 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'Arbeitszimmer_hue.rules'

==> /var/log/openhab2/events.log <==
2018-04-02 19:34:52.304 [vent.ItemStateChangedEvent] - ntp_ntp_local_dateTime changed from 2018-04-02T19:33:52.266+0200 to 2018-04-02T19:34:52.278+0200
2018-04-02 19:34:52.314 [vent.ItemStateChangedEvent] - current_Date changed from 2018-04-02T19:33:52.266+0200 to 2018-04-02T19:34:52.278+0200
2018-04-02 19:34:52.335 [vent.ItemStateChangedEvent] - current_Time changed from 2018-04-02T19:33:52.266+0200 to 2018-04-02T19:34:52.278+0200
2018-04-02 19:34:53.701 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Switch changed from ON to OFF
2018-04-02 19:34:54.698 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Switch changed from OFF to ON
2018-04-02 19:34:55.810 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Switch changed from ON to OFF
2018-04-02 19:34:56.631 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Switch changed from OFF to ON
2018-04-02 19:34:57.607 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Brightness changed from OFF to ON
2018-04-02 19:34:58.157 [ome.event.ItemCommandEvent] - Item 'HueLamp2Color' received command OFF
2018-04-02 19:34:58.178 [ome.event.ItemCommandEvent] - Item 'HueLamp2Color' received command OFF
2018-04-02 19:34:58.186 [ome.event.ItemCommandEvent] - Item 'HueLamp2Color' received command OFF

==> /var/log/openhab2/openhab.log <==

2018-04-02 19:34:58.194 [ERROR] [org.quartz.core.JobRunShell         ] - Job DEFAULT.2018-04-02T19:34:58.145+02:00: Proxy for org.eclipse.xtext.xbase.lib.Procedures$Procedure0: [ | {
  org.eclipse.xtext.xbase.impl.XIfExpressionImpl@1201080
} ] threw an unhandled Exception: 

java.lang.IllegalArgumentException: Couldn't invoke 'assignValueTo' for feature JvmVoid:  (eProxyURI: Arbeitszimmer_hue.rules#|::0.2.1.2.0.1.7.6.1.1.0.0.2.0.0::0::/1)
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.assignValueTo(XbaseInterpreter.java:1224) [164:org.eclipse.xtext.xbase:2.12.0.v20170519-0752]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:1212) [164:org.eclipse.xtext.xbase:2.12.0.v20170519-0752]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:215) [164:org.eclipse.xtext.xbase:2.12.0.v20170519-0752]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:215) [145:org.eclipse.smarthome.model.script:0.10.0.b1]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) [164:org.eclipse.xtext.xbase:2.12.0.v20170519-0752]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:446) [164:org.eclipse.xtext.xbase:2.12.0.v20170519-0752]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:227) [164:org.eclipse.xtext.xbase:2.12.0.v20170519-0752]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:215) [145:org.eclipse.smarthome.model.script:0.10.0.b1]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) [164:org.eclipse.xtext.xbase:2.12.0.v20170519-0752]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:463) [164:org.eclipse.xtext.xbase:2.12.0.v20170519-0752]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:243) [164:org.eclipse.xtext.xbase:2.12.0.v20170519-0752]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:215) [145:org.eclipse.smarthome.model.script:0.10.0.b1]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) [164:org.eclipse.xtext.xbase:2.12.0.v20170519-0752]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:446) [164:org.eclipse.xtext.xbase:2.12.0.v20170519-0752]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:227) [164:org.eclipse.xtext.xbase:2.12.0.v20170519-0752]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:215) [145:org.eclipse.smarthome.model.script:0.10.0.b1]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) [164:org.eclipse.xtext.xbase:2.12.0.v20170519-0752]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:189) [164:org.eclipse.xtext.xbase:2.12.0.v20170519-0752]
	at org.eclipse.xtext.xbase.interpreter.impl.ClosureInvocationHandler.doInvoke(ClosureInvocationHandler.java:46) [164:org.eclipse.xtext.xbase:2.12.0.v20170519-0752]
	at org.eclipse.xtext.xbase.interpreter.impl.AbstractClosureInvocationHandler.invoke(AbstractClosureInvocationHandler.java:29) [164:org.eclipse.xtext.xbase:2.12.0.v20170519-0752]
	at com.sun.proxy.$Proxy151.apply(Unknown Source) [?:?]
	at org.eclipse.smarthome.model.script.internal.actions.TimerExecutionJob.execute(TimerExecutionJob.java:49) [145:org.eclipse.smarthome.model.script:0.10.0.b1]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [115:org.eclipse.smarthome.core.scheduler:0.10.0.b1]
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [115:org.eclipse.smarthome.core.scheduler:0.10.0.b1]

==> /var/log/openhab2/events.log <==

2018-04-02 19:34:58.240 [ome.event.ItemCommandEvent] - Item 'HueLamp2Color' received command OFF

==> /var/log/openhab2/openhab.log <==

2018-04-02 19:34:58.201 [ERROR] [org.quartz.core.ErrorLogger         ] - Job (DEFAULT.2018-04-02T19:34:58.145+02:00: Proxy for org.eclipse.xtext.xbase.lib.Procedures$Procedure0: [ | {
  org.eclipse.xtext.xbase.impl.XIfExpressionImpl@1201080
} ] threw an exception.

org.quartz.SchedulerException: Job threw an unhandled exception.
	at org.quartz.core.JobRunShell.run(JobRunShell.java:213) [115:org.eclipse.smarthome.core.scheduler:0.10.0.b1]
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [115:org.eclipse.smarthome.core.scheduler:0.10.0.b1]
Caused by: java.lang.IllegalArgumentException: Couldn't invoke 'assignValueTo' for feature JvmVoid:  (eProxyURI: Arbeitszimmer_hue.rules#|::0.2.1.2.0.1.7.6.1.1.0.0.2.0.0::0::/1)
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.assignValueTo(XbaseInterpreter.java:1224) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:1212) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:215) ~[?:?]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:215) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:446) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:227) ~[?:?]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:215) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:463) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:243) ~[?:?]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:215) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:446) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:227) ~[?:?]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:215) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:189) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.ClosureInvocationHandler.doInvoke(ClosureInvocationHandler.java:46) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.AbstractClosureInvocationHandler.invoke(AbstractClosureInvocationHandler.java:29) ~[?:?]
	at com.sun.proxy.$Proxy151.apply(Unknown Source) ~[?:?]
	at org.eclipse.smarthome.model.script.internal.actions.TimerExecutionJob.execute(TimerExecutionJob.java:49) ~[?:?]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202) ~[?:?]
	... 1 more

==> /var/log/openhab2/events.log <==
2018-04-02 19:34:58.371 [vent.ItemStateChangedEvent] - HueLamp2Color changed from 45,100,100 to 45,100,0
2018-04-02 19:34:58.601 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Brightness changed from ON to OFF
2018-04-02 19:35:00.607 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Switch changed from ON to OFF
2018-04-02 19:35:00.635 [ome.event.ItemCommandEvent] - Item 'HueLamp2Color' received command ON
2018-04-02 19:35:00.661 [vent.ItemStateChangedEvent] - HueLamp2Color changed from 45,100,0 to 45,100,100
2018-04-02 19:35:03.197 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Brightness changed from OFF to ON

==> /var/log/openhab2/openhab.log <==
2018-04-02 19:35:03.228 [WARN ] [se.smarthome.model.script.brightness] - The light is already dimming

==> /var/log/openhab2/events.log <==
2018-04-02 19:35:04.626 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Brightness changed from ON to OFF
2018-04-02 19:35:05.604 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Switch changed from OFF to ON
2018-04-02 19:35:05.638 [ome.event.ItemCommandEvent] - Item 'HueLamp2Color' received command OFF
2018-04-02 19:35:05.659 [vent.ItemStateChangedEvent] - HueLamp2Color changed from 45,100,100 to 45,100,0
2018-04-02 19:35:07.618 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Brightness changed from OFF to ON

==> /var/log/openhab2/openhab.log <==
2018-04-02 19:35:07.633 [WARN ] [se.smarthome.model.script.brightness] - The light is already dimming

==> /var/log/openhab2/events.log <==
2018-04-02 19:35:07.719 [vent.ItemStateChangedEvent] - hue_0210_0017886f0a4a_2_color changed from 45,100,68 to 45,100,0
2018-04-02 19:35:10.117 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Brightness changed from ON to OFF
2018-04-02 19:35:11.619 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Brightness changed from OFF to ON

==> /var/log/openhab2/openhab.log <==
2018-04-02 19:35:11.631 [WARN ] [se.smarthome.model.script.brightness] - The light is already dimming

==> /var/log/openhab2/events.log <==
2018-04-02 19:35:12.802 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Brightness changed from ON to OFF
2018-04-02 19:35:13.796 [vent.ItemStateChangedEvent] - LCN_AZ_SW_Relay_HUE_Switch changed from ON to OFF
2018-04-02 19:35:13.819 [ome.event.ItemCommandEvent] - Item 'HueLamp2Color' received command ON
2018-04-02 19:35:13.847 [vent.ItemStateChangedEvent] - HueLamp2Color changed from 45,100,0 to 45,100,100

Above you can the the code and the behavior of the trigger and the rule itself - I just deleted some blank lines to increase the readability.

Thanks for helping and best regards
Stef

Each Rule must have a unique name. That could have been another source of problems.

All Rules must have a unique name no matter what files they are defined in.

Add a try catch around the body of the timer to see what exception is being thrown.

AZ_brightnessTimer = createTimer(now.plusMillis(1), [ |
    try {
        // all the current code
    }
    catch(Exception e){
        logError("ChangeBrightness", e)
    }
])

Hello Rich,

I had in the last days some computer problems, so it wasn’t able for me to test or answer anything. I anhanced the code with the try-statement, but didn’t get any fortune. Bevor we go further within the code I’d like to read a little bit more about the used commands. So can you give me a link to the “rule-language-documentaion” where I can read something about createTimer and reschedule …

Thanks and best regards
Stef

See:

Hello Vincent,

thanks for the fast hint. At the link I can find some usefull informations, thanks for that, but isn’t a generell documentaion about the rules-language available ?

Thanks and best regards
Stef

Hello Rich,

I found the mistake, which is the reason for the errors I got. It’s just a little “naming-problem”. In your code advice you worte

brightnessThread.reschedule(now.plusMillis(100))

but ther is now variable or timer with this name, so the assignment runs to … an error.

So I just had to change the name to the correct one

AZ_BrightnessTimer.reschedule(now.plusMillis(100))

and everything works fine … after a few logical modifications … :wink:

Thanks an best regards
Stef

https://docs.openhab.org/configuration/rules-dsl.html
http://www.eclipse.org/xtend/

The second link is linked to from the first one.

However, many of the commands are add-on Actions which are documented at https://docs.openhab.org/addons/actions.html. This includes createTimer.

Hello Rich,

thanks for the informations … and again … thanks for your help :ok_hand::+1:

Best regards
Stef