Few years back, I had been working on a project for solar auto lighting. The light will turn on when the the solar panel voltage drop below a set point indicating that it is dark. The detection is done by using D2 in the schematic. The zener diode value will be adjusted so that the transition between the switch depends on the amount of light the panel receive. Relay K1 is used to switch the load and the battery. If the battery power fall below a set threshold, the relay will cut the supply to the load. Relay K2 is used to control the charging of the circuit. When a Set point is reach the charging will be cut off. A Comparator is used for the voltage comparison.