Ok so I finally got some time to reinstall everything related to CD but I still had the same issue if I manually set the Sunrise time where it’ll just go to ctMin no matter what I tried. So I did some digging on my part and at least for me I’m having the following issue.
I inserted a few “log.debug” lines to see what actual time values the function “calcColorTemperature()” was using.
private void calcColorTemperature(sunriseAndSunset) {
def nowDate = new Date()
log.debug "nowDate ${nowDate}"
log.debug "sunrise = ${sunriseAndSunset.sunrise}"
log.debug "sunset = ${sunriseAndSunset.sunset}"
if (nowDate < sunriseAndSunset.sunrise || nowDate > sunriseAndSunset.sunset) { state.colorTemperature = settings.ctMin } //before sunrise / after sunset
Now when if I don’t set my Sunrise time then I get this output in the Live Logging:
4a3d1c66-8b7d-4011-a8cc-5509d48a47e3 5:03:23 PM: debug Color Temperature set to 3279
4a3d1c66-8b7d-4011-a8cc-5509d48a47e3 5:03:23 PM: debug sunset = Thu Feb 02 01:32:00 UTC 2017
4a3d1c66-8b7d-4011-a8cc-5509d48a47e3 5:03:23 PM: debug sunrise = Wed Feb 01 15:11:00 UTC 2017
4a3d1c66-8b7d-4011-a8cc-5509d48a47e3 5:03:23 PM: debug nowDate Thu Feb 02 01:03:23 UTC 2017
4a3d1c66-8b7d-4011-a8cc-5509d48a47e3 5:03:22 PM: debug initialize() with settings: [updateNotifications:false, lZip:95194, ctMin:2700, ctMax:6000]
Now if I set my Sunrise time manually to 5:31AM I get this:
4a3d1c66-8b7d-4011-a8cc-5509d48a47e3 5:03:47 PM: debug sunset = Thu Feb 02 01:32:00 UTC 2017
4a3d1c66-8b7d-4011-a8cc-5509d48a47e3 5:03:47 PM: debug sunrise = Thu Feb 02 13:31:37 UTC 2017
4a3d1c66-8b7d-4011-a8cc-5509d48a47e3 5:03:47 PM: debug nowDate Thu Feb 02 01:03:47 UTC 2017
4a3d1c66-8b7d-4011-a8cc-5509d48a47e3 5:03:46 PM: debug initialize() with settings: [updateNotifications:false, lZip:95194, lSunriseTime:2017-02-01T05:31:37.000-0800, ctMin:2700, ctMax:6000]
The sunrise time changes to the next day sunrise time not the current day when I manually set the Sunrise time.
I think this is why when I set my Sunrise time manually, CD always goes to ctMin.
That’s far as I got since I’m not sure how to fix the time calculation function to fix my problem.
Help please. Thanks!