jath03 / openrgb-python

A python client for the OpenRGB SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when enabling Razer Blade 15 keyboard

rakinishraq opened this issue · comments

When I enable "Razer Blade 15 (2021 Base)" in the Settings and try to connect to the OpenRGB server, it raises an error as soon as I try to initialize with OpenRGBClient("127.0.0.1", 6742).

Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\openrgb\network.py", line 137, in read
    self.callback(device_id, packet_type, utils.ControllerData.unpack(data, self._protocol_version))
  File "C:\Python39\lib\site-packages\openrgb\utils.py", line 547, in unpack
    metadata = MetaData.unpack(data, version)
  File "C:\Python39\lib\site-packages\openrgb\utils.py", line 489, in unpack
    serial = parse_string(data)
  File "C:\Python39\lib\site-packages\openrgb\utils.py", line 116, in parse_string
    return parse_var(f'{length}s', data).decode().rstrip('\x00')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Projects\Python\prisma\rgb.py", line 55, in <module>
    rgb_keyboard("#ff0000", "ffffff", "000000")
  File "C:\Projects\Python\prisma\rgb.py", line 38, in rgb_keyboard
    client = OpenRGBClient("127.0.0.1", 6742)
  File "C:\Python39\lib\site-packages\openrgb\orgb.py", line 337, in __init__
    self.update()
  File "C:\Python39\lib\site-packages\openrgb\orgb.py", line 502, in update
    self.comms.requestDeviceNum()
  File "C:\Python39\lib\site-packages\openrgb\network.py", line 188, in requestDeviceNum
    self.read()
  File "C:\Python39\lib\site-packages\openrgb\network.py", line 116, in read
    self.callback(device_id, packet_type, buff[0])
  File "C:\Python39\lib\site-packages\openrgb\orgb.py", line 348, in _callback
    self.comms.requestDeviceData(x)
  File "C:\Python39\lib\site-packages\openrgb\network.py", line 181, in requestDeviceData
    self.read()
  File "C:\Python39\lib\site-packages\openrgb\network.py", line 139, in read
    raise utils.ControllerParsingError(f"Unable to parse data from request `{packet_type}` for device #{device_id}") from e
openrgb.utils.ControllerParsingError: Unable to parse data from request `1` for device #2
commented

Looks like another #33. What version of OpenRGB are you using?

I was using 0.6 and after updating to 0.7, I can initialize properly but still get an error:

Traceback (most recent call last):
  File "C:\Projects\Python\prisma\rgb.py", line 59, in <module>
    rgb_keyboard("#ff0000", "#ffffff", "#00ff00")
  File "C:\Projects\Python\prisma\rgb.py", line 55, in rgb_keyboard
    keyboard.zones[0].set_color(col3)
  File "C:\Python39\lib\site-packages\openrgb\orgb.py", line 85, in set_color
    buff = struct.pack("iH", self.id, len(self.leds)) + (color.pack())*len(self.leds)
AttributeError: 'str' object has no attribute 'pack'
commented

The set_color function takes an RGBColor object as an argument, not just a string. It's an easy fix though. just change line 55 to

keyboard.zones[0].set_color(RGBColor.fromHEX(col3))

and make sure that you import RGBColor from openrgb.utils.

Ah, sorry about the silly mistake. Thanks for your time.