Homey Community Forum

Light - selected color values


I’m trying to create an app for controlling a light. The onoff, and the dim feature is already working, but when I try to change the color of the light I just cannot change it. The light accepts color in RGB. From the homey i got the Hue and Saturation values when I select the desired color, but without the selected color HSV/HSL values I cannot convert it back RGB.

Does anybody have any info how can I get these informations?

This might be of help

Thanks but, I already checked it, but i need to convert it in the source code and not in flows.

Ask the dev if he wants give you a pointer? Contact links are on that app page…

Looks like the dev used this for conversion:

The dev just referred the supported color names there :wink:

I can prolly help you there. Just PM me.

But there is sample javascript code there too, so the dev could have :wink:

The dev thinks that the following snippet of pseudo code might be helpful and give pointers into the right direction.

this.TinyColor = require('tinycolor2');
var colorObj = this.TinyColor(herecomesthecolordatasstring);
var hsvObj = colorObj.toHsv();
var someparametersobject {
          'parsed-color-hue': Math.round((this.ColorUtilities.MapScale(0, 360, 0, 1, hsvObj.h) + Number.EPSILON) * 100) / 100,
          'parsed-color-saturation': Math.round((hsvObj.s + Number.EPSILON) * 100) / 100,
          'parsed-color-brightness': Math.round((hsvObj.v + Number.EPSILON) * 100) / 100,

I have just added the colour bulb to the Switchbot app that solves the same problem.
The bulbs use RGB so I have to convert from HSL to RGB and back.