# Light - selected color values

**URL:** https://community.homey.app/t/light-selected-color-values/54925
**Category:** Developers
**Tags:** app
**Created:** [November 16, 2021, 3:31pm UTC](https://community.homey.app/t/light-selected-color-values/54925 "2021-11-16T15:31:09Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![palatin.bence](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/palatin.bence/32/36980_2.png) [@palatin.bence](https://community.homey.app/u/palatin.bence)
#### Post date: [November 16, 2021, 3:31pm UTC](https://community.homey.app/t/light-selected-color-values/54925/1 "2021-11-16T15:31:10Z")

</div>

Hello,

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?

---

<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: [November 16, 2021, 6:03pm UTC](https://community.homey.app/t/light-selected-color-values/54925/2 "2021-11-16T18:03:36Z")

</div>

This might be of help

> **[Color Tools](https://homey.app/en-us/app/com.sdn.color-tools/Color-Tools/)**
>
> Convert color data to processable values

---

<div class="post-metadata">

### Author: ![palatin.bence](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/palatin.bence/32/36980_2.png) [@palatin.bence](https://community.homey.app/u/palatin.bence)
#### Post date: [November 16, 2021, 8:24pm UTC](https://community.homey.app/t/light-selected-color-values/54925/3 "2021-11-16T20:24:52Z")

</div>

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

---

<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: [November 16, 2021, 9:10pm UTC](https://community.homey.app/t/light-selected-color-values/54925/4 "2021-11-16T21:10:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Edwin\_D](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/edwin_d/32/136417_2.png) [@Edwin\_D](https://community.homey.app/u/Edwin_D)
#### Post date: [November 16, 2021, 9:23pm UTC](https://community.homey.app/t/light-selected-color-values/54925/5 "2021-11-16T21:23:52Z")

</div>

Looks like the dev used this for conversion:  
[https://www.w3.org/TR/css-color-3/#svg-color](https://www.w3.org/TR/css-color-3/#svg-color)

---

<div class="post-metadata">

### Author: ![Shakesbeard](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/shakesbeard/32/15112_2.png) [@Shakesbeard](https://community.homey.app/u/Shakesbeard)
#### Post date: [November 16, 2021, 10:50pm UTC](https://community.homey.app/t/light-selected-color-values/54925/6 "2021-11-16T22:50:10Z")

</div>

> [@Edwin\_D](#):
>
> Looks like the dev used this for conversion

The dev just referred the supported color names there 😉

@palatin.bence  
I can prolly help you there. Just PM me.

---

<div class="post-metadata">

### Author: ![Edwin\_D](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/edwin_d/32/136417_2.png) [@Edwin\_D](https://community.homey.app/u/Edwin_D)
#### Post date: [November 17, 2021, 3:28am UTC](https://community.homey.app/t/light-selected-color-values/54925/7 "2021-11-17T03:28:56Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Shakesbeard](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/shakesbeard/32/15112_2.png) [@Shakesbeard](https://community.homey.app/u/Shakesbeard)
#### Post date: [November 17, 2021, 8:01am UTC](https://community.homey.app/t/light-selected-color-values/54925/8 "2021-11-17T08:01:51Z")

</div>

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

```auto
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,
}

```

---

<div class="post-metadata">

### Author: ![Adrian\_Rockall](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/adrian_rockall/32/13209_2.png) [@Adrian\_Rockall](https://community.homey.app/u/Adrian_Rockall)
#### Post date: [November 17, 2021, 7:59pm UTC](https://community.homey.app/t/light-selected-color-values/54925/9 "2021-11-17T19:59:59Z")

</div>

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.

> <https://github.com/AdyRock/com.switchbot/blob/SDK3/drivers/color_bulb_hub/device.js>
