# Color variable

**URL:** <https://community.homey.app/t/color-variable/75173>\
**Category:** Ideas & Suggestions\
**Created:** [January 16, 2023, 6:07pm UTC](https://community.homey.app/t/color-variable/75173 "2023-01-16T18:07:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dactilus](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dactilus/32/29792_2.png) [@Dactilus](https://community.homey.app/u/Dactilus)\
**Post date:** [January 16, 2023, 6:07pm UTC](https://community.homey.app/t/color-variable/75173/1 "2023-01-16T18:07:26Z")

</div>

Hi,

what about to add color variable type? I have lot of cases, where I want to store actual color of some light, strip etc. for later restore state.

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [January 17, 2023, 11:54am UTC](https://community.homey.app/t/color-variable/75173/2 "2023-01-17T11:54:42Z")

</div>

Color is just a number in the background.

Depending on how you use it, your devices or apps, you should be able to retrieve the actual value, between 0 and 1, and save it as a number variable.

Throught the flowcards of the Device Capabilitites app, you can set colors directly.

---

<div class="post-metadata">

**Author:** ![Dactilus](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dactilus/32/29792_2.png) [@Dactilus](https://community.homey.app/u/Dactilus)\
**Post date:** [January 17, 2023, 12:49pm UTC](https://community.homey.app/t/color-variable/75173/3 "2023-01-17T12:49:15Z")

</div>

You can store separated light components - saturation, hue, temperature, but it needs to create 3 variables per use. I would like to have one variable, which can store color from color picker. Atleast i dont know how to store color to single variable and it would be nice to store it with brightness aswell :-).

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [January 17, 2023, 1:01pm UTC](https://community.homey.app/t/color-variable/75173/4 "2023-01-17T13:01:32Z")

</div>

Well, than my question would be first: how would you re-use the (values of) the color?

Only think i can think of is using scripts like HomeyScript to retrieve the multiple values, put them into a json object.

But you would also need to re-set them using HS i guess.

Because, afaik, you cannot use a tag/token/varialbe when setting a color through a flowcard.

One sec, i’ll create a small flow.

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [January 17, 2023, 1:11pm UTC](https://community.homey.app/t/color-variable/75173/5 "2023-01-17T13:11:47Z")

</div>

Here, like this:

```auto
let name = 'Light Variable Example';
let device =_.find(await Homey.devices.getDevices(), d=>d.name==name); 
let variable = {
  light_hue:device.capabilitiesObj.light_hue.value,
  light_temperature:device.capabilitiesObj.light_temperature.value,
  light_saturation:device.capabilitiesObj.light_saturation.value,
  light_mode:device.capabilitiesObj.light_mode.value
};
return JSON.stringify(variable);

```

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/9/f9d490fd4ec177262d6a5147f948fa0cec1ecb4a.png)

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [January 17, 2023, 1:13pm UTC](https://community.homey.app/t/color-variable/75173/6 "2023-01-17T13:13:22Z")

</div>

Now, you can place the JSON in a variable.

Then you can create a flow which triggers when the variable changes for instance (or start a flow yourself with a JSON text token) and in that flow, you can set the capabilities of the device through HomeyScript.

But, like i said, it depends on how you thought to re-set the real device capabilitites.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [January 18, 2023, 7:54pm UTC](https://community.homey.app/t/color-variable/75173/7 "2023-01-18T19:54:33Z")

</div>

Maybe [Zone Memory](https://homey.app/nl-nl/app/com.sdn.zone-memory/Zone-Memory/) is usable, for (re-)storing more than one value at a time.
