Color variable

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.

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.

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 :-).

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.

Here, like this:

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);

1 Like

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.

Maybe Zone Memory is usable, for (re-)storing more than one value at a time.