[SOLVED] Adding an "if" statement after a timer, a simple rules

Running OH2 on Pi3B+ using VC to edit!

Easy for some but I am stumped. Also not so up with coding
My rule is to: when motion is detected, if the Lux is low, and the light is not already set above 10, turn on a light at a power of 10, then wait 5 minute and set the light to 75 then turn it off. Not wanting to blind myself at night going to the john. The following code works just fine.

Now I want to add a condition immediately after the 5 minute time, if the light changed (while the timer was running) to a higher value simply abort the commands after the timer. I have tried many combinations of "if"s and "else"s with no luck, could someone please help?

// Bathroom Low Light Motion Rule
rule "Motion at night not so bright"
  when Item Sensor41_1_AlarmMotion changed to ON
  then  if (Sensor41_1_Luminance.state <=15) 
            if (LightD_Bath_Ceiling.state <=10) 
      { LightD_Bath_Ceiling.sendCommand(10) 
        createTimer(now.plusMinutes(5), 
        [ | LightD_Bath_Ceiling.sendCommand(75)
        Thread::sleep(100)
        LightD_Bath_Ceiling.sendCommand(0)
        ]      ) 
      } 
        else{}
end

That would be something like:

// Bathroom Low Light Motion Rule
rule "Motion at night not so bright"
  when 
     Item Sensor41_1_AlarmMotion changed to ON
  then 
    if (Sensor41_1_Luminance.state <=15 && LightD_Bath_Ceiling.state <=10) { 
      LightD_Bath_Ceiling.sendCommand(10) 
      createTimer(now.plusMinutes(5), [ | 
        if(LightD_Bath_Ceiling.state > 10) return;
        LightD_Bath_Ceiling.sendCommand(75)
        Thread::sleep(100)
        LightD_Bath_Ceiling.sendCommand(0)
      ]) 
    }
end

Explanation: You can combine two nested if’s into an single if with an && (and) in between, so if Lux is smaller than or equal to 15, and the light is smaller than or equal to 10, turn it up to 10.
Then set a timer for 5 minutes, and after those 5 minutes, if the light is larger than then, just return (so do nothing). Otherwise, set the light to 75, wait for 100 ms and set it to 0.

Thank you so so much!!

Is it odd that it works as I have it now, without the condition after the timer?

OOOps VC says the is an error… red underline under the >. Do I ignore it?

if(LightD_Bath_Ceiling > 10) return;

Oh doh… Should be LightD_Bath_Ceiling.state obviously. I’ll fix it in my original answer as well.

Edit: and it “worked” as that it stopped after the timer due to that error.

Yep now it works! Thank you again.
BTW is there a book “java for dummies” I can get that you know of?

Rule DSL language is not really Java, it is a language called Xtend (https://www.eclipse.org/xtend/) and in any case I’d say there are a lot of resources online to learn about either Java or Xtend or Xtext.