Reworked to improve handling of luminance

Significant re-write to more robustly handle light measurement as a criteria.  Added the concept of an ambient state, light or dark, and rules for how sunrise, sunset, and light measurement drive transitions between light and dark