Hi i want to make an rule for protecting rollershutter to not to be in motion too long. I read many topics and i cant understand something. I am makeing same i as found but nothing works.
firstly i tried this:
rule "rollershutter1 safety"
when
Item rollershutter1 changed to 1 or Item rollershutter1 changed to 2
then
rollerTimer1 = createTimer(now.plusSeconds(20), [
rollershutter1.sendCommand(0)
])
if(rollershutter1 changed to 0){
rollerTimer1.cancel
}
end
but i got error:
[WARN ] [del.core.internal.ModelRepositoryImpl] - Configuration model 'rollershuttersafety.rules' has
errors, therefore ignoring it: [8,12]: no viable alternative at input 'rollershutter1'
[8,39]: mismatched input ')' expecting 'end'
Then after many tries i make something like that
var rollerTimer1
rule "rollershutter1 safety"
when
Item rollershutter1 changed to 1 or Item rollershutter1 changed to 2
then
logInfo("rs1", "nowy timer")
rollerTimer1 = createTimer(now.plusSeconds(20), [
rollershutter1.sendCommand(0)
])
end
rule "rollerTimer1 cancel"
when
Item rollershutter1 changed to 0
then
if(rollerTimer1 !== null){
rollerTimer1.cancel()
rollerTimer1 = null
}
end
and i got:
[ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'rollerTimer1 cancel': 'cancel' is not a
member of 'null'; line 17, column 7, length 21
Is it mean may variable rollerTimer1 does not exist in rule ‘rollerTimer1 cancel’ ?
Haw can I make it works?