This sensor controller when paired with the wireless magnetic door sensor switches (SY2448) can turn lights on and off automatically. The switch is secured to the inside of a cabinet using the adhesive back, whilst the separate magnetic contact button is placed on the inside of the door. When the door closes these two components touch, sending a signal to the sensor controller to switch the lights off. Opening the door prompts the lights to turn back on.
Up to 4 switches can be run from one of these controllers, making it perfect for switching lights on and off within bathroom cabinets. The switch runs on two 3V button batteries which are very easy to change when required.
See the image of the diagram above for an example of how you can use this set up.