Give your levers and doors an instance variable called "id".
Match the variables for the levers and doors that are connected, meaning a lever with the id 4 will open any door with a matching id.
Of course in order to achieve this you need to add a condition checking for the door id to be equal to the lever id.