API¶
Module contents¶
- class openrgb.OpenRGBClient(address='127.0.0.1', port=6742, name='openrgb-python', protocol_version=None)[source]¶
Bases:
openrgb.utils.RGBObject
This is the only class you should need to manually instantiate. It initializes the communication, gets the device information, and creates Devices, Zones, and LEDs for you.
- Parameters
address (
str
) – the ip address of the SDK serverport (
int
) – the port of the SDK servername (
str
) – the string that will be displayed on the OpenRGB SDK tab’s list of clientsprotocol_version (
Optional
[int
]) – which protocol version to use
- clear()¶
Turns all of the LEDS off
- delete_profile(name)[source]¶
Deletes the selected profile
- Parameters
name (
Union
[str
,int
,Profile
]) – Can be a profile’s name, index, or even the Profile itself
- property ee_devices¶
A subset of the device list that only includes devices with a direct control mode. These devices are suitable to use with an effects engine.
- get_devices_by_name(name, exact=True)[source]¶
Gets a list of any devices matching the requested name
- Parameters
name – the name of the device(s) you want to get
exact – whether to check for only a precise match or accpet a device that contains name
- get_devices_by_type(type)[source]¶
Gets a list of devices that are the same type as requested
- Parameters
type – what type of device you want to get
- load_profile(name, local=False, directory='')[source]¶
Loads an OpenRGB profile
- Parameters
name (
Union
[str
,int
,Profile
]) – Can be a profile’s name, index, or even the Profile itselflocal (
bool
) – Whether to load a local file or a profile from the server.directory (
str
) – what directory the profile is in. Defaults to OpenRGB’s config directory for supported OS’s (Windows or Linux), or falls back to using the current working directory.
- property protocol_version¶
The protocol version of the connected SDK server
- save_profile(name, local=False, directory='')[source]¶
Saves the current state of all of your devices to a new or existing OpenRGB profile
- Parameters
name (
Union
[str
,int
,Profile
]) – Can be a profile’s name, index, or even the Profile itselflocal (
bool
) – Whether to load a local file or a profile on the server.directory (
str
) – what directory to save the profile in. Defaults to OpenRGB’s config directory for supported OS’s (Windows or Linux), or falls back to using the current working directory.
- set_color(color, fast=False)[source]¶
Sets the color of every device.
- Parameters
color (
RGBColor
) – the color to set the devices tofast (
bool
) – If you care more about quickly setting colors than having correct internal state data, then setfast
toTrue
- show(fast=False, force=False)[source]¶
Shows all devices
- Parameters
fast (
bool
) – If you care more about quickly setting colors than having correct internal state data, then setfast
toTrue
force (
bool
) – Sets all colors rather than trying to only set the ones that have been changed
Submodules¶
openrgb.network module¶
- class openrgb.network.NetworkClient(update_callback, address='127.0.0.1', port=6742, name='openrgb-python', protocol_version=None)[source]¶
Bases:
object
A class for interfacing with the OpenRGB SDK
- Parameters
update_callback (
Callable
) – the function to call when data is receivedaddress (
str
) – the ip address of the SDK serverport (
int
) – the port of the SDK servername (
str
) – the string that will be displayed on the OpenRGB SDK tab’s list of clients
- check_version(packet_type)[source]¶
Verifies that the packet type is supported on the version we are using.
- Parameters
packet_type (
PacketType
) – What kind of packet is going to be sent- Raises
utils.SDKVersionError – When a packet is unsupported
- property connected: bool¶
Returns whether the current instance is currently connected to a server
- Return type
bool
- read()[source]¶
Reads responses from the SDK
- Raises
utils.OpenRGBDisconnected – when it loses connection to the SDK
- requestDeviceData(device)[source]¶
Sends the request for a device’s data
- Parameters
device (
int
) – the id of the device to request data for
- send_data(data, release_lock=True)[source]¶
Sends data to the SDK
- Parameters
data (
bytes
) – The data to send
- send_header(device_id, packet_type, packet_size)[source]¶
Sends a header to the SDK
- Parameters
device_id (
int
) – The id of the device to send a header forpacket_type (
PacketType
) – A utils.PacketTypepacket_size (
int
) – The full size of the data to be sent after the header
openrgb.orgb module¶
- class openrgb.orgb.Device(data, device_id, network_client)[source]¶
Bases:
openrgb.utils.RGBContainer
A class to represent an RGB Device
- off()[source]¶
Turns off device by setting the custom mode and then calling
RGBObject.clear
- set_color(color, fast=False)[source]¶
Sets the color of the device whether the current mode is per-led or mode-specific
- Parameters
colors – the list of colors, one per LED
fast (
bool
) – If you care more about quickly setting colors than having correct internal state data, then setfast
toTrue
(only applies when not setting a mode-specific color)
- set_colors(colors, fast=False)[source]¶
Sets the colors of the device whether the current mode is per-led or mode-specific
- Parameters
colors – the list of colors, one per LED or per mode-specific color
fast – If you care more about quickly setting colors than having correct internal state data, then set
fast
toTrue
(only applies when not setting a mode-specific color)
- class openrgb.orgb.LED(data, color, led_id, device_id, network_client)[source]¶
Bases:
openrgb.utils.RGBObject
A class to represent individual LEDs
- class openrgb.orgb.OpenRGBClient(address='127.0.0.1', port=6742, name='openrgb-python', protocol_version=None)[source]¶
Bases:
openrgb.utils.RGBObject
This is the only class you should need to manually instantiate. It initializes the communication, gets the device information, and creates Devices, Zones, and LEDs for you.
- Parameters
address (
str
) – the ip address of the SDK serverport (
int
) – the port of the SDK servername (
str
) – the string that will be displayed on the OpenRGB SDK tab’s list of clientsprotocol_version (
Optional
[int
]) – which protocol version to use
- delete_profile(name)[source]¶
Deletes the selected profile
- Parameters
name (
Union
[str
,int
,Profile
]) – Can be a profile’s name, index, or even the Profile itself
- property ee_devices¶
A subset of the device list that only includes devices with a direct control mode. These devices are suitable to use with an effects engine.
- get_devices_by_name(name, exact=True)[source]¶
Gets a list of any devices matching the requested name
- Parameters
name – the name of the device(s) you want to get
exact – whether to check for only a precise match or accpet a device that contains name
- get_devices_by_type(type)[source]¶
Gets a list of devices that are the same type as requested
- Parameters
type – what type of device you want to get
- load_profile(name, local=False, directory='')[source]¶
Loads an OpenRGB profile
- Parameters
name (
Union
[str
,int
,Profile
]) – Can be a profile’s name, index, or even the Profile itselflocal (
bool
) – Whether to load a local file or a profile from the server.directory (
str
) – what directory the profile is in. Defaults to OpenRGB’s config directory for supported OS’s (Windows or Linux), or falls back to using the current working directory.
- property protocol_version¶
The protocol version of the connected SDK server
- save_profile(name, local=False, directory='')[source]¶
Saves the current state of all of your devices to a new or existing OpenRGB profile
- Parameters
name (
Union
[str
,int
,Profile
]) – Can be a profile’s name, index, or even the Profile itselflocal (
bool
) – Whether to load a local file or a profile on the server.directory (
str
) – what directory to save the profile in. Defaults to OpenRGB’s config directory for supported OS’s (Windows or Linux), or falls back to using the current working directory.
- set_color(color, fast=False)[source]¶
Sets the color of every device.
- Parameters
color (
RGBColor
) – the color to set the devices tofast (
bool
) – If you care more about quickly setting colors than having correct internal state data, then setfast
toTrue
- show(fast=False, force=False)[source]¶
Shows all devices
- Parameters
fast (
bool
) – If you care more about quickly setting colors than having correct internal state data, then setfast
toTrue
force (
bool
) – Sets all colors rather than trying to only set the ones that have been changed
- class openrgb.orgb.Zone(data, zone_id, device_id, network_client)[source]¶
Bases:
openrgb.utils.RGBContainer
A class to represent a zone
- resize(size)[source]¶
Resizes the zone. Required to control addressable leds in Direct mode.
- Parameters
size (
int
) – the number of leds in the zone
openrgb.utils module¶
- class openrgb.utils.ControllerData(name, metadata, device_type, leds, zones, modes, colors, active_mode)[source]¶
Bases:
object
- active_mode: int¶
- device_type: DeviceType¶
- name: str¶
- pack(version)[source]¶
Packs itself into a bytes ready to be sent to the SDK or saved in a profile
- Return type
bytes
- Returns
raw data ready to be sent or saved
- classmethod unpack(raw_data, version, start=0)[source]¶
Unpacks the raw bytes received from the SDK into a ControllerData dataclass
- Parameters
data – The raw data from a response to a request for device data
- Return type
- Returns
A ControllerData dataclass ready to pass into the OpenRGBClient’s calback function
- class openrgb.utils.DeviceType(value)[source]¶
Bases:
enum.IntEnum
An enumeration.
- COOLER = 3¶
- DRAM = 1¶
- GAMEPAD = 10¶
- GPU = 2¶
- HEADSET = 8¶
- HEADSET_STAND = 9¶
- KEYBOARD = 5¶
- LEDSTRIP = 4¶
- LIGHT = 11¶
- MOTHERBOARD = 0¶
- MOUSE = 6¶
- MOUSEMAT = 7¶
- SPEAKER = 12¶
- UNKNOWN = 14¶
- VIRTUAL = 13¶
- class openrgb.utils.LEDData(name, value)[source]¶
Bases:
object
- name: str¶
- pack(version)[source]¶
Packs itself into a bytes ready to be sent to the SDK or saved in a profile
- Return type
bytes
- Returns
raw data ready to be sent or saved
- classmethod unpack(data, version, *args)[source]¶
Creates a new LEDData object from raw bytes
- Parameters
data (
Iterator
[int
]) – the raw bytes from the SDKstart – what place in the data object to start
- Return type
- value: int¶
- class openrgb.utils.LocalProfile(controllers)[source]¶
Bases:
object
A dataclass to load, store, and pack the data found in an OpenRGB profile file.
- controllers: list[ControllerData]¶
- class openrgb.utils.MetaData(vendor, description, version, serial, location)[source]¶
Bases:
object
- description: str¶
- location: str¶
- pack(version)[source]¶
Packs itself into a bytes ready to be sent to the SDK or saved in a profile
- Return type
bytes
- Returns
raw data ready to be sent or saved
- serial: str¶
- classmethod unpack(data, version, *args)[source]¶
Unpacks the raw data into a MetaData object
- Parameters
data (
Iterator
[int
]) – The raw byte data to unpackstart – What place in the data object to start
- Return type
- vendor: Optional[str]¶
- version: str¶
- class openrgb.utils.ModeColors(value)[source]¶
Bases:
enum.IntEnum
An enumeration.
- MODE_SPECIFIC = 2¶
- NONE = 0¶
- PER_LED = 1¶
- RANDOM = 3¶
- class openrgb.utils.ModeData(id, name, value, flags, speed_min, speed_max, brightness_min, brightness_max, colors_min, colors_max, speed, brightness, direction, color_mode, colors)[source]¶
Bases:
object
- brightness: Optional[int]¶
- brightness_max: Optional[int]¶
- brightness_min: Optional[int]¶
- color_mode: ModeColors¶
- colors_max: Optional[int]¶
- colors_min: Optional[int]¶
- direction: Optional[ModeDirections]¶
- id: int¶
- name: str¶
- pack(version)[source]¶
Packs itself into a bytes ready to be sent to the SDK or saved in a profile
- Return type
bytes
- Returns
raw data ready to be sent or saved
- speed: Optional[int]¶
- speed_max: Optional[int]¶
- speed_min: Optional[int]¶
- classmethod unpack(data, version, index=0)[source]¶
Creates a new ModeData object from raw bytes
- Parameters
data (
Iterator
[int
]) – the raw bytes from the SDKstart – what place in the data object to start
index (
int
) – which mode this is
- Return type
- validate(version)[source]¶
Tests the values of the mode data and raises a ValueError if the validation fails
- value: int¶
- class openrgb.utils.ModeDirections(value)[source]¶
Bases:
enum.IntEnum
An enumeration.
- DOWN = 3¶
- HORIZONTAL = 4¶
- LEFT = 0¶
- RIGHT = 1¶
- UP = 2¶
- VERTICAL = 5¶
- class openrgb.utils.ModeFlags(value)[source]¶
Bases:
enum.IntFlag
An enumeration.
- HAS_BRIGHTNESS = 16¶
- HAS_DIRECTION_HV = 8¶
- HAS_DIRECTION_LR = 2¶
- HAS_DIRECTION_UD = 4¶
- HAS_MODE_SPECIFIC_COLOR = 64¶
- HAS_PER_LED_COLOR = 32¶
- HAS_RANDOM_COLOR = 128¶
- HAS_SPEED = 1¶
- class openrgb.utils.PacketType(value)[source]¶
Bases:
enum.IntEnum
An enumeration.
- DEVICE_LIST_UPDATED = 100¶
- REQUEST_CONTROLLER_COUNT = 0¶
- REQUEST_CONTROLLER_DATA = 1¶
- REQUEST_DELETE_PROFILE = 153¶
- REQUEST_LOAD_PROFILE = 152¶
- REQUEST_PROFILE_LIST = 150¶
- REQUEST_PROTOCOL_VERSION = 40¶
- REQUEST_SAVE_PROFILE = 151¶
- RGBCONTROLLER_RESIZEZONE = 1000¶
- RGBCONTROLLER_SAVEMODE = 1102¶
- RGBCONTROLLER_SETCUSTOMMODE = 1100¶
- RGBCONTROLLER_UPDATELEDS = 1050¶
- RGBCONTROLLER_UPDATEMODE = 1101¶
- RGBCONTROLLER_UPDATESINGLELED = 1052¶
- RGBCONTROLLER_UPDATEZONELEDS = 1051¶
- SET_CLIENT_NAME = 50¶
- class openrgb.utils.Profile(name)[source]¶
Bases:
object
A simple dataclass to parse profiles from the server.
- name: str¶
- class openrgb.utils.RGBColor(red, green, blue)[source]¶
Bases:
object
- blue: int¶
- classmethod fromHSV(hue, saturation, value)[source]¶
Creates a RGBColor object from HSV values using colorsys
- Return type
- green: int¶
- pack(version=0)[source]¶
Packs itself into a bytes ready to be sent to the SDK or saved in a profile
- Return type
bytes
- Returns
raw data ready to be sent or saved
- red: int¶
- class openrgb.utils.RGBContainer[source]¶
Bases:
openrgb.utils.RGBObject
A parent class for RGBObjects that can control more than one LED like the
Device
class or theZone
class.
- class openrgb.utils.RGBObject[source]¶
Bases:
object
A parent class that includes a few generic functions that use the implementation provided by the children.
- class openrgb.utils.ZoneData(name, zone_type, leds_min, leds_max, num_leds, mat_height, mat_width, matrix_map=None, leds=<factory>, colors=<factory>, start_idx=0)[source]¶
Bases:
object
- leds_max: int¶
- leds_min: int¶
- mat_height: Optional[int]¶
- mat_width: Optional[int]¶
- matrix_map: Optional[list[list[Optional[int]]]] = None¶
- name: str¶
- num_leds: int¶
- pack(version)[source]¶
Packs itself into a bytes ready to be sent to the SDK or saved in a profile
- Return type
bytes
- Returns
raw data ready to be sent or saved
- start_idx: int = 0¶
- class openrgb.utils.ZoneType(value)[source]¶
Bases:
enum.IntEnum
An enumeration.
- LINEAR = 1¶
- MATRIX = 2¶
- SINGLE = 0¶
- openrgb.utils.pack_list(things, version)[source]¶
Packs a list of things using the things’ .pack() methods
- Parameters
things (
list
) – a list of things to pack- Return type
bytes
- Returns
bytes ready to be used
- openrgb.utils.pack_string(string)[source]¶
Packs a string into bytes
- Parameters
string (
str
) – the string to pack- Return type
bytes
- Returns
bytes ready to be used
- openrgb.utils.parse_list(kind, data, version)[source]¶
Parses a list of objects and returns them
- Parameters
kind (
object
) – the class that the list consists ofdata (
Iterator
[int
]) – the raw data to parsestart – the location in the data to start parsing
- Return type
list