Set Global Variable with captured Hex Color

I'm hoping someone can assist with the below. I am wanting to:

  1. capture the hex code for "Light Strip A" to a Global Variable.

then

  1. set "Light Strip B" to that captured color using the Hex code from the Global Variable

I am able to do 2 above with the following:

However I've no idea to accomplish step 1 above. I've tried this:

image

but it results in (null). Same when I try to set it as RGB.

The variable I am using is below
image

Hoping someone can point me in the right direction.

Cheers.

Which integration (driver) are you using with your Hue bulbs on Hubitat? The community favorite (CoCoHue) does not present an RGB hex value for a bulb's color; rather, it lists "Color Temperature", "Saturation" and "Hue", all of which are decimal values. (See your bulb's Status page for reference.)

If your intention is to match both the RGB/HSL* value and the DimLevel of both bulbs, I'd refer you to the built-in Mirror app, expressly made for this purpose. But if you really need to do this in Rule Machine (for whatever reason), you may have to change tactics and deal with values other than what you're currently assuming.

* It is possible to set Hue bulbs using Hue-Sat-Lev as a "color map" (bracketed list object) in the CoCo driver, which RM could do for you as a Custom Action.

1 Like

These are standard attributes (so any complaint driver should do the same), and it's what I'd recommend for the OP, too, even though it will require storing a few different things. It's just easier to work with, and it's the same values setColor() will accept when you need to send the data back (some drivers may accept another format in addition, but hue, saturation, and level are the standard).

But there's more. :slight_smile: Unless your bulb is only RGB (i.e., if it's RGBW/RGB+CT or however else that may be marketed), you could be in RGB (color) mode or CT (color temperature) mode. The former is "color" in the sense of HSV/HSB, RGB, or whatever format you'd represent those in; the latter is shades of white, i.e., color temperature. Different attributes matter for each.

So, to fully capture the state, you'd need to:

  1. Capture the colorMode attribute value

  2. If colorMode is RGB, then:

  • capture hue, saturation, and level attributes
  • use "Set Color" action in RM when restoring, and use the captured-to variables for hue, saturation, and level
  1. If colorMode is CT, then:
  • capture colorTemperature and level attributes
  • use "Set Color Temperature" action in RM when restoring, and use the captured-to variables for the color temperature and level

This also means you'll need to use a conditional, like IF colorModeVariable = 'RGB' THEN..., to do different actions based on this value. Of course, if you truly only care about color, you can ignore this difference.

Finally, it should be noted that RM includes built-in "capture" and "restore" actions for switches, dimmers, and bulbs. You can't access those saved values, only restore their state later, but if your only goal is to capture, change something, then restore, they would also work (with less effort).

2 Likes

Thank you both. Very much appreciated. I am using CoCoHue which would explain why I couldn't capture the hex code.

Iโ€™d use the mirror app except I canโ€™t use it selectively. I.e it always mirrors. What I am trying to accomplish is to have my kitchen kicker LEDs all the same color (which is easy enough) except when the oven is on. As soon as the oven is on, have the kicker under it turn red (but leave the rest). Then once the oven finishes, turn the oven kicker led to the same color as the other kickers. This was the part I was getting stuck at.

Iโ€™ll put together a rule capturing the suggested attributes and see if that works and will report back.

Many thanks!

1 Like

Yep. CAPTURE and RESTORE will take you precisely where you need to go with this.

1 Like

Thanks heaps again for your help. This worked perfectly!

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.