-
Notifications
You must be signed in to change notification settings - Fork 53
Restrict set_mode/get_mode to supported variants only #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/2.0-dev
Are you sure you want to change the base?
Restrict set_mode/get_mode to supported variants only #121
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Files not reviewed (1)
- src/blinkstick/clients/blinkstick.py: Evaluated as low risk
from blinkstick.enums import BlinkStickVariant | ||
from blinkstick.models import Configuration | ||
|
||
_VARIANT_CONFIGS: dict[BlinkStickVariant, Configuration] = { | ||
BlinkStickVariant.BLINKSTICK: Configuration( | ||
mode_change_support=False, | ||
), | ||
BlinkStickVariant.BLINKSTICK_PRO: Configuration( | ||
mode_change_support=True, | ||
), | ||
BlinkStickVariant.BLINKSTICK_NANO: Configuration( | ||
mode_change_support=True, | ||
), | ||
BlinkStickVariant.BLINKSTICK_SQUARE: Configuration( | ||
mode_change_support=True, | ||
), | ||
BlinkStickVariant.BLINKSTICK_STRIP: Configuration( | ||
mode_change_support=True, | ||
), | ||
BlinkStickVariant.BLINKSTICK_FLEX: Configuration( | ||
mode_change_support=True, | ||
), | ||
BlinkStickVariant.UNKNOWN: Configuration( | ||
mode_change_support=False, | ||
), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arvydas Is this correct? It wasn't clear to me if the non-pro multi addressable LED models (e.g. square, strip etc.) also supported mode change.. I figure they can't do mode 0 for a single RGB LED, but I wasn't clear on whether mode 1 (inverse mode) was supported in addressable mode, or what modes were available for variants that were not BS/BSPro.
ef91b46
to
cf6a88e
Compare
…rtedOperation in mode change methods
cf6a88e
to
9b42a2b
Compare
This pull request introduces several changes to enhance the BlinkStick client by adding support for hardware configuration and handling unsupported operations. The most important changes include adding a new
Configuration
class, updating methods to check for mode change support, and adding corresponding tests.Enhancements to BlinkStick Client:
src/blinkstick/clients/blinkstick.py
: Introduced acached_property
_config
to get the hardware configuration of the connected device, and updatedset_mode
andget_mode
methods to raiseUnsupportedOperation
if mode changes are not supported. [1] [2] [3] [4]New Configuration Handling:
src/blinkstick/configs.py
: Added_get_device_config
function to retrieve the configuration for a BlinkStick variant and defined_VARIANT_CONFIGS
dictionary to store configurations for different variants.src/blinkstick/models.py
: Added a newConfiguration
class to represent the configuration of a BlinkStick variant, including whether mode changes are supported.Exception Handling:
src/blinkstick/exceptions.py
: Added a newUnsupportedOperation
exception class to handle unsupported operations.Testing Enhancements:
tests/clients/test_blinkstick.py
: Added tests to verify thatset_mode
andget_mode
methods raiseUnsupportedOperation
for unsupported variants and to ensure all methods require a backend. [1] [2]