New Color Setting trait: Formatting thoughts


#1

Hi everyone,

I’m currently working on a new trait to support setting the color of light bulbs. It consists of two features:

Optionally, the “color temperature” feature could be activated. You set user defined upper and lower constraints in kelvin. The value in kelvin will be published and received from own topics.

The other feature is setting the actual color in RGB. However, I’m unsure how the value for the MQTT topic could be formatted. I’ve got a couple of ideas there:

  • Plain hex code, e.g. FFFF00 for yellow
  • Somehow formatting each color codes and using decimal numbers, like the message R: 255 G: 255 B: 0
  • JSON formatting the data inside the mqtt payload. I rather like this idea, because both a wide variety of formats (like individual color codes, hex representation and maybe HSV) and even the textual representation of the color the user asked for could be integrated. I image something like {"red": 255, "green": 255, "blue": 0, "requested": "yellow", "hex": "FFFF00"}

What do you guys think? Any ideas or suggestions? What would be the easiest to integrate for you?


#2

I agree that the JSON idea sounds nice. It is certainly the most flexible. My RGB bulbs use a hex color code, but others likely use other formats, so it would be nice to include various formats in one JSON payload.

If we wanted to set the remote status of the bulb by publishing to the /set endpoint, I suppose we would we have to construct a JSON object in the same format and publish that. That sounds like it would work.

Looking forward to this feature!


#3

Json is the most flexible and holds the most data.
Are you putting the color and the color temperature in the same mqtt topic?
Maybe ist better to split them into 2 separate topics…