Non-contact switches with solenoid lock