First of all, let me start with thanking you all for the good work what has been done! I've used so many tips, thank you.
Now I need a LUA guru, because I am a LUA programmer n00b.

Because of the time delay (blocky response is slow, up to 3/6 seconds). I want to test if a LUA solution is faster. Having no knowledge about LUA, I'm kinda stuck here.
Is someone willing to help me out?
Purpose of this blocky:
I have a fibaro motion sensor and a KAKU door contact (sensor 354).
When opening the door OR motion is detected AND lux is below or equal to 15, the light is turned on. There is a dummy switch with a 3 minute OFF delay. Everytime motion is detected, the countdown timer is reset.