On door open - Logic problem

Two RGB leds that have to show the same color in the same time (for 2 different rooms).
When distance from sensor is < the leds toggle, from red to green and viceversa, but when you leave the door open, I want the leds to be green. And then red when you close it and so on.