Simply "rule timer" not work

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
1 Like

not works, same situation

rule "cond notte 30min OFF"
when
    Item condi_notte_OFF_1hour received command	
then
    if (receivedCommand == ON) {
        logInfo("TEST", receivedCommand.toString)
        if (condi_timer === null)  {
            logInfo("TEST", "Starting Timer")
            condi_timer = createTimer(now.plusMinutes(5), [ |
                logInfo("TEST", "Stopping Timer")
                lucecorrnotte.sendCommand(ON)
                condi_timer = null
            ])	
        }
    }
end

if I understood correctly:

logInfo("TEST", receivedCommand.toString)
logInfo("TEST", "Starting Timer")
logInfo("TEST", "Stopping Timer")

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

the items file:

String condi_notte_OFF_30min		"cond notte 30min OFF"          <clock>        (Condizionatori)	                              {autoupdate="false"}

sitemap:

Switch item=condi_notte_OFF_30min             mappings=[ON="30 min"]

Those log messages will go to openhab.log, not event.log.

Which is it? condi_notte_OFF_1hour or condi_notte_OFF_30min

sorry… condi_notte_OFF_30min