Light automation that will not trigger if manually turned off

Hello everyone,

I am very new to Home Assistant and still only doing automations via UI,
soo keep that in mind when proposing solutions.

My problem is that I have a light in my living room and also a motion sensor.
I would like to have this light turned on whenever motion is detected and the lux-level is below 40.
So far I have managed myself.

However, I have not yet succeeded with the next part.
Sometimes you want to manually turn the light off, to get a more cosy feeling as an example (replace the light with candles). But since I still am in the room, the automation turns the light on again when I move.
In this case I would like the automation to have another condition stating that if the light is off, and there has been motion detected during the last 5 minutes, it will not turn on.

Because this way, my idea is that, if everyone goes out of the room for 5 minutes, and motion has not been detected for 5 minutes, the automation will still run next time I enter the room.

Thank you,

You might have a look at Entity Controller from HACS, which handles this sort of thing very well.