Rule engine: Set color: Set color by numerical value

I may be missing the ping here but I am wanting to do something simple. What is the hue & Saturation for “white”, “red”, “green”, “yellow”, etc.

Or put another way how do I set color by simply using the name like “white” or “red”?

Thanks,

Joe

Hi Joe, welcome to the community! This post was in the context of specifically wanting to set things by numerical value. If you just want to set a normal color, is there something about the color picker from the setColor() command that doesn’t work for you?

Thanks for the quick reply!!!

I cannot find white using the device you illustrated.

Joe

That does seem to be a bit of a usability gap with the color picker on the Rule Engine compared to that of the dashboard. I’ve noted the feedback.

Long story short, you can adjust the second slider all the way to left for white. That being said, if your bulb also supports color temperature, I would suggest using the setColorTemperature() command as it will produce a more natural ‘white’ that you’re probably used to with regular bulbs.

2700K being a warm white (amber hues), 3500K being a bit cooler/whiter, and beyond 4000K starting to get into cooler/bluish hue of white.


For comparison, in the dashboard color ‘wheel’, you reduce the saturation as you get closer to the center of the wheel which brings you closer to white. In the Rule Engine color sliders, as you reduce the second slider it reduces the saturation but the slider should probably be updated to show that you move toward white rather than gray.

Josh,

I’ve bubbled through it and have a rule to set a bulb red and one to set it white via the color picker.

Having said that, I want to set the color by a variable i.e. $colorred, $colorwhite

Thanks for your help

Joe

Doing it through a single setColor() command with a single variable isn’t officially supported, but I just tried with a few devices and it seems to work. Officially, the setColor() command in SmartThings requires an object as the first parameter with hue, saturation, and optionally level properties.

We have Text, True/False, and Numeric variable types… but notably missing is an ‘Object’ variable type which is why I say it’s not officially supported.

That being said, I tried using a Text variable with the proper object formatting mentioned further up in the thread and to my surprise, it worked… so SmartThings might be doing some special processing of the arguments.

My test rule was just a single setColor() command with my specially formatted variable:

The rest of the details are covered in the notes by James further up in the thread, but if you have specific questions, feel free to ask! :slight_smile:

Josh,

After talking with a photographer friend who really understands color I came away with these tidbits
1- To set color to white, simply set temperature to 7,000
2- Why are we using HUE/Saturation when most of the color world understands and uses RGB? This is a request for a product enhancement.
3- Further the ability to set color (Red) (Green), (Blue), (white) etc. needs to be added as an enhancement as well.

Thanks for your insight.
Joe Baldwin

That’s certainly one approach. Using setColorTemperature() with a value of 7000K will get you “white”, but so will any other color temperature 2200, 3000, etc. You’ll get different ‘temperatures’ with each though.


Image Credit: Understanding Color Temperature (Kelvin)

The lighting and smart home industry more commonly uses hue+saturation. Keep in mind that this isn’t something that SharpTools has defined… these commands are coming from your smart home platform and it defines the commands and the parameters it accepts.

I would note that there are several different color standards and each industry tends to use different standards. RGB is common in digital design and photo editing, but CMYK, Pantone, HSL, HSV and other standards are used in other spaces.

Feel free to create a feature request. I would go back to the point that the standard approach for setting color in a SharpTools rule is just selecting a color from a color picker, so I’m confused where the problem stems from.

If you don’t want to pick from the color picker and want to manually set a color using numeric inputs, it’s up to your smart home platform what color format it accepts. We could perhaps offer a different input method and then convert it to the appropriate format, but that’s already covered by countless online color format converters. :thinking:

Note that some color strips which offer individual Red, Green, Blue, and White color channels do offer the ability to set the individual colors. Again, this depends on the device and what commands it exposes.

1 Like

Hi Josh, I’m very interested in this topic. The issue I have with the Color Picker is that it’s very difficult to get the exact same color for multiple lights. For example, I have 6 LEDs that I’d like to set to the exact same dark blue color. Using the color picker doesn’t well for this application. Instead, I’d rather use a specific variable/command to define the color. Thanks!

1 Like

That’s certainly achievable as noted in the examples above.

1 Like

Is this the correct syntax? I couldn’t tell about spaces before and/or after the comma that separates hue and saturation.

{“hue”:240",“saturation”:100}

The spaces shouldn’t matter, but the quotes do. They should be straight quotes, not curly quotes:

  • " = good
  • = bad

And it looks like you have a rogue quote after the hue value. So it should look more like:

{"hue":240,"saturation":100}
1 Like

This didn’t work for me. Any thoughts? Thanks!

What did the Rule Logs show?

What DTH are you using in smartthings and what do the logs there say?

Hi @Techno_Vol – I just noticed you’re part of our Next Gen Samsung SmartThings beta. You might try sending the hue value in the range of 0-100. This is one of those oddities that we handle automatically for you when you use the color picker – the SmartThings COLOR_MAP range for hue is 0-100, so you have to scale the value to match that. 240 is roughly 67 (240/360 * 100 = 66.66)

1 Like

Thanks @josh, I’ll give that a try.

1 Like

@Chris_C Osram Lightify RGBW A19/BR30 US version (HA) DTH rev 01/19/2018
by gkl_sf

1 Like

@josh That worked for Hue and Saturation, thanks! Can Luminance be set??