question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Changing color with color code

See original GitHub issue

Hi, this isn’t probably the place to ask this question but I don’t really know where else to ask it. When I request the data from my RGBW lamp it returns dps 20-26 with 24 containing the color, brightness and saturation in colour mode. I can’t seem to understand how this code is build. I’ve read a lot of issues on GitHub with possible explanations but none have completely worked for me.

My Bulb returns the following data:

dps: {
    '20': true,
    '21': 'colour',
    '22': 1000,
    '23': 1000,
    '24': '015303e803e8',
    '25': '000e0d0000000000000000c80000',
    '26': 0
  }

From what i can find on the internet the color is in HSV separating the values with a 0.

What i can’t seem to figure out is why my color code contains letters and what they mean.

Could anyone help me out with this or point me in the right direction?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
f00stxcommented, Nov 17, 2021

The colour code can be (almost) directly decoded to an HSV color value, so if you know what color you’d like, you can also encode the correct color value (the resulting string is just the 3 segments of an HSV value, as hex, and then zero-padded):

function hsv2tuya(hsv) {
    tuyaH = hsv['h'].toString(16).padStart(4, '0')
    tuyaS = (10 * hsv['s']).toString(16).padStart(4, '0')
    tuyaV = (10 * hsv['v']).toString(16).padStart(4, '0')

    return tuyaH + tuyaS + tuyaV
}

// Bright green, #00FF00
hsv = {
    h: 120,
    s: 100,
    v: 100,
}

console.log(hsv2tuya(hsv)) // = 007803e803e8

Setting dps['24'] to the resulting value (007803e803e8) does the trick on my device (an LED strip in the “Arlec GridConnect” family).

1reaction
kueblccommented, Sep 8, 2021

From what i can find on the internet the color is in HSV separating the values with a 0.

Not quite, the zero is not a separator.

What i can’t seem to figure out is why my color code contains letters and what they mean.

This is a hexadecimal representation of color. Two hexadecimal digits represent one byte, so the challenge is figuring out which byte controls which channel.

I would send the bulb values with one byte set at a time and observe what it does, ie ff0000000000 00ff00000000 0000ff000000 … and so on.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML Text Color - HTML Color Codes
In this short tutorial we'll cover how to change the color of your HTML text using Hex color codes, HTML color names, RGB...
Read more >
HTML Color Codes - What's your color
HTML color codes and color palettes. Lighten and darken to find the perfect color. Save palletes to see what works together. Generate CSS...
Read more >
Color code converter | color conversion - RapidTables.com
Color code converter. HEX value is 6 digits (rrggbb). RGB values are in range of 0..255. HSV values are in range of Hue:0..359°,...
Read more >
HTML Color Codes and Names - Computer Hope
These color codes can change the color of the background, text, and tables on a web page.
Read more >
How to change text color in HTML? - Top 3 ways to create ...
We can set the text color of a given HTML element by placing the statement of the color change in the tag that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found