Hi @dkarijopawiro , firstly welcome to the community.
Could you explain how you think it should work? I will help me understand .
Currently if you are using contact sensor (a door) and motion sensor I would recommend that you put them into a group for this to work correctly. It is in our FAQ, and here is the link on how to set one up. The only thing is if you close the door then the light will come on and I not sure if this is what your after.
If you have a fan in the toilet then maybe consider using my other blueprint called Toilet Exhaust Fan with time delay