handles switching ON/OFF lights in case of motion