Changing color with color code #546
-
Hi, this isn't probably the place to ask this question but I don't really know where else to ask it. My Bulb returns the following data:
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? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
Not quite, the zero is not a separator.
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 |
Beta Was this translation helpful? Give feedback.
-
I ran into the same issue, from my findings it seems that the |
Beta Was this translation helpful? Give feedback.
-
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):
Setting |
Beta Was this translation helpful? Give feedback.
-
Did this in javascript but got a different result. My result is This is the code I used: 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;
}
hsv = {
h: 120,
s: 100,
v: 100
};
console.log(hsv2tuya(hsv)); |
Beta Was this translation helpful? Give feedback.
-
@tromphakvoort looks like you're missing the required parenthesis, i.e you're doing Converting to a discussion. |
Beta Was this translation helpful? Give feedback.
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):
Setting
dps['24']
to the resulting value (007803e803e8
) does the trick on my device (an LED strip in th…