[RELEASE] Use Switches to set Lighting Scenes, Colors, Color Temperature/dimming

I very recently purchased the SmartThings hub with the intention of controlling several color temperature bulbs in the living room. It works pretty well, except syncing the bulbs together was a pain; I tried “Dim with Me,” but it didn’t control color temperature (I wanted the ability to have cooler light when the lights were on full, and warmer light when set to ‘movie dim’ mode).

So, I wrote this up (note: I am not a java/groovy developer by trade; the code I write for work is all visual block programming. This is probably really poorly coded, but it works). This SmartApp takes as an input anywhere from 1 to 5 switches. Honestly, I don’t know why you’d ever use just 1…but anyways, you can set individual color temperature, color, and dim levels for the selected bulb(s) based on which switch was pressed.

I don’t have an actual momentary switch on my network yet, so I created virtual switches in the IDE, using the ‘momentary button tile’ as the device type. If you have actual momentary buttons on your ST hub, those should work with this app as well.

I didn’t include outright on/off control, but set the dim level to ‘0’ and it turns the light off, any other value turns it on. Additional on/off control seems…unnecessary, in this case.

Anyways, if this fits your use case, please let me know how it works for you. If it would work but you’d like something changed, let me know and I’ll see if I can work through what you need.

[update] Color control has been added for color changing lights. In addition, you can now leave any value blank for a scene; when that scene’s button is pressed, only the values you set will be commanded and any value left blank will be left at the previous state. For example, if a light is on at 75% brightness, and you set ‘Scene 3’ for Color Temp 2700k but leave the ‘dim level’ blank, then pressing Scene 3’s button will set the color temperature but leave the brightness at 75%.

[another update] You can now choose dimmer switches that don’t have any color or color temperature control and set their levels via this App and an associated switch. As part of this update, I’ve removed any ‘required’ flags; before this, you needed a Color Temp bulb to move past the first page. Now, the app will simply respond to the equipment you chose; if you choose color bulbs, it will ask you what color to set. If you choose color temperature, it will ask you what color temp to set.

If you choose a color bulb as BOTH color and color temperature, the app will try and figure out what your intention is with each scene. For example, if you have a scene where you set the color and left the color temperature blank, it will simply set the color bulbs; if you set both color and color temperature, it will set the color to the color bulb and the temperature to the color temp bulb (if any); if you set only color temperature, it will set the color bulbs to ‘white’ and the appropriate color temperature, and of course any simple color temp bulbs will be set to that value as well.

There’s now a new option during setup of ‘dimmer switches.’ If you want to be able to control the lighting level of ANY light (color, temperature, or just a dumb dimmer), you must select it under the ‘dimmer’ controls! If you don’t select an object as a dimmer, you won’t receive the option to set the lighting level. So if you have a color bulb, and you want to be able to change its color, color temperature, and lighting level, you must select that bulb as being a member of each ‘color bulbs,’ ‘color temperature bulbs’ and ‘dimmer switches.’

Please let me know how this works for everyone, and have a great holiday weekend!


Love this APP! ! !

Is there a possibility to add set color within the scene(s) in addition to the brightness level and the K scale?

I installed and set up 3 “scenes” - created 3 VS’s … momentary button
[ the only “unfriendly” thing about using a Momentary button time … is that it is not bi directional … so the “off” cmd of course does not turn the scene off, but easy for me to work around that ]

so users can imagine - I used 3 lights in my living area- these are the “group” of the "scene"
Early bird = 40% brightness 4000 Kelvin
Sunny = 98% brightness 6000 Kevin
Smooth = 17% brightness 2900 Kevin

SO morning, noon and night “scene” if you will - creates the PERFECT lighting in the Living area
Of course these could be tied into routines / timers etc if needed too. I prefer to voice control - one light goes on at a sunset -30 min in that area already.

If possible to set the one light in the scene to a predefined “color” - say a red hugh for the smooth or evening scene that would be just GREAT :slight_smile:

THank you kindly for your great work on this APP ! I LOVE IT and will probably be setting up a few more through out the house.

1 Like

I don’t have any color changing bulbs myself so it makes programming the set color a bit problematic. I looked into it briefly and I couldn’t find a good way to bring up a color picker, so I’d have to pull two 0-100 inputs from you, one for hue and one for saturation. Would that work for you?

Considering that, I intend to modify it so that you can not put in a value for things like color, color temp, and dim level; if the value were not set for a particular scene, then it would continue at whatever the previous setting was. This would let you set color temp with 1 set of buttons and dim level with another and not have them fight each other.

In regards to the momentary buttons not turning the scene off when the button is off, that’s intentional. I’m expecting to pick up a wall switch with momentary buttons eventually, and just because I stopped ‘pushing’ a button doesn’t mean the scene should turn off. Instead, if you want to turn the scene off, create another virtual button, call it ‘Off,’ and have it set the level to 0; when you push that momentary button, it’ll turn off all slaved devices.

I’m at work at the moment but I’ll look into making these changes tonight.

Great thanks !

Look forward to seeing it :slight_smile:

1 Like

OP has been updated with color bulb control! Thank you @femwitjava for testing!

Additional updates today. Setting color temperature and color at the same time no longer conflicts; the color goes to the color bulbs, the temperature goes to color temp only bulbs.

You can now rename the app, allowing you to set up multiple scenes or even have the same button control two separate scenes and name the SmartApps appropriately.

Not specifying any value at all means that value won’t be modified in that scene. For example, if you just put in a color temperature for a scene but no dim level or color information, then all bulbs will change to that color temperature but maintain their current dim level.

Please give the app a try and let me know how it works for you.

Thanks a ton for this app. I have it all set up with virtual momentary switches and its working great.

One note: I was getting aggravated because it was not changing the color of my bulbs. I eventually figured out it would not change the color on a virtual bulb that I was attempting to sync all the others with. I individually selected each of the slave bulbs and it works like a charm.

My only recommendation would be an easier color chooser. Until then, here’s this:

“White”, hue: 0, sat: 0
"Orange", hue: 11, sat: 100
"Red", hue: 100, sat: 100
"Purple", hue: 77, sat: 100
"Green", hue: 30, sat: 100
"Blue", hue: 66, sat: 100
"Yellow", hue: 16, sat: 100
"Pink", hue: 95, sat: 100
"Cyan", hue: 50, sat: 100
"Chartreuse", hue: 25, sat: 100
"Teal", hue: 44, sat: 100
"Magenta", hue: 92, sat: 100
"Violet", hue: 83, sat: 100
"Indigo", hue: 70, sat: 100
"Marigold", hue: 16, sat: 75
"Raspberry", hue: 99, sat: 75
"Fuchsia", hue: 92, sat: 75
"Lavender", hue: 83, sat: 75
"Aqua", hue: 44, sat: 75
"Amber", hue: 11, sat: 75
"Carnation", hue: 99, sat: 50
"Periwinkle", hue: 70, sat: 50
"Pistachio", hue: 30, sat: 50
"Vanilla", hue: 16, sat: 50

1 Like

I did post in the SmartApps Dev section asking about how to make a better color chooser, but the color picker that you can use within SmartThings when controlling a single bulb is not available within a SmartApp for some reason. As such, I’m left with either creating a giant list like you did for people to pick from, or leaving Hue and Saturation up to the user to enter as integers.

I did it the way I did because I didn’t want to limit anyone’s color options; you only get a choice of 100 colors as is when taking these as integers. Thank you, though, for making that list; it will help people figure out where to start.

I’m glad you figured out the slave bulb control; I’ve not tried this app on virtual bulbs but it doesn’t surprise me that it didn’t work. You need to pick the bulbs that you want to control directly.

1 Like

Thanks for posting your work! Works like a champ. :grinning:

Just some thoughts as I have had the chance to play with your great app! Why not both? Sure it is a long list BUT it would much easier to use picking from the list to have it input those values so at least you know where to start but if your needs are more custom then edit those values. Or at least use a smaller list of just the primary and complementary colors of Red, Green, Blue, Cyan, Magenta, Yellow?

  • You might consider renaming the app to make it easier to search for here in the forums and when choosing it from the mobile app? In your definitions I renamed it slightly and modified the description to make it more intuitive to what it does
    name: “Color Bulb Light Scenes Control”,
    namespace: “triosniolin”,
    author: “Will Cole”,
    description: “Use any switch to control color bulb(s) temperature setting or Hue, Saturation levels by user selected scenes.”,

  • Right now if the user only has Color Bulbs the app won’t get by the Color Temp required input. Maybe I don’t understand how the app controls Color bulbs like RGB strips? [quote=“Triosinal, post:1, topic:74863”]
    When choosing bulbs to control, choosing ‘Color’ bulbs will ONLY set the color values for those bulbs. If you also want the bulbs to change color temperature and dim levels along with regular Color Temp bulbs, you’ll need to select the ‘Color’ bulbs under both ‘Color’ and ‘Color Temperature.’

Fairly major update today, read the OP for details!

Again, I think the community shouldn’t need both. I’m going to keep a close eye on the new HTML5 development and SmartApp writing; if and when it becomes possible to add a color picker, or to at least be able to preview the color that you’re choosing, I’ll add that functionality. Maybe I’m just not a big fan of lists like that.

I don’t have any RGB strips. Do they not take the ColorTemp control? Not that it matters anymore, I un-flagged Color Temp as a required input as part of the update today; give the OP a read and check for the latest code!

In any event, thank you for the feedback and I’m glad you enjoy the app!

1 Like

thank you for sharing … very helpful

Got it. For a dummy like me I would rather deal with long lists than trying to look up the info that @LDC2335 provided in a post. :slight_smile:

The RGB bulbs do not take temp color controls directly. I had three Hues color bulbs but I also have 5 RGB setups so I wanted to play around with how those would work with this app.

Any chance you’ve been able to test the RGB strips and such with the new version? I’d love to hear the results.

I realize I’m kind of being a dictator by not adding a list of color options. I don’t have any color bulbs or strips myself, so I don’t have any skin in the game except for the programming time to add them. I just feel like as soon as I add some colors, this conversation will begin:

Person 1: Can you add cerulean? It’s my favorite color.
Person 2: I love bacon, I need a bacon color.
Person 3: That bacon color is fantastic and makes me hungry, please add a steak color so I can pretend I’m having bacon-wrapped tenderloins via my Hue lamps.
Person 1: I prefer my bacon crispy, this bacon color isn’t right, please add ‘crispy bacon.’

I’m trying to head that off by just letting everyone choose the colors directly. I’m working a bit (mostly in my head right now) on a method to be able to preview a color in the app, using an external website, if I can get that working fairly easily it should make this process simpler.

I tried using this and I’m getting some odd results that no one else seems to have mentioned… When I try using it the lights cycle between 3 different colors when I use a switch to trigger them. It goes from a white like color, to a light red/pink color and then a dark red color and repeat. I have no idea as to why this is happening. I’m using the Sylvania Osram bulbs. Is it possible that these bulbs have a color setting that is additive or something? Like I set 30 and then it does 30, 60, 90 and back to 30 because 120 is out of bounds? I’m shooting in the dark here as I’m pretty new to ST development. I did poke around the code and it looks fairly straightforward. Does any one know of anything odd with these bulbs or has any tips for attempting to debug the issue I’m having?

Are you using multiple switches to control the different scenes? For example, in my setup I created 3 virtual buttons - ‘Lights on,’ ‘Lights off,’ and ‘Lights Dim.’ I set up the app selecting 3 scenes, and set the lighting levels I wanted for each button.

If you’re using just one button and trying to set that button to multiple scenes, then the behavior you’re describing will happen.

I had only set up one scene but maybe for some reason it held on to the 3 scenes. I’ll set up 3 different scenes with 3 different switches and see if that changes things. I’ll post back after I try it out. Thanks!

I found a bug in my code and I think it’s fixed now. Check the OP for the latest code and please give it another try.

Just discovered this thread and trying to install the smart app. I get an error on installation in the IDE.

startup failed: script1489507792081865858580.groovy: 1126: expecting EOF, found ‘else’ @ line 1126, column 4. } else { ^ 1 error

Are there some requesites that I’m missing? Any help appreciated.

Thanks for writing. Evidently I made a major copy/paste error in the Github and the file got nearly doubled.

Should be fixed now, please give the code another try.

Yes, that did the trick. Thanks!