Are you trying to use a motion sensor and a time of day to determine if lights should turn on? If so, check out the Advanced Smart Lights code. It uses jkUtils Solar Altitude rather than WU or a luminescence sensor to determine sunrise/sunset. You can either use that script or modify your code based on how it works.