Functions in rules

I have tried to work with functions in rules and having problems with timers…

`Preformatted textval org.eclipse.xtext.xbase.lib.Functions$Function2 myFunc = [
org.openhab.core.library.items.SwitchItem relayItem,
org.openhab.model.script.actions.Timer t|

t=createTimer(now.plusSeconds(10)) [|

When the rule runs, the timer created successfully, but when the timer runs, it looks like it does not recognize the relayItem. here is the error:
2017-05-14 23:14:15.181 [ERROR] [org.quartz.core.JobRunShell ] - Job DEFAULT.2017-05-14T23:14:15.165+03:00: Proxy for org.eclipse.xtext.xbase.lib.Procedures$Procedure0: [ | {
} ] threw an unhandled Exception:
java.lang.RuntimeException: The name ‘.sendCommand()’ cannot be resolved to an item or type.
at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.invokeFeature([129:org.eclipse.smarthome.model.script:0.9.0.b4]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate([145:org.eclipse.xtext.xbase:2.9.2.v20160428-1452]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate([145:org.eclipse.xtext.xbase:2.9.2.v20160428-1452]

Please help.
Thanks ahead,

That sounds like a situation in which the Expire Binding could be used. Please have a look at the following thread. @rlkoshak explains the usage at the bottom of the first post.
Design Pattern: Motion Sensor Timer

I simplified the problem. My rules are much smarter with lots of conditions (not always turn off the light… and if they turn off the light it depends on the time…)

In this case a look into the following thread might help.

still I see (the same) errors:
The name '<XFeatureCallImplCustom>.containsKey(<XFeatureCallImplCustom>)' cannot be resolved to an item or type

err, that’s not the same error. When you began, with it was complaining about .sendCommand, now it is .containsKey

Yes, I tried the other way.
My big problem is that when I forward the item as parameter the timer not recognize it…

Are you using OH2? If so, this import is incorrect-

org.openhab.core.library.items.SwitchItem relayItem,

perhaps you followed an OH1 example?

Yes I’m using OH2, what is the SwtichItem classpath for OH2?

No path required at all, already included

@rossko57 Thanks!! that was the problem!