The MC-38 sensor is a magnetic switch that opens/closes in the presence of a magnetic field. It was designed for use with doors, windows, etc. Here is a guide to getting started.