How to change Color 1000 color using AllJoyn?

I am trying to control the LIFX Color 1000 bulb using the AllJoyn protocol. I have successfully turned it on & off and adjusted the brightness. However, I can’t figure out how to change the color. Any help would be greatly appreciated!

Thanks,

Ian

By toggling back & forth between the AllJoyn Explorer app and the LIFX app, I’ve been able to figure out that the Hue values need to be…

red = 0xFFFFFFFF
green = 0x55555580
blue = 0xAAAAAB00

(colors are not necessarily “pure” since I only had a color dial to work with…)

And I’ve found this calculator that gives me an idea about how HSL corresponds to RGB which I’m used to work with.

However, I still don’t understand how the hue degree value becomes the value that AllJoyn expects. Someone please help educate me.

Thanks!

Ian

I don’t know anything about Alljoyn specifically, but from your data, it looks like they are encoding the hue as a 32-bit integer. (This is the same as how the LIFX LAN protocol encodes the hue, except the LAN protocol uses 16 bits instead of 32.)

Therefore, alljoyn_hue = degree_hue * 0x100000000 / 360

This would make red = 0x00000000, green=0x55555555, blue = 0xaaaaaaaa, which is pretty close to what you found experimentally.

3 Likes

I believe you have solved my riddle. Thank you very much!

I’m not sure using the LIFX bulb as “proof” is the right way. The spec clearly states that the temperature should be in Kelvin, but the lifx bulbs uses some arbitrarily large numbers for the entire number range.
The AllJoyn spec is generally pretty poor wrt to what a certain value is supposed to mean. Ie what is brightness? A ratio for the entire UINT32 range, or lumens? Is 0 off, or the dimmest the bulb can do? What hue value is green? etc etc. Actually the only value they do state what is, is the temperature which is in Kelvin, and this is the one that LIFX seems to have gotten wrong.
I’ve submitted a but to the AllSeen Alliance with comments to the AllJoyn Lighting spec so they can add more information on these things to avoid any confusion.

It would be really great if a LIFX Team Member could provide a bit more information about the values.
While using there API it is really easy to select a color via API - I’m totally stuck to do the same with AllJoyn.
I just guess that converting RGB to HUE (LIFX style) is not a real secret.
So if somebody from LIFX could provide a bit support on this would be really a great help!

Thanks in advance
Manfred

Hi @ManniAT,

LIFX values for Hue, Brightness, Saturation and Kelvin are all represented as uint16_t values in the firmware.

All use the following simple scaling logic to convert from AllJoyn values:

min + (value / UINT32_MAX) * (max - min)

max & min values:

  • Hue: 0 → UINT16_MAX
  • Brightness: 0 → UINT16_MAX
  • Saturation: 0 → UINT16_MAX
  • Kelvin: 1000 → 20000

In addition to the above, a further range check-and-adjustment is done for LIFX Kelvin values (min 2500, max 9000):

((value) < (min) ? (min) : ((value) > (max) ? (max) : (value)))

Cheers,
Daniel

Hi Daniel,

thank you for this information.
I understand the values so far.
And the calcultaion from ppelleti generally works.
Also the other values can be set can be set via Percents / 100 *( UInt32.MaxValu - 1)

But my question was more about finding the correct color in the LIFX Colorspace.
In general there is a kind of conversion from the color of the device (as coordinate in a cie chromatic diagram) to the hue.
This is what I was asking for - a formula to find (for an example) the “correct Red” (gamut mapping).

Anyhow this is not “so important” - I couldn’t find information about it on your site so I was asking.
I was curious if you have such a “mapping function” - if not this is not a stopper or a problem at all.

I really was impressed by your fast answer.
As well as the fast and helpful reactions of your support (I had problems with DHCP on my Ciso).

Thank you again
Manfred

Hi Manfred,

Thanks for your generous praise! Great to see your contributions here.

I was curious if you have such a “mapping function” - if not this is not a stopper or a problem at all.

We don’t currently support such a mapping function. However, I have observed previous work in this area eg. see Lightbow’s comment:

http://www.trustedreviews.com/opinions/smart-lightbulbs-explained#disqus_thread

Cheers,
Daniel

The UINT32_MAX value used above isn’t entirely correct according to the AllJoyn spec. Max value is one less. Ie UINT32_MAX-1

Hello,

I’am trying to control the LIFX via the Alljoyn protocol, can anyone give me guidance about how to do so ? i’m acquainted with the protocol but i can’t find proper documentation about how to do so. ianlee74 can you please five me info about how you managed to control your LIFX via Alljoyn ?

Thanks in advance,

@broxcodes - here’s a very simple example I created that shows how to turn a LIFX bulb on/off and change its color & brightness. I’ll be adding much more detail via a blog post in the near future but you should be able to figure out what you need to get started from this.

This example is in C# (Visual Studio 2015). Let me know if anything isn’t clear.

Good luck!
Ian

1 Like

Thanks a lot Ianlee74, this helped me out especially with the HSL colors.

Cheers,
Mouad