This sensor is essentially a reed switchencased in an ABS plastic shell. Normally the reed is \'open\' (no connection between the two wires). The other half is a magnet. When the magnet is less than 13mm (0.5") awaythe reed switch closes. They\'re often used to detect when a door or drawer is openwhich is why they have mounting tabs and screws. You can also pick up some double-sided foam tape from a hardware store to mount thesethat works well without needing screws.
MC-38 Wired Door Window Sensor Magnetic Switch Home Alarm System（Normally closed: the magnet is close to the conduction, the magnet is off the circuit）
1 x MC-38 Wired Door Window Sensor Magnetic Switch