I have started using OH2, and I currently working on getting my most complex script running on OH2 (inspired by the article “Taking rules to new Hights”). I have found solutions for most things I have been dealing with, there is one thing that I can’t figure out - that is the createTimerWithArgument. I keep getting this error: Error during the execution of rule 'SecurityZones sensor tripped TEST': The name 'createTimerWithArgument(<XMemberFeatureCallImplCustom>,<XFeatureCallImplCustom>,<XClosureImplCustom>)' cannot be resolved to an item or type.
I have written a new rule with just a create time in it, but it keeps failing:
var cookie = "timer2"
var Timer timer2 = createTimerWithArgument(now.plusSeconds(10), null,
[ x |
logInfo("timer_expired", " with cookie: " + x)
If I just use the plain Timer:
logInfo("timer_test", "<No Cookie>")
var Timer timer1 = createTimer(now.plusSeconds(10))
[ x |
logInfo("timer_expired", "(No arguments present)")
Everything works, the timer is fired as expected.
All I have done is just to copy my code from the OH1 rule to my OH2 rule.
Any suggestions what I might have done wrong.
I somebody could give a working sample it would be just fine.
I’m so embarrassed of having published this ugly piece of code. I have since rewritten the rule much cleaner in python. But that is in OH1, not sure what the status of jython support is in OH2.
Like me, you have probably invested a substantial amount of time in learning how xtend works, and now you don’t want to ditch it, but at least for me, that was the right decision, if only for the fact that it allowed me to write code without the designer.
You are right I have used a lot of time trying to learn and understand the rule engine. I still find it difficult, and I have also been looking for another way of solving this. Since I have started to develop a binding for ZoneMinder I have been looking in the direction of OH2. I believe I will revert my complex rules to OH1 and then take advantage of JSR223, as it seems to be just what I have been looking for. Even when the timerproblem is fixed in OH2 I will still have some complex rules that it will be hard to maintain.