[OBSOLETE] Circadian Daylight: SmartThings + Smart Bulbs

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!

Just wanted to weigh in on this. I was having the same problem as the other poster, so I made the change on line 56, and that appears to work. However, the CD Brightness and CD Color still say On, even though they say false in the IDE view.

Can you install the Coordinator code I just pushed to the development branch, and see if that fixes the issue?

CD pretty much works in UTC for everyone, because that’s what SmartThings defaults to and all calculations are relative so there would be no point in converting everything to each users’ local timezone. The only thing that isn’t in UTC is the time picked for Sunrise/Sunset. When you pick a time for either of those it’s stored in a date object, so it actually includes whatever date you set it up. Obviously the date needs to be changed to whatever the current date is. So I was basically pulling the current date, combining it with the specified time, and converting to UTC. What I overlooked was the fact that the current date was being pulled in UTC, which is why it would actually pull the next day’s date when you get past the UTC offset (4pm in your case).

EDIT: I’m still thinking about the options for Dynamic Brightness, and would appreciate any opinions or ideas others may have.

1 Like

That fix is implemented in the development branch, which also had some upstream changes. I’ve been testing for over a week now so I’m going to push it to the stable branch as well. The tile not updating sounds like a platform issue, is should always reflect what the IDE shows.

Your changes fixed this issue for me.

Thank you!

1 Like

Hm, does IOS have any known issues? I thought that was the most solid platform with Smartthings?

Don’t know, I don’t have any iOS devices. Can anyone else chime in?

I had problems with the transition to “working” and then not showing on the tile when it was disabled (the tiles always show as “Circadian Daylight: On” when I was on the stable branch.

However, I switched over to the development branch earlier this year and it started working as expected after I did that… and I didn’t even need to uninstall the app or install automations.

Just an update, I removed all of my Hue devices and the Hue Advanced Connect, reinstalled the app and connected my devices, and now the tile is updating properly.

1 Like

Hello,

I’ve searched a few times, but haven’t found a great solution to my situation. I think others may have a similar setup and could benefit from answers to these questions.

Essentially, I use both smart zwave switches AND smart bulbs. I just cannot convince others in the house to not use light switches, and I would prefer to sometimes use them myself. The problem is what when the switch is turned off and on, the bulbs reset to the default soft white state until told to change. This usually takes longer than I would prefer.

My ideas to solve this are to either change the default timing of the update to something that happens once every minute or (preferrably) less, or to activate the SmartApp to resync the color temperature each time the a zwave switch it turned on, so it would both turn the bulb on then immediate sync the temperature. I’m open to any other ideas as well.

1.) How often does this app update the state of the bulbs?
2.) Is there any way for a brave beginner like myself to change this through the IDE or other mechanism? If so, how?
3.) Is there a way to “activate” the SmartApp through either a Routine or possibly something like CoRE? I am referring to action that occurs when I press the “play button” in my Automation -> SmartApps menu. With this I would try to add this command to each switch’s ON command.

Thanks!
Tom

Adjustments are made every 15 minutes, AND as soon as any assigned devices reports that it’s on.

Yes, but it will not help your issue and will put strain on your system that neither you nor SmartThings want.

SmartApps cannot control other SmartApps, only devices. This is a security measurement built-in to the platform.


To elaborate on the above responses - every 15 minutes CD calculated new values for color temperature and brightness, and adjusts all selected devices. However, as soon as any device that is added to CD has their state updated to “on”, CD will immediately set the color temperature and/or brightness to the last calculated value. So the delay you are seeing is not a result of the system waiting until the next scheduled adjustment, but rather it is a result of your bulbs not immediately reporting that they are on. What this means is that even if you had CD running every second, the bulbs wouldn’t adjust any faster. When power is applied to smart bulbs the LEDs immediately turn on, however it takes some time for them to rejoin the network, update ST that they are on, and actually be controllable.

I think it’s safe to say that pretty much everyone has experienced the issue of wanting smart bulbs, but maintaining the functionality of switches. The only solution that I have come up with that allows full automation while maintaining traditional functionality is to install “smart” switches, but wire them so that the fixtures are always hot. I have SmartApps that control the bulbs via the switches. So basically, when a switch is turned off, nothing physically happens, but the SmartApp will tell the bulbs to turn off. This allows the bulbs to remain connected to the network and fully controllable, and results in the status being immediately known to SmartThings. The disadvantages of this setup is that there is a slight (0.5s-1s in my case) delay between turning on a switch and lights coming on, and very rarely a switch will be used and the bulbs won’t change.

Another solution that may work better for you is a switch that would communicate directly to the bulbs, but not actually cut power. Something like the Lutron Pico remote, Hue dimmer, etc. depending on what bulbs you have. This would be a bit of a compromise between your current solution and my solution. Bulbs would always respond immediately when the switch is pressed, and because the bulbs stay on the network they should update their state faster in SmartThings, however not quite as fast as with my solution where SmartThings is in between.

By the way, if you’re using Z-Wave or Zigbee bulbs connected directly to SmarThings, by cutting the power to them all the time you’re probably wrecking havok to the mesh and if you haven’t already you will likely notice communication issues to other devices.

Thank you for the thorough response, very helpful! So, worst case things update every 15 minutes and best case is when-the-bulbs-connect-to-Smartthings. Makes sense.

Since I have a number of Z-Wave GE Dimmer Switches already installed, I may just hard wire the lights on and use the dimmer as a soft switch to control the lights (Hue and some others). I will probably want to test this out to make sure the dimmers act as a proper soft switch.

I realize I’ll likely lose the dimmer feature of the switches, but the more I get into this and the more devices I get, the more I find myself living in “scenes” rather than really ever wanting to control a single light.

Thanks again!

Your dimmers should report the level, so there’s no reason you couldn’t maintain the dimming feature. That’s what I do with Cooper Aspire dimmers.

1 Like

Hi,
I haven’t found the solution to my problem in the discussion above, and was hoping to get some help. I’ve tried everything I could think of including resetting and reinstalling each component, but I can’t get CD to work with my Hue lights. I’m sure it’s a simple oversight, but I’m pretty technically limited. Here’s my setup:

-2nd gen Smartthings hub
-2nd gen Hue hub
-1x white and color ambiance Hue bulb
-3x white ambiance Hue bulbs

-Hue Advanced (Connect) seems to work and can control my lights (CD is enabled for each)
-Circadian Daylight Coordinator is set to all defaults (my zip code begins with 0 and the value in the IDE is a 4-digit number - could this be relevant?)
-There is an entry from setHandler every 15 minutes in the Job History for CD Coordinator, but the color temp/brightness of my lights never changes

Please let me know if there is any other information that might be helpful. Thanks for your dedication to this project!

I also have an ambience bulb from Philips and have just assumed CD didn’t work with the White/Ambience bulbs and exclusively worked with the colour bulbs. I haven’t been able to get CD to work on either the White or Ambience bulbs but still enjoy the Advanced Connect due to the transition and paramters in CORE.

@noneck @BlackCatPeanut Circadian Daylight should work with any lights that support color, color temperature, dimming, or any combination of the three. This should include all Hue lights and pretty much all other “smart” bulbs.

For starters, if you go into the IDE>My Locations>smartapps>Circadian Daylight Coordinator, what do each of you see as the value for colorTemperature under Application State?

Hi there, I’ve got a value of 3663…

Okay good, now in that same smartapps page can you open the child instance of Circadian Daylight coordinator that you’ve selected bulbs that aren’t working and post a screenshot of that?

I’m not sure I understand where the Child apps are found…could this be the problem?

The coordinator keeps the color temperature in sync, but the child SmartApps are where you actually select the lights and choose additional settings. The child SmartApps would be listed below and indented from the Circadian Daylight Coordinator link. If you don’t have anything there, open the SmartApp from the SmartThings app on your phone, you should see a button "New Circadian Daylight Setup. Run through that and everything should start working.

1 Like