Hi all
request help about this rule, on the log, the item, received command ON correctly, but the rule does not execute the command.
thanks for your help
var Timer condi_timer = null
rule "cond notte 30min OFF"
when
Item condi_notte_OFF_1hour received command
then
if(receivedCommand==ON) {
if (condi_timer == null) {
condi_timer = createTimer(now.plusMinutes(5))
[|
sendCommand(lucecorrnotte, ON)
condi_timer = null
]
}
}
end
When testing for null you need to use ===
When the item is known, use the method item.sendCommand(command) instead of the action sendCommand(item String, command String)
Make sure your indents are aligned it’s easier to read and debug
Put the timer lambda inside the createTimer action, although not necessary, it’s easier to read and debug
var Timer condi_timer = null
rule "cond notte 30min OFF"
when
Item condi_notte_OFF_1hour received command
then
if (receivedCommand == ON) {
if (condi_timer === null) {
condi_timer = createTimer(now.plusMinutes(5), [ |
lucecorrnotte.sendCommand(ON)
condi_timer = null
])
}
}
end
you should show me in event.log when it starts and when the timer ends…correclty?
but this does not happen. The item “condi_notte_OFF_1hour” receives the command but nothing happens