I'm not sure I understand the problem..
There are so many ways to do this.
Putting the door and the switch in a container would be my first option.
You could also use instance variables and give the door and the switch the same variable so on switch clicked check if switch.variable = door.variable..
Also setteng a variable on either the switch or the door to the UID of the other and checking that would be an option.
Maybe in your case you could use pick nearest door when using the switch..
A lot of it depends on what you are comfortable with..