Skip to content

GL25B #105

Description

@4noxx

Maybe this can help you. After a few days, I can now control the GL25B:

sudo python3 lampe.py brightness 75
sudo python3 lampe.py temp 4400
sudo python3 lampe.py temp 2900
sudo python3 lampe.py temp 7000

import hid
import sys

VID = 0x0581
PID = 0x011d

def send_command(cmd_bytes):
    """Open HID device, send command and close"""
    device = hid.device()
    device.open(VID, PID)
    device.write(cmd_bytes)
    device.close()

def set_brightness(brightness):
    """Set brightness between 0-100%"""
    brightness = max(0, min(100, int(brightness)))
    # Build HID command with brightness value
    cmd = bytes.fromhex(
        f"ba70240000000077580182{brightness:02x}8c"
        + "00" * 32
    )
    send_command(cmd)
    print(f"✅ Brightness: {brightness}%")

def set_color_temp(kelvin):
    """Set color temperature between 2900K-7000K"""
    kelvin = max(2900, min(7000, int(kelvin)))
    # Convert kelvin to device value (e.g. 4400K → 44)
    val = kelvin // 100
    # Build HID command with color temperature value
    cmd = bytes.fromhex(
        f"ba70240000000077580183{val:02x}8c"
        + "00" * 32
    )
    send_command(cmd)
    print(f"✅ Color temperature: {kelvin}K (value: 0x{val:02x})")

def print_usage():
    """Print usage instructions"""
    print("Usage:")
    print("  sudo python3 lampe.py brightness <0-100>")
    print("  sudo python3 lampe.py temp <2900-7000>")
    print("")
    print("Examples:")
    print("  sudo python3 lampe.py brightness 75")
    print("  sudo python3 lampe.py temp 4400")

if __name__ == "__main__":
    # Check if enough arguments were provided
    if len(sys.argv) < 3:
        print_usage()
        sys.exit(1)

    cmd = sys.argv[1]
    val = int(sys.argv[2])

    try:
        if cmd == "brightness":
            set_brightness(val)
        elif cmd == "temp":
            set_color_temp(val)
        else:
            print(f"❌ Unknown command: {cmd}")
            print_usage()
            sys.exit(1)
    except Exception as e:
        print(f"❌ Error: {e}")
        sys.exit(1)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions