On door open - Logic problem

Can you fully explain the behaviour you're looking for? So two LEDs, red and green. What are the various states/behaviours and at what distances do they occur?