Use an additional photodetector, e.g. a fototransistor, attached to a GPIO pin and detect when there is light.
A simple circuit could look like this (source). With Vcc=3.3 V and Vout tied to a GPIO input pin of the Pi. According to the source the resistor would be 100 Ohms, I would think it should be higher (Adafruit is in the range of 1k to 10k Ohms). Major drawback of this circuit is its analogue signal that is feed into the digital input and might be somewhat less repeatable.
An improved circuit would use a Schmitt-Trigger, either integrated, e.g. the 74HC14, or a circuit like this (source):
Needs additional hardware.
Wait, a camera is essentially a photodetector, why use another one? Simply have the Raspicam taking pictures all the time in an appropriate frame rate. Read the picture, calculate the sum of all pixels. If this value is above a certain threshold assume it's "light" and keep the picture, otherwise discard of it. You will need to figure out that threshold for your particular setup - a dark image will not be zero due to hot pixels and noise.
As an example using numpy/scipy (just because I use those all the time - one could also use any other package that imports images).
import numpy as np
import scipy.misc as spmisc
img = spmisc.imread(filename, flatten=True)
lumi = np.sum(img)
if lumi > threshold:
# do something
Improvement to that would be to not save all the unneeded images to the SD card. Instead use
picamera.capture() to capture the image to a file-like object (an io.BytesIO stream) or even better (thanks to Dave Jones) directly to a numpy array. Calculate your result from that object and save only if necessary.
An example from here shows how to do it and gives important notes to the resolution.
import numpy as np
with picamera.PiCamera() as camera:
camera.resolution = (320, 240)
camera.framerate = 24
output = np.empty((240, 320, 3), dtype=np.uint8)
It is also important to note that when outputting to unencoded formats, the camera rounds the requested resolution. The horizontal resolution is rounded up to the nearest multiple of 32 pixels, while the vertical resolution is rounded up to the nearest multiple of 16 pixels.