How to avoid infinite on/off loop of a voltage controlled (with a photoresistor) switch?
Your state machine has two states right now: "on" and "off" and only one way to transition out of a state (the light sensor) You could add another sensor (time) and introduce another state or two to delay the transitions but the machine will always cycle. This might be ok if your relay was fast and quiet (so no one will notice) then having it check by transitioning from "on" to "off after an hour or whatever. When it's in "off", if the ambient light is bright enough then it'll stay off. Otherwise it'll pop back into "on" then wait for an hour again. A very simple way to make a delay is to discharge a large capacitor with a resistor in parallel and use a comparator to trigger the next state.