Nest if Statements

Hi there,

Is there any limitation to using nested if statements in rules?

This rule works (please excuse the noise):

rule “LoungeLightsOff”
when
Time cron “0 * * * * ?”

then

     //if(sleepMode.state == ON) {   
    //if(loungeLightAuto == true)    {
        
        if(LLlastCheck == LLcounter) {
            LLcounter = 0;
            LLlastCheck = -1;
            //sendCommand(HueGroup1, OFF)
            sendCommand(Hue4_Toggle, OFF)
            sendCommand(Hue3_Toggle, OFF)
            sendCommand(Hue2_Toggle, OFF)
            sendCommand(Hue1_Toggle, OFF)
            //sendCommand(kitchenPIR, OFF)
            loungeLightAuto = false
        } 
    //}
    //}
    
    else {
        logInfo("LLcounter", "LLcounter = " + LLcounter)
        LLlastCheck = LLcounter
        logInfo("LLlastCheck", "LLlastCheck = " + LLlastCheck)
    }

end

However if I uncomment one of the if statements it doesn’t work:

rule “LoungeLightsOff”
when
Time cron “0 * * * * ?”

then

    //if(sleepMode.state == ON) {   
    if(loungeLightAuto == true)    {
        
        if(LLlastCheck == LLcounter) {
            LLcounter = 0;
            LLlastCheck = -1;
            //sendCommand(HueGroup1, OFF)
            sendCommand(Hue4_Toggle, OFF)
            sendCommand(Hue3_Toggle, OFF)
            sendCommand(Hue2_Toggle, OFF)
            sendCommand(Hue1_Toggle, OFF)
            //sendCommand(kitchenPIR, OFF)
            loungeLightAuto = false
        } 
    }
    //}
    
    else {
        logInfo("LLcounter", "LLcounter = " + LLcounter)
        LLlastCheck = LLcounter
        logInfo("LLlastCheck", "LLlastCheck = " + LLlastCheck)
    }

end

There is no limit to how deeply you can embed if statements.

What do you mean by “doesn’t work?” Does it throw an exception or just doesn’t do what you expect?