the word “item” in the rule trigger should be capitalized:
when
Item HueMotionEvent changed
then
Add a log statement as the first line of the rule.
Review the following for a better way to do the above using timers. The way it is coded now your light will flicker off and on after two minutes depending how many additional motion detection events were detected…
When you encounter errors like this your first thing to do should be to load your config into Designer to check for syntax errors. Get Eclipse SmartHome Designer 0.8 (not the 0.9 snapshot which has a major bug).
Thus, your rule should look something closer to:
Note: you are not even using the transition from OFF to ON in this case so no need to the var
var Timer timer = null
rule "test"
when
Item HueMotionEvent received update
then
if(HueMotionEvent.state ==ON) { // HueMotionEvent should be a Switch, not a String
if(timer == null){
var DecimalType hue = new DecimalType(240)
var PercentType sat = new PercentType(100)
var PercentType bright = new PercentType(50)
var HSBType light = new HSBType(hue,sat,bright)
corr_salotto.sendCommand(light)
corr_camere.sendCommand(light)
timer = createTimer(now.plusMinutes(2), [|
corr_salotto.sendCommand(OFF)
corr_camere.sendCommand(OFF)
timer = null
])
}
else {
timer.reschedule(now.plusMinutes(2)
}
}
end
In the above, the light will be turned on when an ON is detected on the motion sensor and a Timer that expires in two minutes is created. The body of the Timer turns the lights off. If another motion is detected before the Timer expires it is rescheduled for an additional two minutes into the future.
In short, the light stays ON until two minutes after the last motion event. No flickering in between events.