Compact non-contact door switch/flexible safety unit