Giter Club home page Giter Club logo

openrgb-python's People

Contributors

inlart avatar jath03 avatar koying avatar krzys-h avatar peetz0r avatar shawnc722 avatar stuporglue avatar triikk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

openrgb-python's Issues

Issue with brigtness with protocol < 3 ?

A user of the HA got the following stackdump, with v0.2.10:

[139967665461568] '<=' not supported between instances of 'NoneType' and 'NoneType'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1492, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1527, in _execute_service
await handler.job.target(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
await self.hass.helpers.service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 658, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 843, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 695, in _handle_entity_call
await result
File "/usr/src/homeassistant/homeassistant/components/light/init.py", line 462, in async_handle_light_on_service
await light.async_turn_on(**filter_turn_on_params(light, params))
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 895, in async_turn_on
await self.hass.async_add_executor_job(ft.partial(self.turn_on, **kwargs))
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/openrgb/light.py", line 162, in turn_on
self._device_turned_on(**kwargs)
File "/config/custom_components/openrgb/light.py", line 286, in _device_turned_on
self._set_effect()
File "/config/custom_components/openrgb/light.py", line 310, in _set_effect
self._light.set_mode(self._effect)
File "/usr/local/lib/python3.9/site-packages/openrgb/orgb.py", line 231, in set_mode
data = mode.pack(self.comms._protocol_version)
File "/usr/local/lib/python3.9/site-packages/openrgb/utils.py", line 276, in pack
self.validate()
File "/usr/local/lib/python3.9/site-packages/openrgb/utils.py", line 256, in validate
assert self.brightness_min <= self.brightness <= self.brightness_max
TypeError: '<=' not supported between instances of 'NoneType' and 'NoneType'

I suspect it is due to the ORGB protocol 3 support?
brightness_min / brightness_max seems to be None otherwise...

OpenRGBClient() fails on recent builds in linux

The same builds work fine in windows, using the OpenRGB protocol version 1. When connecting to the server on linux, it fails and the OpenRGB window shows it tried to use protocol version 2. The same code runs fine on version 0.5 of OpenRGB, and it was running on the nightly builds until recently.
Here's the crash log:

  File "/SharedData/RGB/visualizer.py", line 28, in <module>
    client = OpenRGBClient()
  File "/home/shawn/.local/lib/python3.8/site-packages/openrgb/orgb.py", line 267, in __init__
    self.comms.requestDeviceNum()
  File "/home/shawn/.local/lib/python3.8/site-packages/openrgb/network.py", line 180, in requestDeviceNum
    self.read()
  File "/home/shawn/.local/lib/python3.8/site-packages/openrgb/network.py", line 118, in read
    self.callback(device_id, packet_type, buff[0])
  File "/home/shawn/.local/lib/python3.8/site-packages/openrgb/orgb.py", line 282, in _callback
    self.comms.requestDeviceData(x)
  File "/home/shawn/.local/lib/python3.8/site-packages/openrgb/network.py", line 173, in requestDeviceData
    self.read()
  File "/home/shawn/.local/lib/python3.8/site-packages/openrgb/network.py", line 137, in read
    self.callback(device_id, packet_type, utils.ControllerData.unpack(data, self._protocol_version))
  File "/home/shawn/.local/lib/python3.8/site-packages/openrgb/utils.py", line 464, in unpack
    start, metadata = MetaData.unpack(data, version, start)
  File "/home/shawn/.local/lib/python3.8/site-packages/openrgb/utils.py", line 411, in unpack
    start, val = parse_string(data, start)
  File "/home/shawn/.local/lib/python3.8/site-packages/openrgb/utils.py", line 99, in parse_string
    val = struct.unpack(f"{size}s", data[start:start + size])[0].decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 0: invalid continuation byte```
If there's any way I can help out with figuring out this issue please let me know!

Issues connecting through Home Assistant instance running on TrueNAS

Trying to set up OpenRGB integration for Home Assistant but get a connection error.

Opened a ticket here and the developer suggested I post the issue here as well.

System Info:

version core-2021.4.6
installation_type Home Assistant Core
dev false
hassio false
docker false
virtualenv true
python_version 3.8.9
os_name FreeBSD
os_version 12.2-RELEASE-p3
arch amd64

Log entry:

Traceback (most recent call last):
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/components/http/security_filter.py", line 56, in security_filter_middleware
    return await handler(request)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
    return await handler(request)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/components/http/auth.py", line 135, in auth_middleware
    return await handler(request)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/components/http/view.py", line 131, in handle
    result = await result
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/components/config/config_entries.py", line 155, in post
    return await super().post(request, flow_id)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/components/http/data_validator.py", line 60, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/data_entry_flow.py", line 107, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/data_entry_flow.py", line 156, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/data_entry_flow.py", line 214, in _async_handle_step
    result: dict = await getattr(flow, method)(user_input)
  File "/home/homeassistant/homeassistant/custom_components/openrgb/config_flow.py", line 76, in async_step_user
    await asyncio.wait_for(
  File "/usr/local/lib/python3.8/asyncio/tasks.py", line 494, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/homeassistant/custom_components/openrgb/config_flow.py", line 24, in _try_connect
    conn = OpenRGBClient(_host, _port, name=_client_id)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/openrgb/orgb.py", line 263, in __init__
    self.comms = NetworkClient(self._callback, address, port, name, protocol_version)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/openrgb/network.py", line 42, in __init__
    self.start_connection()
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/openrgb/network.py", line 64, in start_connection
    self.send_header(0, utils.PacketType.REQUEST_PROTOCOL_VERSION, struct.calcsize('I'))
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/openrgb/network.py", line 204, in send_header
    sent = self.sock.send(data, NOSIGNAL)
NameError: name 'NOSIGNAL' is not defined

Finding the size of DRGB LEDs

I'm trying to do something like this:

motherboard = client.get_devices_by_type(DeviceType.MOTHERBOARD)
for mobo in motherboard:
    for zone in mobo.zones:
        # Addressable RGBs
        if zone.type == ZoneType.LINEAR:
            # Check if direct mode is in use
            if mobo.active_mode != 0:
                for mode in mobo.modes:
                    if mode.name == 'Direct':
                        mobo.set_mode('Direct')
            find_led_count(zone)

And

def find_led_count(zone):
    for size in range(1, 100):
        zone.resize(size)
        zone.set_color(RGBColor(255, 255, 255), start=size, end=size, fast=False)

I was hoping that when resize is more than actual amount of leds in fan/led strip there would be exception that I could catch.
At the moment python-openrgb seems to get stuck waiting for openrgb when I resize to 10 (avaialble leds is 9). All leds go black (I take this indication that led controller detected bad configuration) and:

^CTraceback (most recent call last):
  File "/usr/local/bin/rgb", line 135, in <module>
    find_led_count(zone)
  File "/usr/local/bin/rgb", line 78, in find_led_count
    zone.set_color(RGBColor(123, 123,0 ), start=size, end=size, fast=False)
  File "/usr/lib/python3.8/site-packages/openrgb/orgb.py", line 80, in set_color
    self.update()
  File "/usr/lib/python3.8/site-packages/openrgb/utils.py", line 549, in update
    self.comms.requestDeviceData(self.device_id)
  File "/usr/lib/python3.8/site-packages/openrgb/network.py", line 119, in requestDeviceData
    self.read()
  File "/usr/lib/python3.8/site-packages/openrgb/network.py", line 77, in read
    self.sock.recv_into(header)
KeyboardInterrupt

And openrgb outputs not and if you try to stop it then:

Attempting to connect to local OpenRGB server.
Connection attempt failed
Local OpenRGB server unavailable, running standalone.
Network connection thread started on port 6742
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
Network server started
Server connection closed
terminate called after throwing an instance of 'std::system_error'
  what():  Invalid argument
Aborted

Is this possible or is there just bug in python-openrgb (Version: 0.2.3) or openrgb (0.5)?

EDIT: upgraded python-openrgb to 0.2.5 but behaviour seems to be same.

"IndexError: list assignment index out of range" when creating OpenRGBClient object

  • OS: Arch Linux
  • OpenRGB version: openrgb-git r618.b3cadba-1
  • openrgb-python version: python-openrgb-git v0.0.5.r1.gf32661a-1 (AUR package I made myself)
Full traceback
client = OpenRGBClient()
6 23
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.8/site-packages/openrgb/network.py", line 61, in listen
    self.callback(device_id, packet_type, utils.ControllerData.unpack(data))
  File "/usr/lib/python3.8/site-packages/openrgb/utils.py", line 428, in unpack
    start, zones = parse_list(ZoneData, data, start)
  File "/usr/lib/python3.8/site-packages/openrgb/utils.py", line 114, in parse_list
    start, thing = kind.unpack(data, start, x)
  File "/usr/lib/python3.8/site-packages/openrgb/utils.py", line 336, in unpack
    matrix[y][x] = struct.unpack("I", data[start:start + struct.calcsize("I")])
IndexError: list assignment index out of range
^CTraceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.8/site-packages/openrgb/orgb.py", line 207, in __init__
    sleep(.2)

error when calling OpenRGBClient()

if i run client = OpenRgbClient() i get this error message:
>>> client = OpenRGBClient() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.10/site-packages/openrgb/orgb.py", line 386, in __init__ self.update() File "/usr/lib/python3.10/site-packages/openrgb/orgb.py", line 568, in update self.comms.requestDeviceNum() File "/usr/lib/python3.10/site-packages/openrgb/network.py", line 214, in requestDeviceNum self.read() File "/usr/lib/python3.10/site-packages/openrgb/network.py", line 116, in read self.callback(device_id, packet_type, buff[0]) File "/usr/lib/python3.10/site-packages/openrgb/orgb.py", line 398, in _callback self.comms.requestDeviceData(x) File "/usr/lib/python3.10/site-packages/openrgb/network.py", line 207, in requestDeviceData self.read() File "/usr/lib/python3.10/site-packages/openrgb/network.py", line 137, in read self.callback(device_id, packet_type, utils.ControllerData.unpack(data, self._protocol_version)) File "/usr/lib/python3.10/site-packages/openrgb/utils.py", line 599, in unpack mode = ModeData.unpack(data, version, x) File "/usr/lib/python3.10/site-packages/openrgb/utils.py", line 330, in unpack color_mode = ModeColors(parse_var('I', data)) File "/usr/lib/python3.10/enum.py", line 385, in __call__ return cls.__new__(cls, value) File "/usr/lib/python3.10/enum.py", line 710, in __new__ raise ve_exc ValueError: 64 is not a valid ModeColors

I installed openrgb-python with the python-openrgb-git AUR package and use OpenRGB version 0.81 with Python Version 3.10.9

OpenRGBClient() fails to get number of devices

Hello, this issue might be similar to #29 - I get this error:

OpenRGB: 0.6
openrgb-python: 0.2.9

Traceback (most recent call last):
  File "./test.py", line 8, in <module>
    client = OpenRGBClient()
  File "/home/redaxmedia/.local/lib/python3.8/site-packages/openrgb/orgb.py", line 268, in __init__
    self.comms.requestDeviceNum()
  File "/home/redaxmedia/.local/lib/python3.8/site-packages/openrgb/network.py", line 176, in requestDeviceNum
    self.read()
  File "/home/redaxmedia/.local/lib/python3.8/site-packages/openrgb/network.py", line 114, in read
    self.callback(device_id, packet_type, buff[0])
  File "/home/redaxmedia/.local/lib/python3.8/site-packages/openrgb/orgb.py", line 283, in _callback
    self.comms.requestDeviceData(x)
  File "/home/redaxmedia/.local/lib/python3.8/site-packages/openrgb/network.py", line 169, in requestDeviceData
    self.read()
  File "/home/redaxmedia/.local/lib/python3.8/site-packages/openrgb/network.py", line 133, in read
    self.callback(device_id, packet_type, utils.ControllerData.unpack(data, self._protocol_version))
  File "/home/redaxmedia/.local/lib/python3.8/site-packages/openrgb/utils.py", line 466, in unpack
    start, metadata = MetaData.unpack(data, version, start)
  File "/home/redaxmedia/.local/lib/python3.8/site-packages/openrgb/utils.py", line 413, in unpack
    start, val = parse_string(data, start)
  File "/home/redaxmedia/.local/lib/python3.8/site-packages/openrgb/utils.py", line 101, in parse_string
    val = struct.unpack(f"{size}s", data[start:start + size])[0].decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa8 in position 0: invalid start byte

You codebase contains lot of [0] that might cause nullpointer exceptions or code not to work as expected. That being said, it might be nice to raise more exceptions or fix potential unsafe code.

OpenRGBDisconnected When Setting Color for Zone

openrgb: 0.6
openrgb-python: 0.2.13

running this code:

import openrgb
from openrgb.utils import RGBColor, DeviceType

rgb = openrgb.OpenRGBClient()
cooler = rgb.get_devices_by_type(DeviceType.COOLER)[0] # AMD Wraith Prism
cooler_fan = cooler.zones[1]
cooler_fan.set_color(RGBColor(255, 255, 255))

results in this error after a few seconds:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.9/site-packages/openrgb/orgb.py", line 90, in set_color
    self.update()
  File "/usr/lib/python3.9/site-packages/openrgb/utils.py", line 664, in update
    self.comms.requestDeviceData(self.device_id)
  File "/usr/lib/python3.9/site-packages/openrgb/network.py", line 179, in requestDeviceData
    self.send_header(device, utils.PacketType.REQUEST_CONTROLLER_DATA, struct.calcsize('I'))
  File "/usr/lib/python3.9/site-packages/openrgb/network.py", line 210, in send_header
    raise utils.OpenRGBDisconnected("SDK server did not respond to previous request")
openrgb.utils.OpenRGBDisconnected: SDK server did not respond to previous request

Any further attempts to communicate with the server result in the same exception.

Random hangs on client connect

Hi - nice project! Started playing around with it today and found something a bit odd:
4 out of 5 times (more or less), it works perfectly
Every 1 in 5 or so, it gets stuck trying to connect. The client shows up on the server, and if I interrupt it with CTRL-C, I get

client = OpenRGBClient('10.0.0.99', 6742, 'Python client')
  File "/home/olesk/venvs/rgb_controller/lib/python3.8/site-packages/openrgb/orgb.py", line 236, in __init__
    sleep(.2)
KeyboardInterrupt

It seems it gets stuck on device detection:

while any((dev is None for dev in self.devices)):
            sleep(.2)

This might be an upstream/server problem, but I thought I should report. I'll try the slightly more bleeding edge package and see if I get the same problem. I'm testing is WSL (Ubuntu) for Windows 10 for the record.

OpenRGB [WinError 10061]

Heyo, i'm trying to use this library and i'm getting this error.

ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

This is my current code.

from openrgb import OpenRGBClient

client = OpenRGBClient("192.168.0.51", 8000)

print(client.devices())

set_color of LED Class doesn't take into account zones

Well the problem is pretty simple, if one of the devices has more than 1 zone and you want to change the color of a specific LED in a specific zone you run into "undefined" behavior that makes it so the LED of the last zone (i think it's the last one) you touched with the same ID gets modified.

Looking into the source you can find this:

def set_color(self, color: utils.RGBColor, fast: bool = False):
'''
Sets the color of the LED
:param color: the color to set the LED to
:param fast: If you care more about quickly setting colors than having correct internal state data, then set :code:fast\ to :code:True
'''
self.comms.send_header(
self.device_id,
utils.PacketType.RGBCONTROLLER_UPDATESINGLELED,
struct.calcsize("i3bx")
)
buff = struct.pack("i", self.id) + color.pack()
self.comms.send_data(buff)
if not fast:
self.update()

As you can see this method makes no reference to the zone in any part, meaning you can't actually change individual leds from different zones

To replicate grab a device with multiple zones and do a for loop of each zone changing the leds one by one. You'll find you'll get unexpected results.

EDIT: I grabbed the current version doing pip3 install openrgb-python

OpenRGBClient() hangs on update_profiles() (Win10)

Running the example file, the script hangs without providing any error. Debugging the program, the last function to execute is requestProfileList(). It sends the header, then gets to line 95: self.sock.recv_into(header) before hanging indefinitely.

The client shows up in the OpenRGB SDK Server tab. I have the following devices:

X570 I Aorus Pro WiFi
SteelSeriesRival 300 Mouse

Using openrgb-python version 0.2.6 on python 3.9.2

AttributeError when calling RGBColor method fromHEX

I am getting an error when trying to convert a HEX string to RGBColor using the provided method fromHEX:

Exception has occurred: AttributeError
type object 'RGBColor' has no attribute 'fromHEX'
  File "xxxxx.py", line yy, in zzz
    backColor = RGBColor.fromHEX('#800000')

In addition, in VSCode IntelliSense doesnt show the fromHEX method, even though interestingly enough it does show fromHSV correctly

AttributeError when SDK server is not fully initialized

I'm starting the server from the python process then repeatedly attempting a connection until it's ready, but it seems there's some short period where the server will respond to a connection but it's not actually ready, or openrgb-python has not yet received some initial state (just guessing here). It seems to work fine after a couple more attempts if I also handle the AttributeError in addition to the ConnectionRefusedError.

Traceback (most recent call last):
  File "C:/Users/user/Scripts/python/rgb/rgb_effects.py", line 30, in open_connection
    client = OpenRGBClient()
  File "C:\Users\user\Scripts\python\rgb\venv\lib\site-packages\openrgb\orgb.py", line 234, in __init__
    self.comms.requestDeviceNum()
  File "C:\Users\user\Scripts\python\rgb\venv\lib\site-packages\openrgb\network.py", line 123, in requestDeviceNum
    self.read()
  File "C:\Users\user\Scripts\python\rgb\venv\lib\site-packages\openrgb\network.py", line 94, in read
    self.callback(device_id, packet_type, buff[0])
  File "C:\Users\user\Scripts\python\rgb\venv\lib\site-packages\openrgb\orgb.py", line 243, in _callback
    if data != self.device_num or data != len(self.devices):
AttributeError: 'OpenRGBClient' object has no attribute 'devices'

Not a critical issue by any means, but repeatedly retrying a connection isn't an uncommon thing in general so it'd be nice it it were cleaner

Attempting to set memory color only sets a few of the led's

Hi,

I've been trying to use OpenRGB and this python client to set the color in my rig and while it works for all of my fans and the motherboard itself, I am having issues with setting memory colors.

Using the examples in the examples folder seems to work okay and it is able to change the individual LED's just fine. If I issue a command to set the whole module to a single color it seems to skip at least the first two LED's.

Motherboard: Gigabyte Aorus Master X570
Memory: G.Skill Trident Z Neo

Code being used to change colors:

#!/usr/bin/env python3
from openrgb import OpenRGBClient
from openrgb.utils import RGBColor, DeviceType, ZoneType
from time import sleep

client = OpenRGBClient()

client.clear() # Turns everything off
motherboard = client.get_devices_by_type(DeviceType.DEVICE_TYPE_MOTHERBOARD)[0]
memory_module_0 = client.get_devices_by_type(DeviceType.DEVICE_TYPE_DRAM)[0]
memory_module_1 = client.get_devices_by_type(DeviceType.DEVICE_TYPE_DRAM)[1]

motherboard.set_color(RGBColor(155, 25, 40))
memory_module_0.set_color(RGBColor(155, 25, 40))
memory_module_1.set_color(RGBColor(155, 25, 40)) 

Any insight into what I might be doing wrong would be extraordinarily helpful. Also, are there more examples anywhere? Haven't had much luck with setting effects. It might be because the effects need to be common to the devices (Breathing for instance) but I am unsure. My hope is that once I get whole device colors worked out I can step further into more granular control of LED's for more advanced effects.

Thanks and have a great day.

Errors when trying to run example code

Hi,

I have compiled the latest OpenRGB from gitlab and installed both the git and pip3 versions of openrgb-python and get the following error when trying to run the example code in basics.py.

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/bobris/.local/lib/python3.8/site-packages/openrgb/network.py", line 61, in listen
    self.callback(device_id, packet_type, utils.ControllerData.unpack(data))
  File "/home/bobris/.local/lib/python3.8/site-packages/openrgb/utils.py", line 426, in unpack
    start, mode = ModeData.unpack(data, start, x)
  File "/home/bobris/.local/lib/python3.8/site-packages/openrgb/utils.py", line 267, in unpack
    start += RGBColor.size
AttributeError: type object 'RGBColor' has no attribute 'size'

Newbie question/error: ImportError: cannot import name 'OpenRGBClient' from partially initialized module 'openrgb' (most likely due to a circular import)

Hi,

Just experimenting with Python, I'm trying to get the module working, but I'm getting the following error when running the sample code below:

from openrgb import OpenRGBClient
cli = OpenRGBClient()
root@charon:~# python3 openrgb.py 
Traceback (most recent call last):
  File "/root/openrgb.py", line 1, in <module>
    from openrgb import OpenRGBClient
  File "/root/openrgb.py", line 1, in <module>
    from openrgb import OpenRGBClient
ImportError: cannot import name 'OpenRGBClient' from partially initialized module 'openrgb' (most likely due to a circular import) (/root/openrgb.py)

Can you please point me in the right direction?

Getting confusing parsing[?] error running example code

The below error is generated every time I run the example code given by the readme. I don't know if it's a silly mistake on my part or a problem with the module. Honestly, it's probably the former. Also a screenshot showing the server I have running in OpenRGB and that a client did connect to it.

image

  File "C:\Users\[user]\anaconda3\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:\Users\[user]\anaconda3\lib\site-packages\openrgb\utils.py", line 547, in unpack
    metadata = MetaData.unpack(data, version)
  File "C:\Users\[user]\anaconda3\lib\site-packages\openrgb\utils.py", line 489, in unpack
    serial = parse_string(data)
  File "C:\Users\[user]\anaconda3\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 0xa6 in position 0: invalid start byte

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

Traceback (most recent call last):
  File "example_code.py", line 4, in <module>
    client = OpenRGBClient()
  File "C:\Users\[user]\anaconda3\lib\site-packages\openrgb\orgb.py", line 287, in __init__
    self.comms.requestDeviceNum()
  File "C:\Users\[user]\anaconda3\lib\site-packages\openrgb\network.py", line 188, in requestDeviceNum
    self.read()
  File "C:\Users\[user]\anaconda3\lib\site-packages\openrgb\network.py", line 116, in read
    self.callback(device_id, packet_type, buff[0])
  File "C:\Users\[user]\anaconda3\lib\site-packages\openrgb\orgb.py", line 302, in _callback
    self.comms.requestDeviceData(x)
  File "C:\Users\[user]\anaconda3\lib\site-packages\openrgb\network.py", line 181, in requestDeviceData
    self.read()
  File "C:\Users\[user]\anaconda3\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 #1```





Is there a function to "Rescan Devices" via the API?

When USB devices disconnect and reconnect to OpenRGB, OpenRGB looses control of them and I have to "Rescan Devices" in the UI.

I was hoping to use the openrgb-python client to trigger "Rescan Devices" but I could not find a function for that in the documentation and I couldn't find anything in the source called rescan...

image

Last LED in addressable strip getting wrong color

Summary

When setting colour to an addressable RGB strip, the final colour set seems to be ignored and is replaced by a different random colour.

It is always the last colour, not the nth.

It is not a problem with my LEDs (3 fans of 9 LEDs each - in the sample code below I am using a length of 9 which is just my first and most visible fan) and probably not the controller hardware either. If I resize it down to a portion of my strip, the last address of the size always exhibits the issue. Also, I have mitigated the issue by resizing the strip in OpenRGB to be one bigger than my real strip (3 x 9 = 27 LEDs, resized in OpenRGB to 28) - the erroneous colours fall off the end of the real strips and I observe no error on my actual LEDs, only in the software. I am experiencing the same issue with both the ARGB header and the motherboard's integrated addressable LEDs

I'm running OpenRGB Windows 0.7 (build date 12/30/2021) and pip-installed openrgb-python 0.2.14. The LED controller is an ASUS Aura version AULA3-6K75-0207.

Example code:

>>> from openrgb import OpenRGBClient
>>> from openrgb.utils import RGBColor, ZoneType
>>> from openrgb.orgb import Zone
>>> import time
>>> import math
>>> cli = OpenRGBClient()
>>> zone = max([
...     z for dev in cli.ee_devices for z in dev.zones if z.type == ZoneType.LINEAR],
...     key=lambda z: len(z.colors))
>>>
>>> zone.set_colors([RGBColor.fromHSV(0,100,100)] * 9) 
>>> zone.colors
[RGBColor(red=255, green=0, blue=0), RGBColor(red=255, green=0, blue=0), RGBColor(red=255, green=0, blue=0), RGBColor(red=255, green=0, blue=0), RGBColor(red=255, green=0, blue=0), RGBColor(red=255, green=0, blue=0), RGBColor(red=255, green=0, 
blue=0), RGBColor(red=255, green=0, blue=0), RGBColor(red=109, green=0, blue=101)]

Using the "fastled style" API does the same

>>> zone.colors = [RGBColor.fromHSV(120,100,100)] * 9  
>>> zone.colors
[RGBColor(red=0, green=255, blue=0), RGBColor(red=0, green=255, blue=0), RGBColor(red=0, green=255, blue=0), RGBColor(red=0, green=255, blue=0), RGBColor(red=0, green=255, blue=0), RGBColor(red=0, green=255, blue=0), RGBColor(red=0, green=255, 
blue=0), RGBColor(red=0, green=255, blue=0), RGBColor(red=0, green=255, blue=0)]
>>> zone.show()
>>> zone.colors
[RGBColor(red=0, green=255, blue=0), RGBColor(red=0, green=255, blue=0), RGBColor(red=0, green=255, blue=0), RGBColor(red=0, green=255, blue=0), RGBColor(red=0, green=255, blue=0), RGBColor(red=0, green=255, blue=0), RGBColor(red=0, green=255, 
blue=0), RGBColor(red=0, green=255, blue=0), RGBColor(red=109, green=0, blue=101)]

OpenRGB itself "reflects the error accurately" (that is - it seems to occur in openrgb-python or between it and OpenRGB)

image

As does the LED strip:

IMG_20220108_142333_HDR

Colour preferences

The erroneous colour seems to have a preference for particular colours. Sampling zone.colors[-1] after setting colour shows the last address being set to the following colours, the first column being the number of times that colour appeared (not consecutively - it will randomly jump between these colours):

    160 RGBColor(red=0, green=0, blue=0)
     52 RGBColor(red=0, green=0, blue=101)
     20 RGBColor(red=0, green=0, blue=116)
      4 RGBColor(red=0, green=0, blue=128)
    142 RGBColor(red=0, green=0, blue=212)
     14 RGBColor(red=0, green=128, blue=0)
     42 RGBColor(red=1, green=0, blue=212)
      6 RGBColor(red=108, green=0, blue=0)
    209 RGBColor(red=109, green=0, blue=101)
     38 RGBColor(red=116, green=0, blue=0)
     40 RGBColor(red=116, green=0, blue=96)
     32 RGBColor(red=120, green=0, blue=0)
     20 RGBColor(red=121, green=0, blue=0)
     92 RGBColor(red=121, green=0, blue=116)
      2 RGBColor(red=146, green=164, blue=0)
      2 RGBColor(red=161, green=164, blue=0)
     38 RGBColor(red=161, green=164, blue=212)
     22 RGBColor(red=184, green=163, blue=212)
     44 RGBColor(red=189, green=163, blue=212)
     32 RGBColor(red=195, green=163, blue=212)
     11 RGBColor(red=84, green=161, blue=212)

But cancelling and restarting my sampler program seems to get a new palette of errors?

   1981 RGBColor(red=0, green=0, blue=0)
    903 RGBColor(red=0, green=0, blue=1)
     56 RGBColor(red=0, green=0, blue=127)
    184 RGBColor(red=0, green=0, blue=22)

And another:

     35 RGBColor(red=0, green=0, blue=0)
      9 RGBColor(red=0, green=0, blue=32)
      2 RGBColor(red=0, green=0, blue=45)
      1 RGBColor(red=110, green=32, blue=112)
    151 RGBColor(red=167, green=164, blue=212)
     37 RGBColor(red=197, green=163, blue=212)
     93 RGBColor(red=206, green=164, blue=212)
     16 RGBColor(red=207, green=164, blue=212)
     40 RGBColor(red=215, green=164, blue=212)
      1 RGBColor(red=22, green=0, blue=22)
      2 RGBColor(red=27, green=0, blue=27)
      5 RGBColor(red=67, green=97, blue=108)
     73 RGBColor(red=97, green=116, blue=101)
    164 RGBColor(red=97, green=116, blue=105)

Setting the LED individually with the FastLED API

I've also just discovered that setting that one LED specifically works just fine. This works as expected, for the singular last LED:

for i in range(360):
  zone.colors[8] = RGBColor.fromHSV(i,100,100)
  zone.show()
  time.sleep(0.016)

Although this still exhibits the issue:

for i in range(360):
  for x in range(9):
    zone.colors[x] = RGBColor.fromHSV(i,100,100)
  zone.colors[8] = RGBColor.fromHSV(i,100,100)
  zone.show()
  time.sleep(0.016)

fast=True

Doing zone.set_colors([RGBColor.fromHSV(0,100,100)] * 9, fast=True) or zone.show(fast=True) makes no difference as far as I can tell.

Start / Stopping the client

When implementing a longer running client, I'd like the ability to be able to stop / start the connection to OpenRGB + handle disconnections a bit more gracefully.

Easiest way I can see to implement these would be:

Start / Stopping

  • Checking a variable instead of always evaluating to true on https://github.com/jath03/openrgb-python/blob/master/openrgb/network.py#L60
  • Implementing some cleanup logic after this loop to close the socket
  • Adding in two extra functions, one to start (basically move most of __init__ into this, needs an extra check to ensure only one connection is active.) and a stop one to make the variable used by listen false.

Better disconnecting handling

  • Define a new exception like OpenRGBDisconnected
  • Make send_header and send_data check if the sever is still active.
  • Wrap every instance of sock.recv_into and sock.send with some exception handling, which will stop the client if it throws one.
  • Then raise the OpenRGBDisconnected exception so the user can catch all these errors.

I'm fine implementing these if you want!

Can't connect to server when Sony Dualshock 4 controller connected

First of all, thanks for your implementation of the openRGB API! It's been really useful to me so far and seems to work flawlessly unless a PS4 controller is plugged in. OpenRGB itself recognises and can control the lights on the controller, but as soon as I initialise an OpenRGBClient object it causes a crash. I've got a couple other RGB devices that have been working perfectly. Here's the traceback:

  File "/home/shawn/Documents/RGB/default.py", line 13, in <module>
    client = OpenRGBClient()
  File "/home/shawn/.local/lib/python3.8/site-packages/openrgb/orgb.py", line 235, in __init__
    self.comms.requestDeviceNum()
  File "/home/shawn/.local/lib/python3.8/site-packages/openrgb/network.py", line 163, in requestDeviceNum
    self.read()
  File "/home/shawn/.local/lib/python3.8/site-packages/openrgb/network.py", line 113, in read
    self.callback(device_id, packet_type, buff[0])
  File "/home/shawn/.local/lib/python3.8/site-packages/openrgb/orgb.py", line 248, in _callback
    self.comms.requestDeviceData(x)
  File "/home/shawn/.local/lib/python3.8/site-packages/openrgb/network.py", line 156, in requestDeviceData
    self.read()
  File "/home/shawn/.local/lib/python3.8/site-packages/openrgb/network.py", line 131, in read
    self.callback(device_id, packet_type, utils.ControllerData.unpack(data, self._protocol_version))
  File "/home/shawn/.local/lib/python3.8/site-packages/openrgb/utils.py", line 448, in unpack
    start, metadata = MetaData.unpack(data, version, start)
  File "/home/shawn/.local/lib/python3.8/site-packages/openrgb/utils.py", line 395, in unpack
    start, val = parse_string(data, start)
  File "/home/shawn/.local/lib/python3.8/site-packages/openrgb/utils.py", line 90, in parse_string
    val = struct.unpack(f"{size}s", data[start:start + size])[0].decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 0: invalid continuation byte

I'm running this on linux using the latest stable build (0.2.5) in python 3.8. I'm not familiar with openRGB's api at all but looking at the traceback it seems to be related to the struct containing device info, so here's the info provided by openRGB itself:

Vendor: Sony
Type: Gamepad
Description: Sony Dualshock 4 Device
Version: 
Location: HID: /dev/hidraw11
Serial: ๏ฟฝ

The serial is the unicode U+FFFD (in case it doesn't show up right), which I assume is causing the issue when openRGB passes along the real value of whatever caused this error.
Thanks again for your work on this project!

Edit: the serial number for the device returned by lsusb is just 0. I'm not sure if that helps.

IndexError on connection

Operating system: Manjaro
Python version: 3.10.2
OpenRGB version: 0.7 (appimage)
python-openrgb: 0.0.5-1

Hi,

While trying to connect to my local OpenRGB server, I get the following error:

$ python test.py 
7 23
Exception in thread Thread-1 (listen):
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.10/site-packages/openrgb/network.py", line 61, in listen
    self.callback(device_id, packet_type, utils.ControllerData.unpack(data))
  File "/usr/lib/python3.10/site-packages/openrgb/utils.py", line 428, in unpack
    start, zones = parse_list(ZoneData, data, start)
  File "/usr/lib/python3.10/site-packages/openrgb/utils.py", line 114, in parse_list
    start, thing = kind.unpack(data, start, x)
  File "/usr/lib/python3.10/site-packages/openrgb/utils.py", line 336, in unpack
    matrix[y][x] = struct.unpack("I", data[start:start + struct.calcsize("I")])
IndexError: list assignment index out of range

My python file contains just the following:

from openrgb import OpenRGBClient

cli = OpenRGBClient('localhost', 6742)

Do you have a clue what could be going on?
Thanks!


p.s. "But those are the defaults" you might say.
I know, I didn't change any settings for the OpenRGB server, but with

from openrgb import OpenRGBClient

cli = OpenRGBClient()

I get

$ python test.py 
Traceback (most recent call last):
  File "/home/christiaan/python_openrgb/test.py", line 3, in <module>
    cli = OpenRGBClient()
  File "/usr/lib/python3.10/site-packages/openrgb/orgb.py", line 197, in __init__
    self.comms = NetworkClient(self._callback, address, port, name)
  File "/usr/lib/python3.10/site-packages/openrgb/network.py", line 23, in __init__
    self.sock.connect((address, port))
ConnectionRefusedError: [Errno 111] Connection refused

openrgb -l
Attempting to connect to local OpenRGB server.
Connected to server
Network client listener started
Client: Received controller count from server: 4
Client: Requesting controller 0
Client: Requesting controller 1
Client: Requesting controller 2
Client: Requesting controller 3
Client: All controllers received, adding them to master list
Local OpenRGB server connected, running in client mode
0: Corsair Vengeance Pro RGB
  Type:           DRAM
  Description:    Corsair Vengeance Pro RGB Device
  Location:       I2C: /dev/i2c-0, address 0x5A
  Modes: [Direct] Static 'Color Shift' 'Color Pulse' 'Rainbow Wave' 'Color Wave' Visor Rain Marquee Rainbow Sequential
  Zones: 'Corsair Pro Zone'
  LEDs: 'Corsair Pro LED 0' 'Corsair Pro LED 1' 'Corsair Pro LED 2' 'Corsair Pro LED 3' 'Corsair Pro LED 4' 'Corsair Pro LED 5' 'Corsair Pro LED 6' 'Corsair Pro LED 7' 'Corsair Pro LED 8' 'Corsair Pro LED 9'

1: Corsair Vengeance Pro RGB
  Type:           DRAM
  Description:    Corsair Vengeance Pro RGB Device
  Location:       I2C: /dev/i2c-0, address 0x5B
  Modes: [Direct] Static 'Color Shift' 'Color Pulse' 'Rainbow Wave' 'Color Wave' Visor Rain Marquee Rainbow Sequential
  Zones: 'Corsair Pro Zone'
  LEDs: 'Corsair Pro LED 0' 'Corsair Pro LED 1' 'Corsair Pro LED 2' 'Corsair Pro LED 3' 'Corsair Pro LED 4' 'Corsair Pro LED 5' 'Corsair Pro LED 6' 'Corsair Pro LED 7' 'Corsair Pro LED 8' 'Corsair Pro LED 9'

2: B550M AORUS ELITE
  Type:           Motherboard
  Description:    IT5702-GIGABYTE V2.0.10.0
  Version:        0x000A0002
  Location:       HID: /dev/hidraw0
  Serial:         0x57020100
  Modes: [Direct] Static Breathing Blinking 'Color Cycle' Flashing
  Zones: 'D_LED1 Bottom' 'D_LED2 Top' Motherboard
  LEDs: 'Name for LED Strip 1 LED 0' 'Name for LED Strip 1 LED 1' 'Name for LED Strip 1 LED 2' 'Name for LED Strip 1 LED 3' 'Name for LED Strip 1 LED 4' 'Name for LED Strip 1 LED 5' 'Name for LED Strip 1 LED 6' 'Name for LED Strip 1 LED 7' 'Name for LED Strip 2 LED 0' 'Name for LED Strip 2 LED 1' 'Name for LED Strip 2 LED 2' 'Name for LED Strip 2 LED 3' 'Name for LED Strip 2 LED 4' 'Name for LED Strip 2 LED 5' 'Name for LED Strip 2 LED 6' 'Name for LED Strip 2 LED 7' 'Name for Led 1' 'Name for Led 2' 'Name for Led 3' 'Name for Led 4' 'Name for Led 5' 'Name for Led 6' 'Name for Led 7' 'Name for Led 8'

3: Corsair K70 RGB MK.2
  Type:           Keyboard
  Description:    Corsair RGB Peripheral Device
  Version:        3.36
  Location:       HID: /dev/hidraw2
  Serial:         1401D017AF1584275961890EF5001BC5
  Modes: [Direct]
  Zones: Keyboard
  LEDs: 'Key: Escape' 'Key: `' 'Key: Tab' 'Key: Caps Lock' 'Key: Left Shift' 'Key: Left Control' 'Key: F12' 'Key: =' 'Key: Lock' 'Key: Number Pad 7' 'Key: F1' 'Key: 1' 'Key: Q' 'Key: A' 'Key: Left Windows' 'Key: Print Screen' 'Key: Media Mute' 'Key: Number Pad 8' 'Key: F2' 'Key: 2' 'Key: W' 'Key: S' 'Key: Z' 'Key: Left Alt' 'Key: Scroll Lock' 'Key: Backspace' 'Key: Media Stop' 'Key: Number Pad 9' 'Key: F3' 'Key: 3' 'Key: E' 'Key: D' 'Key: X' 'Key: Pause/Break' 'Key: Delete' 'Key: Media Previous' 'Key: F4' 'Key: 4' 'Key: R' 'Key: F' 'Key: C' 'Key: Space' 'Key: Insert' 'Key: End' 'Key: Media Play/Pause' 'Key: Number Pad 4' 'Key: F5' 'Key: 5' 'Key: T' 'Key: G' 'Key: V' 'Key: Home' 'Key: Page Down' 'Key: Media Next' 'Key: Number Pad 5' 'Key: F6' 'Key: 6' 'Key: Y' 'Key: H' 'Key: B' 'Key: Page Up' 'Key: Right Shift' 'Key: Num Lock' 'Key: Number Pad 6' 'Key: F7' 'Key: 7' 'Key: U' 'Key: J' 'Key: N' 'Key: Right Alt' 'Key: ]' 'Key: Right Control' 'Key: Number Pad /' 'Key: Number Pad 1' 'Key: F8' 'Key: 8' 'Key: I' 'Key: K' 'Key: M' 'Key: Right Windows' 'Key: \ (ANSI)' 'Key: Up Arrow' 'Key: Number Pad *' 'Key: Number Pad 2' 'Key: F9' 'Key: 9' 'Key: O' 'Key: L' 'Key: ,' 'Key: Menu' 'Key: Left Arrow' 'Key: Number Pad -' 'Key: Number Pad 3' 'Key: F10' 'Key: 0' 'Key: P' 'Key: ;' 'Key: .' 'Key: Enter' 'Key: Down Arrow' 'Key: Number Pad +' 'Key: Number Pad 0' 'Key: F11' 'Key: -' 'Key: [' 'Key: '' 'Key: /' 'Key: Brightness' 'Key: Right Arrow' 'Key: Number Pad Enter' 'Key: Number Pad .' 'Key: / (ISO)' 'Key: \ (ISO)' 'Key: Logo Left' 'Key: Logo Right' 'Key: Profile'

Error when enabling Razer Blade 15 keyboard

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

Getting a socket.timeout everytime on initialization

Pretty self-explanatory,

> from openrgb import OpenRGBClient
> client = OpenRGBClient()

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\x\AppData\Local\Programs\Python\Python38\lib\site-packages\openrgb\orgb.py", line 283, in __init__
    self.comms = NetworkClient(self._callback, address, port, name, protocol_version)
  File "C:\Users\x\AppData\Local\Programs\Python\Python38\lib\site-packages\openrgb\network.py", line 42, in __init__
    self.start_connection()
  File "C:\Users\x\AppData\Local\Programs\Python\Python38\lib\site-packages\openrgb\network.py", line 54, in start_connection
    self.sock.connect((self.address, self.port))
socket.timeout: timed out

Tried this multiple times on multiple sessions, help?

OpenRGBClient hangs on Connection

The code when is exectued on a Raspberry Pi 3 (Python 3.7.3) hangs out in the lock acquire()
The client is connected to the server because it appears on the list of the OpenRGB program...

But when I execute it on another PC with Linux Mint (Python 3.8.5) it works normally... so IDK

Please help! Thx

Traceback (most recent call last):
  File "app.py", line 24, in <module>
    OpenRGB.connect(IP_OPENRGB,PORT_OPENRGB)
  File "/home/pi/Desktop/deploys/leds-twitch/OpenRGB.py", line 9, in connect
    client = OpenRGBClient(ip, port, '')
  File "/home/pi/.local/lib/python3.7/site-packages/openrgb/orgb.py", line 235, in __init__
    self.comms.requestDeviceNum()
  File "/home/pi/.local/lib/python3.7/site-packages/openrgb/network.py", line 163, in requestDeviceNum
    self.read()
  File "/home/pi/.local/lib/python3.7/site-packages/openrgb/network.py", line 113, in read
    self.callback(device_id, packet_type, buff[0])
  File "/home/pi/.local/lib/python3.7/site-packages/openrgb/orgb.py", line 248, in _callback
    self.comms.requestDeviceData(x)
  File "/home/pi/.local/lib/python3.7/site-packages/openrgb/network.py", line 154, in requestDeviceData
    self.send_header(device, utils.PacketType.REQUEST_CONTROLLER_DATA, struct.calcsize('I'))
  File "/home/pi/.local/lib/python3.7/site-packages/openrgb/network.py", line 176, in send_header
    self.lock.acquire()
  File "/home/pi/.local/lib/python3.7/site-packages/engineio/client.py", line 39, in signal_handler
    return original_signal_handler(sig, frame)
  File "/home/pi/.local/lib/python3.7/site-packages/socketio/client.py", line 26, in signal_handler
    return original_signal_handler(sig, frame)

Invalid color or LED turns off

Hi,

I'm using your lib to change the color of my GPU (MSI RTX 3070 Gaming X Trio) in accordance with the temperature of the device every second.

Sometimes, for some reason, either the LED color changes for one that is not in the range I set or completely turns off. This lasts one second (before the next color is set), but of course it is directly catch by my eyes.

I'd like to know if there is any chance the problem is on openrgb-python or if it looks like it is a problem related to openrgb.
I already tried changing the sleep duration (0.5, 1, 2 seconds) or use the 'fast' parameter.

Thank you for your work!

Jonathan

Crash when loading client

Running openrgb in server mode

otto@pc:~$ openrgb -V
OpenRGB 0.6, for controlling RGB lighting.
  Version:		 0.6
  Build Date		 Tue, 15 Jun 2021 20:17:36 +0300
  Git Commit ID		 
  Git Commit Date	 
  Git Branch	

Importing client (installed via pip)

Python 3.9.6 (default, Jun 30 2021, 10:22:16) 
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import openrgb
>>> from openrgb import OpenRGBClient
>>> client = OpenRGBClient()
Traceback (most recent call last):
  File "/home/otto/.local/lib/python3.9/site-packages/openrgb/network.py", line 137, in read
    self.callback(device_id, packet_type, utils.ControllerData.unpack(data, self._protocol_version))
  File "/home/otto/.local/lib/python3.9/site-packages/openrgb/utils.py", line 547, in unpack
    metadata = MetaData.unpack(data, version)
  File "/home/otto/.local/lib/python3.9/site-packages/openrgb/utils.py", line 489, in unpack
    serial = parse_string(data)
  File "/home/otto/.local/lib/python3.9/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 0x80 in position 0: invalid start byte

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

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/otto/.local/lib/python3.9/site-packages/openrgb/orgb.py", line 287, in __init__
    self.comms.requestDeviceNum()
  File "/home/otto/.local/lib/python3.9/site-packages/openrgb/network.py", line 188, in requestDeviceNum
    self.read()
  File "/home/otto/.local/lib/python3.9/site-packages/openrgb/network.py", line 116, in read
    self.callback(device_id, packet_type, buff[0])
  File "/home/otto/.local/lib/python3.9/site-packages/openrgb/orgb.py", line 302, in _callback
    self.comms.requestDeviceData(x)
  File "/home/otto/.local/lib/python3.9/site-packages/openrgb/network.py", line 181, in requestDeviceData
    self.read()
  File "/home/otto/.local/lib/python3.9/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 #3

List of devices

otto@pc:~$ openrgb -l
Attempting to connect to local OpenRGB server.
Connected to server
Network client listener started
Client: Received controller count from server: 6
Client: Requesting controller 0
Client: Requesting controller 1
Client: Requesting controller 2
Client: Requesting controller 3
Client: Requesting controller 4
Client: Requesting controller 5
Client: All controllers received, adding them to master list
Local OpenRGB server connected, running in client mode
0: ASUS Aura DRAM
  Type:           DRAM
  Description:    ASUS Aura SMBus Device
  Version:        DIMM_LED-0103
  Location:       I2C: /dev/i2c-1, address 0x72
  Modes: Direct Off Static Breathing Flashing 'Spectrum Cycle' [Rainbow] 'Chase Fade' Chase 'Random Flicker'
  Zones: Unknown
  LEDs: 'Unknown LED 1' 'Unknown LED 2' 'Unknown LED 3' 'Unknown LED 4' 'Unknown LED 5'

1: ASUS Aura DRAM
  Type:           DRAM
  Description:    ASUS Aura SMBus Device
  Version:        DIMM_LED-0103
  Location:       I2C: /dev/i2c-1, address 0x73
  Modes: Direct Off Static Breathing Flashing 'Spectrum Cycle' [Rainbow] 'Chase Fade' Chase 'Random Flicker'
  Zones: Unknown
  LEDs: 'Unknown LED 1' 'Unknown LED 2' 'Unknown LED 3' 'Unknown LED 4' 'Unknown LED 5'

2: B550 AORUS ELITE
  Type:           Motherboard
  Description:    IT5702-GIGABYTE V2.0.8.0
  Version:        0x00080002
  Location:       HID: /dev/hidraw0
  Serial:         0x57020100
  Modes: [Direct] Static Breathing Blinking 'Color Cycle' Flashing
  Zones: 'D_LED1 Bottom' 'D_LED2 Top' Motherboard
  LEDs: 'Back I/O' 'CPU Header' PCIe 'LED C1/C2'

3: Glorious Model D / D-
  Type:           Mouse
  Description:    Sinowealth Device
  Location:       HID: /dev/hidraw5
  Serial:         ๏ฟฝ//@/b//
  Modes: [Static] Off 'Glorious Mode' 'Seemless Breathing' Tail 'Spectrum Cycle' Rave Epilepsy Wave Breathing
  Zones: Mouse
  LEDs: 'Mouse LED'

4: Glorious Model D / D-
  Type:           Mouse
  Description:    Sinowealth Device
  Location:       HID: /dev/hidraw5
  Serial:         ๏ฟฝ//@/b//
  Modes: [Static] Off 'Glorious Mode' 'Seemless Breathing' Tail 'Spectrum Cycle' Rave Epilepsy Wave Breathing
  Zones: Mouse
  LEDs: 'Mouse LED'

5: Glorious Model D / D-
  Type:           Mouse
  Description:    Sinowealth Device
  Location:       HID: /dev/hidraw5
  Serial:         ๏ฟฝ//@/b//
  Modes: [Static] Off 'Glorious Mode' 'Seemless Breathing' Tail 'Spectrum Cycle' Rave Epilepsy Wave Breathing
  Zones: Mouse
  LEDs: 'Mouse LED'

"3072 is not a valid ModeColors"

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:230
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 3:15:26 PM (3 occurrences)
Last logged: 3:15:34 PM

[547292370240] 3072 is not a valid ModeColors
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 230, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 2035, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 876, in entity_service_call
    response_data = await _handle_entity_call(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 580, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1265, in async_turn_on
    await self.hass.async_add_executor_job(ft.partial(self.turn_on, **kwargs))
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/openrgb/light.py", line 173, in turn_on
    self._set_color()
  File "/config/custom_components/openrgb/light.py", line 334, in _set_color
    self._light.set_color(RGBUtils.RGBColor(*color))
  File "/usr/local/lib/python3.11/site-packages/openrgb/orgb.py", line 190, in set_color
    self.update()
  File "/usr/local/lib/python3.11/site-packages/openrgb/utils.py", line 670, in update
    self.comms.requestDeviceData(self.device_id)
  File "/usr/local/lib/python3.11/site-packages/openrgb/network.py", line 181, in requestDeviceData
    self.read()
  File "/usr/local/lib/python3.11/site-packages/openrgb/network.py", line 137, in read
    self.callback(device_id, packet_type, utils.ControllerData.unpack(data, self._protocol_version))
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/openrgb/utils.py", line 552, in unpack
    mode = ModeData.unpack(data, version, x)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/openrgb/utils.py", line 327, in unpack
    color_mode = ModeColors(parse_var('I', data))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/enum.py", line 712, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/enum.py", line 1135, in __new__
    raise ve_exc
ValueError: 3072 is not a valid ModeColors

Erroring device is:

"fast" is no-op in Device.set_color and Device.set_colors

The fast argument is completely unused in these two methods.

I guess it was simply forgotten to pass it to other methods.

def set_color(self, color: utils.RGBColor, fast: bool = False):
'''
Sets the color of the device whether the current mode is per-led or
mode-specific
:param colors: the list of colors, one per LED
:param fast: If you care more about quickly setting colors than having correct internal state data, then set :code:`fast` to :code:`True` (only applies when not setting a mode-specific color)
'''
active_mode = self.modes[self.active_mode]
if active_mode.color_mode == utils.ModeColors.MODE_SPECIFIC:
self._set_mode_color(color)
elif active_mode.color_mode == utils.ModeColors.PER_LED:
self._set_device_color(color)
def set_colors(self, colors: list[utils.RGBColor], fast: bool = False):
'''
Sets the colors of the device whether the current mode is per-led or
mode-specific
:param colors: the list of colors, one per LED or per mode-specific color
:param fast: If you care more about quickly setting colors than having correct internal state data, then set :code:`fast` to :code:`True` (only applies when not setting a mode-specific color)
'''
active_mode = self.modes[self.active_mode]
if active_mode.color_mode == utils.ModeColors.MODE_SPECIFIC:
self._set_mode_colors(colors)
elif active_mode.color_mode == utils.ModeColors.PER_LED:
self._set_device_colors(colors)

TCP_NODELAY

Hi there. Thanks so much for providing openrgb/openrgb-python. It's fantastic to have such freedom to interact with our hardware without having to rely on the "official" means.
In tinkering on a new Linux environment I noticed that there's a significant limit to the client/server connection when using openrgb-python. I've tracked it down to the TCP_NODELAY not being set on the client socket. I don't have the time (or setup - I'm currently re-building my linux environments) to submit as an actual patch but I'll let you know what I changed locally.
Basically, in the 'start_connection' function in network.py you can set the TCP_NODELAY using :

self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)

This can be done immediately after the 'settimeout' call.
After this change you can get significantly faster updates of the LEDs.
Note that this might cause some people problems if they have written code to rely on the delay for their visual effect - in which case you should add this as an option to the OpenRGBClient() creation or as a separate method to the 'client' object.
Hope this is clear and helps.
Kind regards,
Rich

ValueError when creating an OpenRGBClient object (Windows 10)

Running the example file, I get the following exception:

Traceback (most recent call last):
  File ".\openrgb_test.py", line 4, in <module>
    client = OpenRGBClient()
  File "C:\Users\Cameron\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openrgb\orgb.py", line 234, in __init__
    self.comms.requestDeviceNum()
  File "C:\Users\Cameron\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openrgb\network.py", line 123, in requestDeviceNum
    self.read()
  File "C:\Users\Cameron\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openrgb\network.py", line 94, in read
    self.callback(device_id, packet_type, buff[0])
  File "C:\Users\Cameron\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openrgb\orgb.py", line 247, in _callback
    self.comms.requestDeviceData(x)
  File "C:\Users\Cameron\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openrgb\network.py", line 116, in requestDeviceData
    self.read()
  File "C:\Users\Cameron\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openrgb\network.py", line 105, in read
    self.callback(device_id, packet_type, utils.ControllerData.unpack(data))
  File "C:\Users\Cameron\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openrgb\utils.py", line 443, in unpack
    start, mode = ModeData.unpack(data, start, x)
  File "C:\Users\Cameron\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openrgb\utils.py", line 279, in unpack
    buff[8] = ModeColors(buff[8])
  File "C:\Users\Cameron\AppData\Local\Programs\Python\Python38-32\lib\enum.py", line 309, in __call__
    return cls.__new__(cls, value)
  File "C:\Users\Cameron\AppData\Local\Programs\Python\Python38-32\lib\enum.py", line 600, in __new__
    raise exc
  File "C:\Users\Cameron\AppData\Local\Programs\Python\Python38-32\lib\enum.py", line 584, in __new__
    result = cls._missing_(value)
  File "C:\Users\Cameron\AppData\Local\Programs\Python\Python38-32\lib\enum.py", line 613, in _missing_
    raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 262144 is not a valid ModeColors

I assume this value is getting pulled from the SDK.
I am using version 0.2.3 (pip) and am running Python 3.8.5

Connection drops when doing set color and fast is disabled

I have the following code based on the example

#!/usr/bin/env python3
from openrgb import OpenRGBClient
from openrgb.utils import RGBColor, DeviceType
import time

client = OpenRGBClient()

print(client)

print(client.devices)

keyboard = client.get_devices_by_type(DeviceType.KEYBOARD)[0]
client.clear() # btw example is wrong it should be .clear not .off

while True:
    for x in range(360):
        for led in keyboard.leds:
            led.set_color(RGBColor.fromHSV(x, 100, 100), fast=False)
        # client.set_color(RGBColor.fromHSV(x, 100, 100), fast=False)
        time.sleep(.05)

I get this

OpenRGBClient(address=127.0.0.1, port=6742, name=openrgb-python)
[Device(name=EVision Keyboard, id=0)]
Traceback (most recent call last):
  File "C:\Users\trajano\AppData\Roaming\Python\Python310\site-packages\openrgb\network.py", line 96, in read
    self.sock.recv_into(header)
TimeoutError: timed out

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

Traceback (most recent call last):
  File "C:\Users\trajano\onedrive\Shell Keys\spectrum.py", line 18, in <module>
    led.set_color(RGBColor.fromHSV(x, 100, 100), fast=False)
  File "C:\Users\trajano\AppData\Roaming\Python\Python310\site-packages\openrgb\orgb.py", line 42, in set_color
    self.update()
  File "C:\Users\trajano\AppData\Roaming\Python\Python310\site-packages\openrgb\utils.py", line 664, in update
    self.comms.requestDeviceData(self.device_id)
  File "C:\Users\trajano\AppData\Roaming\Python\Python310\site-packages\openrgb\network.py", line 181, in requestDeviceData
    self.read()
  File "C:\Users\trajano\AppData\Roaming\Python\Python310\site-packages\openrgb\network.py", line 99, in read
    raise utils.OpenRGBDisconnected() from e
openrgb.utils.OpenRGBDisconnected

Execution error occurs when trying ot connect to openRGB server through specific platform

First of all, thank you for writing this module.

I am trying to make Reaper DAW communicate with openRGB through the openrgb-python module using the Reaper IDE in order to bring extra feedback in my studio environment.

I am getting a strange behavior on client = OpenRGBClient() in Reaper IDE in certain conditions and I don't understand where the problem lies. Because it only happens when using the Reaper IDE and an RGB is connected to the openRGB server.

  1. Script execution error doesn't happen when using Jupiter or Python IDE while RGB devices are connected to openRGB.
  2. Script execution error doesn't happen in Reaper IDE when no devices are connected to openRGB.
  3. Same behavior occurs on 2 separate machines with different device types and brandss. (Hyperx Alloy Origins on machine 1 & ASUS x570 Creator motherboard on machine 2)

I have tried using protocol_versions 0, 1, 2, 3 with no luck.

openrgb-python - 0.2.15
openRGB SDK server - 0.7
python version - 3.10.1

One thing I should mention is that when the error occurs, the connection to the openRGB server is done for a split second and then it disappears.

I also tried running the function when the server is offline and got the expected timeout traceback.

Script execution error

Traceback (most recent call last):
File "rRGB.py", line 5, in
client = OpenRGBClient()
File "C:\Users\IVMetalFoundry\AppData\Local\Programs\Python\Python310\lib\site-packages\openrgb\orgb.py", line 337, in init
self.update()
File "C:\Users\IVMetalFoundry\AppData\Local\Programs\Python\Python310\lib\site-packages\openrgb\orgb.py", line 502, in update
self.comms.requestDeviceNum()
File "C:\Users\IVMetalFoundry\AppData\Local\Programs\Python\Python310\lib\site-packages\openrgb\network.py", line 188, in requestDeviceNum
self.read()
File "C:\Users\IVMetalFoundry\AppData\Local\Programs\Python\Python310\lib\site-packages\openrgb\network.py", line 116, in read
self.callback(device_id, packet_type, buff[0])
File "C:\Users\IVMetalFoundry\AppData\Local\Programs\Python\Python310\lib\site-packages\openrgb\orgb.py", line 348, in _callback
self.comms.requestDeviceData(x)
File "C:\Users\IVMetalFoundry\AppData\Local\Programs\Python\Python310\lib\site-packages\openrgb\network.py", line 181, in requestDeviceData
self.read()
File "C:\Users\IVMetalFoundry\AppData\Local\Programs\Python\Python310\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:\Users\IVMetalFoundry\AppData\Local\Programs\Python\Python310\lib\site-packages\openrgb\utils.py", line 547, in unpack
metadata = MetaData.unpack(data, version)
File "C:\Users\IVMetalFoundry\AppData\Local\Programs\Python\Python310\lib\site-packages\openrgb\utils.py", line 492, in unpack
return cls(
TypeError: MetaData() takes no arguments

I haven;t found anymore info regarding this problem other than this traceback.
Thank you!

Cannot change argb single leds

It could be well an OpenRGB problem, however, this tool made me able to change motherboard LEDs which I cannot do succesfully directly from the OpenRGB GUI.

Motherboard: B450 Aorus elite
ARGB header: ARGB Header 1

It is connected to 2 fans through a splitter to a single header, the RGBFusion software was able to detect them and change evert one of the 8 LEDs individually.

I am now able to change the entirety of the fan LEDs without any problem, however I can't figure out any method to individually change them

from openrgb import OpenRGBClient
from openrgb.utils import RGBColor
import time

client = OpenRGBClient()
mobo = client.devices[2]
red = RGBColor(255, 0, 0)

#mobo.leds[7] refers to both the fans attached to the connector
mobo.leds[7].set_color(white)  #"mobo.zones[7].set_color(white)" works as well

I will include something below in case it could be of any help
mobo.zones[7].matrix_map returns [[]]
mobo.zones[7].leds returns [LED(name=ARGB Header 1, id=7)]
mobo.leds returns LED(name=ARGB Header 1, id=7)

Timeout ?

When not using actively the open connexion, the next read/write operation (e.g set_color()) will failed as disconnected, however regularly calling update() will fix the issue.

The Client class may need a kind of keepalive mechanic

openrgb-python and OpenRGB 0.8: not setting all leds

I have a setup where I have a bunch of "devices" (not sure if that's the right OpenRGB term) all plugged into a single hub which is then plugged into an RGB port on my MSI motherboard. These devices have multiple "LEDs" on them and I really just want "all LEDs on all devices the same color". On OpenRGB-0.7 the following does what I want:

for device in openrgb.ee_devices:
    rgb_color = RGBColor(randint(0, 255), randint(0, 255), randint(0, 255))
    device.set_mode("direct")
    device.set_color(rgb_color)

When I upgrade to OpenRGB-0.8 however it seems that only 2 LEDs on each device gets set to the color and the other LEDs are off. Oddly it seems to be 2, not 1 which confuses me but perhaps they're somehow "mirrored". I've tried set_colors([rgb_color] * len(device.leds) but the result is the same.

From what I can tell (not much since I'm fairly new to the ARGB game), one of the following is occurring, ordered by likeliness.

  • The above code is incorrect for what I want but just so happens to work with OpenRGB-0.7
  • Something changed in OpenRGB-0.8 and openrgb-python does not yet work with this change
  • There is a regression bug in OpenRGB-0.8
  • There is something wrong with the hardware

As I said likely there is something I'm doing wrong in the code, but if that's the case I'm not sure what it is (or why it worked before).

openrgb-python-0.2.15 on Linux.

Thanks.

Cannot load local profiles

LocalProfile.unpack is returning None which makes the loading of a local profile fail. Loading the exact same profile from the server works fine.

Here's the terminal output of the error:

Traceback (most recent call last):
  File "/home/vitor/.local/bin/load-rgb-profile", line 6, in <module>
    client.load_profile('default', True)
  File "/home/vitor/.local/lib/python3.9/site-packages/openrgb/orgb.py", line 339, in load_profile
    controllers = utils.LocalProfile.unpack(f).controllers
AttributeError: 'NoneType' object has no attribute 'controllers'

The profile was created in the OpenRGB GUI, I've attached it below:
default.zip

A quick look at the unpack code suggests it does not support the file version.

Can't connect when Corsair K95 RGB Platinum is enabled

I'm using this to test connection:

from openrgb import OpenRGBClient

cli = OpenRGBClient('192.168.100.1', 6742, 'Client')

This works fine most of the time, and interacting with the client works too.
However when I connect my Corsair K95 RGB Platinum keyboard I get the following error:

Traceback (most recent call last):
  File "/home/diademiemi/Downloads/test.py", line 7, in <module>
    cli = OpenRGBClient('192.168.100.1', 6742, 'Client')
  File "/home/diademiemi/.local/lib/python3.10/site-packages/openrgb/orgb.py", line 337, in __init__
    self.update()
  File "/home/diademiemi/.local/lib/python3.10/site-packages/openrgb/orgb.py", line 502, in update
    self.comms.requestDeviceNum()
  File "/home/diademiemi/.local/lib/python3.10/site-packages/openrgb/network.py", line 188, in requestDeviceNum
    self.read()
  File "/home/diademiemi/.local/lib/python3.10/site-packages/openrgb/network.py", line 116, in read
    self.callback(device_id, packet_type, buff[0])
  File "/home/diademiemi/.local/lib/python3.10/site-packages/openrgb/orgb.py", line 348, in _callback
    self.comms.requestDeviceData(x)
  File "/home/diademiemi/.local/lib/python3.10/site-packages/openrgb/network.py", line 181, in requestDeviceData
    self.read()
  File "/home/diademiemi/.local/lib/python3.10/site-packages/openrgb/network.py", line 137, in read
    self.callback(device_id, packet_type, utils.ControllerData.unpack(data, self._protocol_version))
  File "/home/diademiemi/.local/lib/python3.10/site-packages/openrgb/utils.py", line 557, in unpack
    leds = parse_list(LEDData, data, version)
  File "/home/diademiemi/.local/lib/python3.10/site-packages/openrgb/utils.py", line 143, in parse_list
    things.append(kind.unpack(data, version, x))  # type: ignore
  File "/home/diademiemi/.local/lib/python3.10/site-packages/openrgb/utils.py", line 223, in unpack
    name = parse_string(data)
  File "/home/diademiemi/.local/lib/python3.10/site-packages/openrgb/utils.py", line 118, in parse_string
    return parse_var(f'{length}s', data).decode().rstrip('\x00')
  File "/home/diademiemi/.local/lib/python3.10/site-packages/openrgb/utils.py", line 103, in parse_var
    d.append(int(next(data)))
StopIteration

When I disable the keyboard in the OpenRGB config, the script starts working again. But once I enable it and reload devices, the script stops working.
Does anyone know of a solution to this or is this a known bug? This is also affecting https://github.com/koying/openrgb_ha and makes Home Assistant error on connecting.

Detect if Client Connected or Not

Is there any mechanism to determine if the client actually connects to the OpenRGB Server? The only way to have this start on log-in automatically (that I can find) is to have OpenRGB and my python script be triggered by the Windows start-up process. But if Windows starts the python script before OpenRGB the python script will never connect.

TypeError: set_colors() got multiple values for argument 'fast'

Not sure what I am doing wrong. If possible check and try:
https://github.com/subterfugium/rgb

Issue happens at

        for device in client.ee_devices:
            led_count = int(len(device.colors))
            for i in range(led_count):
                device.colors[i] = RGBColor.fromHSV(hue, sat, lig)
        for device in client.ee_devices:
            device.show()

and

    def show(self, fast: bool = False, force: bool = False):
        '''
        Applies changes in the color attribute

        :param fast: Whether or not update the device on each call
        :param force: If True, the function will update every led, regardless of previous state.
        '''
        if len(self.colors) > len(self._colors):
            raise ValueError(f"`self.colors` is longer than expected length `{len(self._colors)}`")
        elif len(self.colors) < len(self._colors):
            raise ValueError(f"`self.colors` is shorter than expected length `{len(self._colors)}`")
        changed = [(i, color) for i, color in enumerate(self.colors) if color != self._colors[i]]
        if force:
            self.set_colors(self.colors, fast=True)
        elif len(changed) == 0:
            return
        elif len(changed) == 1:
            self.leds[changed[0][0]].set_color(changed[0][1], fast=True)
        elif len(changed) > 1:
            start, end = changed[0][0], changed[-1][0] + 1
            colors = self.colors[start:end]
            print(colors)
[RGBColor(red=255, green=255, blue=255), RGBColor(red=255, green=255, blue=255), RGBColor(red=255, green=255, blue=255), RGBColor(red=255, green=255, blue=255)]
            print(start)
0
            print(end)
4
            self.set_colors(colors, start, end, fast=True)
        self._colors = self.colors[:]
        if not fast:
            self.update()

Using latest version

user@pc:$ pip install openrgb-python==0.2.12
Defaulting to user installation because normal site-packages is not writeable
Collecting openrgb-python==0.2.12
  Using cached openrgb_python-0.2.12-py3-none-any.whl (26 kB)
Installing collected packages: openrgb-python
  Attempting uninstall: openrgb-python
    Found existing installation: openrgb-python 0.2.10
    Uninstalling openrgb-python-0.2.10:
      Successfully uninstalled openrgb-python-0.2.10
Successfully installed openrgb-python-0.2.12
user@pc:$ rgb white blue hue
Colors: white, blue

Device ASUS Aura DRAM has 8 leds
- Zone Unknown has 8 leds
Device ASUS Aura DRAM has 8 leds
- Zone Unknown has 8 leds
Device B550 AORUS ELITE has 22 leds
- Zone D_LED1 Bottom has 9 leds
- Zone D_LED2 Top has 9 leds
- Zone Motherboard has 4 leds
Device Logitech G915TKL Wireless RGB Mechanical Gaming Keyboard (Wired) has 95 leds
- Zone Keyboard has 95 leds
Sweep leds hue between ['white', 'blue'] for 60 seconds...
Traceback (most recent call last):
  File "/usr/local/bin/rgb", line 368, in <module>
    device.show()
  File "/home/otto/.local/lib/python3.9/site-packages/openrgb/utils.py", line 702, in show
    self.set_colors(colors, start, end, fast=True)
TypeError: set_colors() got multiple values for argument 'fast'

Issue does not happen with 0.2.10

user@pc:$ pip install openrgb-python==0.2.10
Defaulting to user installation because normal site-packages is not writeable
Collecting openrgb-python==0.2.10
  Using cached openrgb_python-0.2.10-py3-none-any.whl (26 kB)
Installing collected packages: openrgb-python
  Attempting uninstall: openrgb-python
    Found existing installation: openrgb-python 0.2.12
    Uninstalling openrgb-python-0.2.12:
      Successfully uninstalled openrgb-python-0.2.12
Successfully installed openrgb-python-0.2.10
user@pc:$ rgb white blue hue
Colors: white, blue

Device ASUS Aura DRAM has 8 leds
- Zone Unknown has 8 leds
Device ASUS Aura DRAM has 8 leds
- Zone Unknown has 8 leds
Device B550 AORUS ELITE has 22 leds
- Zone D_LED1 Bottom has 9 leds
- Zone D_LED2 Top has 9 leds
- Zone Motherboard has 4 leds
Device Logitech G915TKL Wireless RGB Mechanical Gaming Keyboard (Wired) has 95 leds
- Zone Keyboard has 95 leds
Sweep leds hue between ['white', 'blue'] for 60 seconds...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.