Sun below horizon = lamp on?

See the sticky post for how to correctly format code blocks, and other things. If you don’t do that, then nobody can use what you posted.