# \[Python\] \_to\_rgb parsing things wrong

**URL:** <https://forums.blinkstick.com/t/python--to-rgb-parsing-things-wrong/573>\
**Category:** Uncategorized\
**Created:** [August 28, 2016, 12:32am UTC](https://forums.blinkstick.com/t/python--to-rgb-parsing-things-wrong/573 "2016-08-28T00:32:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MrJaWapa](https://forums.blinkstick.com/letter_avatar_proxy/v4/letter/m/7ab992/32.png) [@MrJaWapa](https://forums.blinkstick.com/u/MrJaWapa)\
**Post date:** [August 28, 2016, 12:32am UTC](https://forums.blinkstick.com/t/python--to-rgb-parsing-things-wrong/573/1 "2016-08-28T00:32:30Z")

</div>

I had a problem with the `hex_to_rgb` and the `name_to_rgb` not converting to rgb, but rather grb.

So `#ff0000` (red) would actually turn the lights to green, and vice versa

I changed line 842 of blinkstick.py from  
`return tuple([int(s, 16) for s in (hex_digits[1:3], hex_digits[3:5], hex_digits[5:7])])`  
to  
`return tuple([int(s, 16) for s in (hex_digits[3:5], hex_digits[1:3], hex_digits[5:7])])`  
Which fixed the problem. Is this a bug, or is there something I’m overlooking?

---

<div class="post-metadata">

**Author:** ![p0ke](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/p0ke/32/14_2.png) [@p0ke](https://forums.blinkstick.com/u/p0ke)\
**Post date:** [August 28, 2016, 11:59am UTC](https://forums.blinkstick.com/t/python--to-rgb-parsing-things-wrong/573/2 "2016-08-28T11:59:53Z")

</div>

Cannot reproduce this. The following example works as expected:

```
r,g,b = led._hex_to_rgb("#ff0000")
led.set_color(channel=0, index=1, red=r,green=g,blue=b)

```

Please show your code to get to know what excactly you are doing.

---

<div class="post-metadata">

**Author:** ![MrJaWapa](https://forums.blinkstick.com/letter_avatar_proxy/v4/letter/m/7ab992/32.png) [@MrJaWapa](https://forums.blinkstick.com/u/MrJaWapa)\
**Post date:** [August 28, 2016, 2:12pm UTC](https://forums.blinkstick.com/t/python--to-rgb-parsing-things-wrong/573/3 "2016-08-28T14:12:11Z")

</div>

```
color = raw_input("\nEnter color:\n")
rgb = bstick._hex_to_rgb(color)
bstick.set_led_data(0, rgb * ledcount)
```

---

<div class="post-metadata">

**Author:** ![p0ke](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/p0ke/32/14_2.png) [@p0ke](https://forums.blinkstick.com/u/p0ke)\
**Post date:** [August 28, 2016, 3:34pm UTC](https://forums.blinkstick.com/t/python--to-rgb-parsing-things-wrong/573/4 "2016-08-28T15:34:56Z")

</div>

OK. It has nothing to do with the hex\_to\_rgb. It is the set\_led\_data, which is in GRB format as shown in the parameter description in blinkstick.py line 445.

---

<div class="post-metadata">

**Author:** ![MrJaWapa](https://forums.blinkstick.com/letter_avatar_proxy/v4/letter/m/7ab992/32.png) [@MrJaWapa](https://forums.blinkstick.com/u/MrJaWapa)\
**Post date:** [August 28, 2016, 4:32pm UTC](https://forums.blinkstick.com/t/python--to-rgb-parsing-things-wrong/573/5 "2016-08-28T16:32:37Z")

</div>

ahhhh, so I was over looking something.

I guess there’s no issue then 😛
