From 63b874f6880e2e694a02cd7545b530057255957e Mon Sep 17 00:00:00 2001 From: JnyJny Date: Tue, 26 Nov 2024 15:48:01 -0600 Subject: [PATCH] Fix for #417 I added a check to the method `busylight.lights.light.Light.update` that prepends a zero byte to the bytes object that will be sent to a device if the current platform is Windows. This is necessary because the Windows HID API requires a report ID to be sent with the data and the underlying hidapi library doesn't seem to handle this for us on Windows but does handle it on Linux and macOS. --- busylight/lights/light.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/busylight/lights/light.py b/busylight/lights/light.py index 1f1c5f6..6c320e8 100644 --- a/busylight/lights/light.py +++ b/busylight/lights/light.py @@ -12,22 +12,12 @@ """ - import abc import asyncio - +import platform from contextlib import contextmanager from functools import lru_cache -from typing import ( - Any, - Callable, - Generator, - Dict, - List, - Tuple, - Type, - Union, -) +from typing import Any, Callable, Dict, Generator, List, Tuple, Type, Union from loguru import logger @@ -37,7 +27,6 @@ LightUnsupported, NoLightsFound, ) - from .taskable import TaskableMixin LightType = Type["Light"] @@ -549,7 +538,10 @@ def update(self) -> None: - LightUnavailable """ - data = bytes(self) + if platform.system() == "Windows": + data = bytes([0x00]) + bytes(self) + else: + data = bytes(self) with self.exclusive_access(): try: