Lights off 30 seconds after leaving the room. But not when you are in

I am new in OH community I moved from HomeSeer that ti used for many years.
I can easily create the rule in HS that say if there is a motion and the light is off and it is dark switch on the light.
The next rule is if the lights is on and there is no motion switch off the light in 30 seconds.
It creates the issue what if there will be a motion once the second rule started so i am adding another task in a first rule saying cancel the rule 2
so it will be
if the r is a motion
and it is dark
and the lights are off
cancel the rule 2
and switch on the right
so it will keep the lights on and start counting the time to switch off again

How can I do it in OH 2.5?

You can use createTimer in a rule.
Reschedule the Timer on new motion.

There are several examples in this forum.

A 30s Timer might not be the best option since you are staying within the rule being active.
Just use an item with a 30s expire and if the 30s have been expired check within a rule if somebody is within the room and if not, update the item with ther 30s expiration again so it will start again from 30s.

Switch myExpireSwitch {expire="30s, command=OFF}

The following assumes that you have an item “MotionDetected” that reports with ON/OFF that somebody is in the room

rule "MotionDetected"

when Item MotionDetected received command ON
  if(myLight.state == OFF){

rule "MotionExpired"
  item myExpireSwitch changed to OFF
  if(MotionDetected.state == ON)
    //somebody still is in the room so only retrigger the expire item

You can add delays after an area is inactive using…