ReentrantLock - Errors

Lambdas do not have access to global vars and vals. @rossko57 is right, you must pass the reentrant lock to the lambda.

And the link he provided is the source of your error. The last line of a lambda must either be an object, a primitive, or a call to a method that returns one of these. Nether Thread::sleep nor logInfo return anything (I.e. they return void) so they cannot be the last line executed in a lambda.

ok, i’ll try it.
did i use always the same lock for every rule who calls the lambda?

That is the purpose of the lock - if there is only one shared lock then only one thread can execute at a time, and the others have to wait their turn for the lock.

Railway enthusiasts will think of a “single line token”

Be careful to always release the lock.

so every rule is multithreaded, but the lambda is single-threaded for all rules-threads?

where the hell should i write the unlock? the rules are confusing me …

import org.openhab.core.library.types.*
import org.openhab.core.types.*
import org.eclipse.xtext.xbase.lib.*
import org.eclipse.smarthome.core.library.items.*
import java.util.Locale
import java.util.concurrent.locks.ReentrantLock


var java.util.concurrent.locks.ReentrantLock lock_rollo_lambda  = new java.util.concurrent.locks.ReentrantLock()



val Functions$Function4 rollo_lambda = 
[
    org.openhab.core.library.items.RollershutterItem rsiRollershutterItem,
    org.openhab.core.types.Command receivedCommand,
    org.openhab.core.library.items.StringItem rsiStatusItem,
    java.util.concurrent.locks.ReentrantLock lockThatLambda
|
	lockThatLambda.lock()

	// ardu02_out_20_13_P_06_07
	val int		_threadSleepTime	= 250
	var int		_whileExitCounter	= 0
	val int		_whileExitCountMax	= 20

	val _NameArray				= rsiRollershutterItem.name.split("_")
	val String	_rsiNodeName	= _NameArray.get(0)
	val String	_rsiDirecion	= _NameArray.get(1)
	val int		_rsiExpAddress	= Integer::parseInt(_NameArray.get(2))
	val int		_rsiExpBank		= Integer::parseInt(_NameArray.get(3))
	val String	_rsiPinIdent	= _NameArray.get(4) // ignore it
	val int		_rsiRelPower	= Integer::parseInt(_NameArray.get(5))
	val int		_rsiRelDirec	= Integer::parseInt(_NameArray.get(6))

	val String _strRelaisPower_On	= String::format("pinout:%1$d:%2$d:%3$d:1", _rsiExpAddress, _rsiExpBank, _rsiRelPower)
	val String _strRelaisPower_Off	= String::format("pinout:%1$d:%2$d:%3$d:0", _rsiExpAddress, _rsiExpBank, _rsiRelPower)

	val String _strRelaisDirec_On	= String::format("pinout:%1$d:%2$d:%3$d:1", _rsiExpAddress, _rsiExpBank, _rsiRelDirec)
	val String _strRelaisDirec_Off	= String::format("pinout:%1$d:%2$d:%3$d:0", _rsiExpAddress, _rsiExpBank, _rsiRelDirec)

	logInfo("rule.info", rsiRollershutterItem.name)
	logInfo("rule.info", rsiStatusItem.name)
	logInfo("rule.info", _strRelaisPower_On)
	logInfo("rule.info", _strRelaisPower_Off)
	logInfo("rule.info", _strRelaisDirec_On)
	logInfo("rule.info", _strRelaisDirec_Off)
	
	publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisPower_Off)

	while (rsiStatusItem.state == "1" && receivedCommand != STOP && _whileExitCounter < _whileExitCountMax)
	{
		logInfo("rule.info", "Warteschleife")
		Thread::sleep(500)
		publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisPower_Off)
		_whileExitCounter++
	}
	
	if (rsiStatusItem.state == "0" && receivedCommand != STOP)
	{
		if (receivedCommand == UP)				//  UP
		{
			Thread::sleep(_threadSleepTime)
			publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisDirec_On)
			Thread::sleep(_threadSleepTime)
			publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisPower_On)			
		}
		else if (receivedCommand == DOWN)		//  DOWN
		{
			Thread::sleep(_threadSleepTime)
			publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisDirec_Off)
			Thread::sleep(_threadSleepTime)
			publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisPower_On)			
		}
		lockThatLambda.unlock()   // <-- ERROR
	}
	else									// STOP
	{
		publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisPower_Off)
		Thread::sleep(_threadSleepTime)
		publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisDirec_Off)			
		lockThatLambda.unlock()   // <-- ERROR
	} 
	lockThatLambda.unlock()   // <-- ERROR
]



// 0x20 - 0x12

rule "rule_ardu02_out_20_12_P_00_01_received_command"
when
    Item ardu02_out_20_12_P_00_01 received command
then
	rollo_lambda.apply(ardu02_out_20_12_P_00_01, receivedCommand, ardu02_out_20_12_00_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_20_12_P_02_03_received_command"
when
    Item ardu02_out_20_12_P_02_03 received command
then
	rollo_lambda.apply(ardu02_out_20_12_P_02_03, receivedCommand, ardu02_out_20_12_02_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_20_12_P_04_05_received_command"
when
    Item ardu02_out_20_12_P_04_05 received command
then
	rollo_lambda.apply(ardu02_out_20_12_P_04_05, receivedCommand, ardu02_out_20_12_04_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_20_12_P_06_07_received_command"
when
    Item ardu02_out_20_12_P_06_07 received command
then
	rollo_lambda.apply(ardu02_out_20_12_P_06_07, receivedCommand, ardu02_out_20_12_06_stat, lock_rollo_lambda)
end

// 0x20 - 0x13

rule "rule_ardu02_out_20_13_P_00_01_received_command"
when
    Item ardu02_out_20_13_P_00_01 received command
then
	rollo_lambda.apply(ardu02_out_20_13_P_00_01, receivedCommand, ardu02_out_20_13_00_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_20_13_P_02_03_received_command"
when
    Item ardu02_out_20_13_P_02_03 received command
then
	rollo_lambda.apply(ardu02_out_20_13_P_02_03, receivedCommand, ardu02_out_20_13_02_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_20_13_P_04_05_received_command"
when
    Item ardu02_out_20_13_P_04_05 received command
then
	rollo_lambda.apply(ardu02_out_20_13_P_04_05, receivedCommand, ardu02_out_20_13_04_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_20_13_P_06_07_received_command"
when
    Item ardu02_out_20_13_P_06_07 received command
then
	rollo_lambda.apply(ardu02_out_20_13_P_06_07, receivedCommand, ardu02_out_20_13_06_stat, lock_rollo_lambda)
end

// 0x21 - 0x12

rule "rule_ardu02_out_21_12_P_00_01_received_command"
when
    Item ardu02_out_21_12_P_00_01 received command
then
	rollo_lambda.apply(ardu02_out_21_12_P_00_01, receivedCommand, ardu02_out_21_12_00_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_21_12_P_02_03_received_command"
when
    Item ardu02_out_21_12_P_02_03 received command
then
	rollo_lambda.apply(ardu02_out_21_12_P_02_03, receivedCommand, ardu02_out_21_12_02_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_21_12_P_04_05_received_command"
when
    Item ardu02_out_21_12_P_04_05 received command
then
	rollo_lambda.apply(ardu02_out_21_12_P_04_05, receivedCommand, ardu02_out_21_12_04_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_21_12_P_06_07_received_command"
when
    Item ardu02_out_21_12_P_06_07 received command
then
	rollo_lambda.apply(ardu02_out_21_12_P_06_07, receivedCommand, ardu02_out_21_12_06_stat, lock_rollo_lambda)
end

// 0x21 - 0x13

rule "rule_ardu02_out_21_13_P_00_01_received_command"
when
    Item ardu02_out_21_13_P_00_01 received command
then
	rollo_lambda.apply(ardu02_out_21_13_P_00_01, receivedCommand, ardu02_out_21_13_00_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_21_13_P_02_03_received_command"
when
    Item ardu02_out_21_13_P_02_03 received command
then
	rollo_lambda.apply(ardu02_out_21_13_P_02_03, receivedCommand, ardu02_out_21_13_02_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_21_13_P_04_05_received_command"
when
    Item ardu02_out_21_13_P_04_05 received command
then
	rollo_lambda.apply(ardu02_out_21_13_P_04_05, receivedCommand, ardu02_out_21_13_04_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_21_13_P_06_07_received_command"
when
    Item ardu02_out_21_13_P_06_07 received command
then
	rollo_lambda.apply(ardu02_out_21_13_P_06_07, receivedCommand, ardu02_out_21_13_06_stat, lock_rollo_lambda)
end

Only if you make it that way, using a lock.

Your lambda takes a long time to execute, as there are while and sleep in it. That makes it more likely that it will get fired off again before it has finished the last run. That may or may not be a problem, depending what it does. But your first post suggested that you had found that it was a problem for you.

At its simplest, you lock once at the beginning of your lambda, and unlock it at the end, once, as the last thing you do (just before the true it was recommended that you put as the last line of your lambda).

Rules are multithreaded in that you can have multiple instances of the she rule executing at any given time. Lambdas are multithreaded in the same way. What makes this single threaded is the reentrant lock. The lock ensures only one thread can run at a time and the rest are awaiting their turn to acquire the lock.

You should always use locks with try, catch, finally and unlock in the catch and the finally clause (I’ve had cases where the finally didn’t run). This makes sure that the lock will always be unlocked even if there is an exception.

try{
    lock.lock
    // Your code
}
catch(Throwable t){
    logError("lambda", "error in lambda: " + t)
    lock.unlock
}
finally {
    lock.unlock
}

that was the magic

i put it in

thanks for explanation.

i’ll change the rules and will come back if more error occurs … and i know they will :smile:

Thanks a lot so long

actually, nothing is working anymore :frowning:

Details?

Are you on OH 1 or OH 2? If OH 2 you should not be using anything from org.openhab.core. Don’t import these and don’t include these when referencing any class. org.openhab.core.library.items.RollershutterItem should just be RollerShutterItem.

Version OH 1.8.3

You may have to give a little more info.
If we’re going to have to go with wild guesses, you’ve messed up the try-catch-finally and now the reentrant lock is locked forever ?

[ERROR] [enhab.model.script.rule.lambda] - buhahuha
[ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule ‘rule_ardu02_out_20_12_P_00_01_received_command’: The name ‘.name’ cannot be resolved to an item or type.

import org.openhab.core.library.types.*
import org.openhab.core.types.*
import org.eclipse.xtext.xbase.lib.*
import org.eclipse.smarthome.core.library.items.*
import java.util.Locale
import java.util.concurrent.locks.ReentrantLock


var java.util.concurrent.locks.ReentrantLock lock_rollo_lambda  = new java.util.concurrent.locks.ReentrantLock()



val Functions$Function4 rollo_lambda = 
[
    RollershutterItem rsiRollershutterItem,
    org.openhab.core.types.Command receivedCommand,
    StringItem rsiStatusItem,
    java.util.concurrent.locks.ReentrantLock lockThatLambda
|
	//lockThatLambda.lock

	// ardu02_out_20_13_P_06_07
	val int		_threadSleepTime	= 250
	var int		_whileExitCounter	= 0
	val int		_whileExitCountMax	= 20

	val _NameArray				= rsiRollershutterItem.name.split("_")
	val String	_rsiNodeName	= _NameArray.get(0)
	val String	_rsiDirecion	= _NameArray.get(1)
	val int		_rsiExpAddress	= Integer::parseInt(_NameArray.get(2))
	val int		_rsiExpBank		= Integer::parseInt(_NameArray.get(3))
	val String	_rsiPinIdent	= _NameArray.get(4) // ignore it
	val int		_rsiRelPower	= Integer::parseInt(_NameArray.get(5))
	val int		_rsiRelDirec	= Integer::parseInt(_NameArray.get(6))

	val String _strRelaisPower_On	= String::format("pinout:%1$d:%2$d:%3$d:1", _rsiExpAddress, _rsiExpBank, _rsiRelPower)
	val String _strRelaisPower_Off	= String::format("pinout:%1$d:%2$d:%3$d:0", _rsiExpAddress, _rsiExpBank, _rsiRelPower)

	val String _strRelaisDirec_On	= String::format("pinout:%1$d:%2$d:%3$d:1", _rsiExpAddress, _rsiExpBank, _rsiRelDirec)
	val String _strRelaisDirec_Off	= String::format("pinout:%1$d:%2$d:%3$d:0", _rsiExpAddress, _rsiExpBank, _rsiRelDirec)

	logInfo("rule.info", rsiRollershutterItem.name)
	logInfo("rule.info", rsiStatusItem.name)
	logInfo("rule.info", _strRelaisPower_On)
	logInfo("rule.info", _strRelaisPower_Off)
	logInfo("rule.info", _strRelaisDirec_On)
	logInfo("rule.info", _strRelaisDirec_Off)
	
	try
	{
		logError("rule.lambda", "Begin Try")

		publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisPower_Off)

		while (rsiStatusItem.state == "1" && receivedCommand != STOP && _whileExitCounter < _whileExitCountMax)
		{
			logInfo("rule.info", "Warteschleife")
			Thread::sleep(500)
			publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisPower_Off)
			_whileExitCounter++
		}
		
		if (rsiStatusItem.state == "0" && receivedCommand != STOP)
		{
			if (receivedCommand == UP)				//  UP
			{
				Thread::sleep(_threadSleepTime)
				publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisDirec_On)
				Thread::sleep(_threadSleepTime)
				publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisPower_On)			
			}
			else if (receivedCommand == DOWN)		//  DOWN
			{
				Thread::sleep(_threadSleepTime)
				publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisDirec_Off)
				Thread::sleep(_threadSleepTime)
				publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisPower_On)			
			}
		}
		else										// STOP
		{
			publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisPower_Off)
			Thread::sleep(_threadSleepTime)
			publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisDirec_Off)			
		} 
	}
	catch(Throwable t)
	{
		logError("rule.lambda", "catch error in lambda: " + t.localizedMessage.toString())
		//lockThatLambda.unlock
	}
	finally 
	{
		logError("rule.lambda", "finally in lambda: ")
		//lockThatLambda.unlock
	}

	true
]



// 0x20 - 0x12

rule "rule_ardu02_out_20_12_P_00_01_received_command"
when
    Item ardu02_out_20_12_P_00_01 received command
then
	logError("rule.lambda", "buhahuha")
	rollo_lambda.apply(ardu02_out_20_12_P_00_01, receivedCommand, ardu02_out_20_12_00_stat, lock_rollo_lambda)
	publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", "buhu") 
end

rule "rule_ardu02_out_20_12_P_02_03_received_command"
when
    Item ardu02_out_20_12_P_02_03 received command
then
	rollo_lambda.apply(ardu02_out_20_12_P_02_03, receivedCommand, ardu02_out_20_12_02_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_20_12_P_04_05_received_command"
when
    Item ardu02_out_20_12_P_04_05 received command
then
	rollo_lambda.apply(ardu02_out_20_12_P_04_05, receivedCommand, ardu02_out_20_12_04_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_20_12_P_06_07_received_command"
when
    Item ardu02_out_20_12_P_06_07 received command
then
	rollo_lambda.apply(ardu02_out_20_12_P_06_07, receivedCommand, ardu02_out_20_12_06_stat, lock_rollo_lambda)
end

// 0x20 - 0x13

rule "rule_ardu02_out_20_13_P_00_01_received_command"
when
    Item ardu02_out_20_13_P_00_01 received command
then
	rollo_lambda.apply(ardu02_out_20_13_P_00_01, receivedCommand, ardu02_out_20_13_00_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_20_13_P_02_03_received_command"
when
    Item ardu02_out_20_13_P_02_03 received command
then
	rollo_lambda.apply(ardu02_out_20_13_P_02_03, receivedCommand, ardu02_out_20_13_02_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_20_13_P_04_05_received_command"
when
    Item ardu02_out_20_13_P_04_05 received command
then
	rollo_lambda.apply(ardu02_out_20_13_P_04_05, receivedCommand, ardu02_out_20_13_04_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_20_13_P_06_07_received_command"
when
    Item ardu02_out_20_13_P_06_07 received command
then
	rollo_lambda.apply(ardu02_out_20_13_P_06_07, receivedCommand, ardu02_out_20_13_06_stat, lock_rollo_lambda)
end

// 0x21 - 0x12

rule "rule_ardu02_out_21_12_P_00_01_received_command"
when
    Item ardu02_out_21_12_P_00_01 received command
then
	rollo_lambda.apply(ardu02_out_21_12_P_00_01, receivedCommand, ardu02_out_21_12_00_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_21_12_P_02_03_received_command"
when
    Item ardu02_out_21_12_P_02_03 received command
then
	rollo_lambda.apply(ardu02_out_21_12_P_02_03, receivedCommand, ardu02_out_21_12_02_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_21_12_P_04_05_received_command"
when
    Item ardu02_out_21_12_P_04_05 received command
then
	rollo_lambda.apply(ardu02_out_21_12_P_04_05, receivedCommand, ardu02_out_21_12_04_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_21_12_P_06_07_received_command"
when
    Item ardu02_out_21_12_P_06_07 received command
then
	rollo_lambda.apply(ardu02_out_21_12_P_06_07, receivedCommand, ardu02_out_21_12_06_stat, lock_rollo_lambda)
end

// 0x21 - 0x13

rule "rule_ardu02_out_21_13_P_00_01_received_command"
when
    Item ardu02_out_21_13_P_00_01 received command
then
	rollo_lambda.apply(ardu02_out_21_13_P_00_01, receivedCommand, ardu02_out_21_13_00_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_21_13_P_02_03_received_command"
when
    Item ardu02_out_21_13_P_02_03 received command
then
	rollo_lambda.apply(ardu02_out_21_13_P_02_03, receivedCommand, ardu02_out_21_13_02_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_21_13_P_04_05_received_command"
when
    Item ardu02_out_21_13_P_04_05 received command
then
	rollo_lambda.apply(ardu02_out_21_13_P_04_05, receivedCommand, ardu02_out_21_13_04_stat, lock_rollo_lambda)
end

rule "rule_ardu02_out_21_13_P_06_07_received_command"
when
    Item ardu02_out_21_13_P_06_07 received command
then
	rollo_lambda.apply(ardu02_out_21_13_P_06_07, receivedCommand, ardu02_out_21_13_06_stat, lock_rollo_lambda)
end

Okay, let us do a little analysis.
One of your rules logs the text buhahuha just before it calls the lambda, so we know we got that far.
Then the log is complaining about something to do with .name
We don’t see the “Begin Try” message, so it goes wrong before it gets that far.

There’s only a couple of places in the lambda referring to .name before “Begin Try”, so we can look at each of those more carefully.

rsiRollershutterItem.name looks good, you declared that to be an Item type at the beginning of the lambda. And if we check the calling rule as well, you passed in an Item. Items have .name method, so all looks good there.

rsiStatusItem.name gets mentioned next. But you declared rsiStatusItem to be a Command type at the beginning of the lambda. Command types do not have a .name method.

I thought I passed a StringItem on 3rd position.

Definition:

String   ardu02_out_20_12_00_stat  "Status (ardu02-20-12-00) [%s]"

I dont know if it is important, but this is red unterlined

org.openhab.core.types.Command receivedCommand

Don’t know what I saw. The post has been edited since.

I only edited typo, no changes on code or something like that.

Well, there’s only three places involving .name You can isolate them with logInfo(“blah”,“here”) or something to figure out the offender, I can’t see it.

addition

 import org.eclipse.smarthome.core.library.items.*

not required for OH 1.8. you want
import org.openhab.core.library.items.*

might just be it?

I believe this is the error. I do some more tests, but the first try was very promising…

Edit:

[enhab.model.script.rule.lambda] - buhahuha
[.script.rule.error.lambda.test] - We are here A
[.script.rule.error.lambda.test] - We are here B
[.script.rule.error.lambda.test] - We are here C
[.script.rule.error.lambda.test] - We are here D
[.script.rule.error.lambda.test] - We are here E
[.script.rule.error.lambda.test] - We are here F
[enhab.model.script.rule.lambda] - Begin Try
[.script.rule.error.lambda.test] - We are here G
[.script.rule.error.lambda.test] - We are here H
[.script.rule.error.lambda.test] - We are here J
[enhab.model.script.rule.lambda] - finally in lambda:
[.script.rule.error.lambda.test] - We are here M

Fullcode

import org.openhab.core.library.types.*
import org.openhab.core.types.*
import org.eclipse.xtext.xbase.lib.*
// import org.eclipse.smarthome.core.library.items.*
import org.openhab.core.library.items.*
import java.util.Locale
import java.util.concurrent.locks.ReentrantLock


var java.util.concurrent.locks.ReentrantLock lock_rollo_lambda  = new java.util.concurrent.locks.ReentrantLock()



val Functions$Function4 rollo_lambda = 
[
    RollershutterItem rsiRollershutterItem,
    org.openhab.core.types.Command receivedCommand,
    SwitchItem rsiStatusItem,
    java.util.concurrent.locks.ReentrantLock lockThatLambda
|
	//lockThatLambda.lock
logError("rule.error.lambda.test", "We are here A")


	// ardu02_out_20_13_P_06_07
	val int		_threadSleepTime	= 250
	var int		_whileExitCounter	= 0
	val int		_whileExitCountMax	= 20

	val _NameArray				= rsiRollershutterItem.name.split("_")
	
logError("rule.error.lambda.test", "We are here B")

	val String	_rsiNodeName	= _NameArray.get(0)
	val String	_rsiDirecion	= _NameArray.get(1)
	val int		_rsiExpAddress	= Integer::parseInt(_NameArray.get(2))
	val int		_rsiExpBank		= Integer::parseInt(_NameArray.get(3))
	val String	_rsiPinIdent	= _NameArray.get(4) // ignore it
	val int		_rsiRelPower	= Integer::parseInt(_NameArray.get(5))
	val int		_rsiRelDirec	= Integer::parseInt(_NameArray.get(6))

	val String _strRelaisPower_On	= String::format("pinout:%1$d:%2$d:%3$d:1", _rsiExpAddress, _rsiExpBank, _rsiRelPower)
	val String _strRelaisPower_Off	= String::format("pinout:%1$d:%2$d:%3$d:0", _rsiExpAddress, _rsiExpBank, _rsiRelPower)

	val String _strRelaisDirec_On	= String::format("pinout:%1$d:%2$d:%3$d:1", _rsiExpAddress, _rsiExpBank, _rsiRelDirec)
	val String _strRelaisDirec_Off	= String::format("pinout:%1$d:%2$d:%3$d:0", _rsiExpAddress, _rsiExpBank, _rsiRelDirec)

logError("rule.error.lambda.test", "We are here C")

	logInfo("rule.info", rsiRollershutterItem.name)

logError("rule.error.lambda.test", "We are here D")

	logInfo("rule.info", rsiStatusItem.name)

logError("rule.error.lambda.test", "We are here E")

	logInfo("rule.info", _strRelaisPower_On)
	logInfo("rule.info", _strRelaisPower_Off)
	logInfo("rule.info", _strRelaisDirec_On)
	logInfo("rule.info", _strRelaisDirec_Off)

logError("rule.error.lambda.test", "We are here F")
	
	try
	{
		logError("rule.lambda", "Begin Try")

		publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisPower_Off)

		while (rsiStatusItem.state == "1" && receivedCommand != STOP && _whileExitCounter < _whileExitCountMax)
		{
			logInfo("rule.info", "Warteschleife")
			Thread::sleep(500)
			publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisPower_Off)
			_whileExitCounter++
		}
		
logError("rule.error.lambda.test", "We are here G")
		
		if (rsiStatusItem.state == "0" && receivedCommand != STOP)
		{
			if (receivedCommand == UP)				//  UP
			{
				Thread::sleep(_threadSleepTime)
				publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisDirec_On)
				Thread::sleep(_threadSleepTime)
				publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisPower_On)			
		
logError("rule.error.lambda.test", "We are here H")
		
			}
			else if (receivedCommand == DOWN)		//  DOWN
			{
				Thread::sleep(_threadSleepTime)
				publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisDirec_Off)
				Thread::sleep(_threadSleepTime)
				publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisPower_On)			
		
logError("rule.error.lambda.test", "We are here I")
		
			}

logError("rule.error.lambda.test", "We are here J")

		}
		else										// STOP
		{
			publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisPower_Off)
			Thread::sleep(_threadSleepTime)
			publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisDirec_Off)			

logError("rule.error.lambda.test", "We are here K")

		} 
	}
	catch(Throwable t)
	{
		logError("rule.lambda", "catch error in lambda: " + t.localizedMessage.toString())
		//lockThatLambda.unlock

logError("rule.error.lambda.test", "We are here L")

	}
	finally 
	{
		logError("rule.lambda", "finally in lambda: ")
		//lockThatLambda.unlock

logError("rule.error.lambda.test", "We are here M")

	}

	true
]

OMG, I went crazy …

First run, looks nice. It goes trough til finally.

[.script.rule.error.lambda.test] - We are here 0
[.script.rule.error.lambda.test] - We are here A
[.script.rule.error.lambda.test] - We are here B
[.script.rule.error.lambda.test] - We are here C
[.script.rule.error.lambda.test] - ardu02_out_20_12_P_00_01
[.script.rule.error.lambda.test] - We are here D
[.script.rule.error.lambda.test] - ardu02_out_20_12_00_stat
[.script.rule.error.lambda.test] - We are here E
[.script.rule.error.lambda.test] - pinout:20:12:0:1
[.script.rule.error.lambda.test] - pinout:20:12:0:0
[.script.rule.error.lambda.test] - pinout:20:12:1:1
[.script.rule.error.lambda.test] - pinout:20:12:1:0
[.script.rule.error.lambda.test] - We are here F
[enhab.model.script.rule.lambda] - Begin Try
[.script.rule.error.lambda.test] - We are here G
[.script.rule.error.lambda.test] - We are here H
[.script.rule.error.lambda.test] - We are here J
[enhab.model.script.rule.lambda] - finally in lambda:
[.script.rule.error.lambda.test] - We are here M

But than, 2nd-run, same button, same command:

[.script.rule.error.lambda.test] - We are here 0
[.script.rule.error.lambda.test] - We are here A
[.script.rule.error.lambda.test] - We are here B
[.script.rule.error.lambda.test] - We are here C
[.script.rule.error.lambda.test] - ardu02_out_20_12_P_00_01
[.script.rule.error.lambda.test] - We are here D
[.script.rule.error.lambda.test] - ardu02_out_20_12_00_stat
[.script.rule.error.lambda.test] - We are here E
[.script.rule.error.lambda.test] - pinout:20:12:0:1
[.script.rule.error.lambda.test] - pinout:20:12:0:0
[.script.rule.error.lambda.test] - pinout:20:12:1:1
[.script.rule.error.lambda.test] - pinout:20:12:1:0
[.script.rule.error.lambda.test] - We are here F
[enhab.model.script.rule.lambda] - Begin Try
[.script.rule.error.lambda.test] - We are here WS A
[.script.rule.error.lambda.test] - Warteschleife
[.script.rule.error.lambda.test] - We are here WS B
[.script.rule.error.lambda.test] - We are here WS C
[.script.rule.error.lambda.test] - We are here WS D
[.script.rule.error.lambda.test] - We are here WS E
[o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'rule_ardu02_out_20_12_P_00_01_received_command': The name '+ <XFeatureCallImplCustom>' cannot be resolved to an item or type.

That’s the “Warteschleife”

    	publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisPower_Off)

		while (rsiStatusItem.state == "1" && receivedCommand != STOP && _whileExitCounter < _whileExitCountMax)
		{

logError("rule.error.lambda.test", "We are here WS A")
	
			logError("rule.error.lambda.test", "Warteschleife")

logError("rule.error.lambda.test", "We are here WS B")
	
			Thread::sleep(500)

logError("rule.error.lambda.test", "We are here WS C")
	
			publish("mosquitto_cubie", "BB55/hctl/v1/ardu02/sub/i2c", _strRelaisPower_Off)

logError("rule.error.lambda.test", "We are here WS D")
	
			_whileExitCounter++

logError("rule.error.lambda.test", "We are here WS E")
	
		}

It come to WS E, but than it stops, without any more messages.
if there is an error, i believe that it has to jump to catch … but it didn’t.

It won’t jump to catch before you get to try. The log appears to show two runs of the lambda, one has got as far as “BEGIN TRY” and then another one starts and presumably hits an error (before it gets to try)

Isn’t that where we came in, needs a reentrant lock?
Addition - As this error was outside your current try-catch block, you will need to move that to include all the code