Restrict set_mode/get_mode to supported variants only#121
Open
robberwick wants to merge 9 commits intoarvydas:release/2.0-devfrom
Open
Restrict set_mode/get_mode to supported variants only#121robberwick wants to merge 9 commits intoarvydas:release/2.0-devfrom
robberwick wants to merge 9 commits intoarvydas:release/2.0-devfrom
Conversation
robberwick
commented
Feb 16, 2025
Comment on lines
+1
to
+26
| 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, | ||
| ), | ||
| } |
Collaborator
Author
There was a problem hiding this comment.
@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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Configurationclass, updating methods to check for mode change support, and adding corresponding tests.Enhancements to BlinkStick Client:
src/blinkstick/clients/blinkstick.py: Introduced acached_property_configto get the hardware configuration of the connected device, and updatedset_modeandget_modemethods to raiseUnsupportedOperationif mode changes are not supported. [1] [2] [3] [4]New Configuration Handling:
src/blinkstick/configs.py: Added_get_device_configfunction to retrieve the configuration for a BlinkStick variant and defined_VARIANT_CONFIGSdictionary to store configurations for different variants.src/blinkstick/models.py: Added a newConfigurationclass to represent the configuration of a BlinkStick variant, including whether mode changes are supported.Exception Handling:
src/blinkstick/exceptions.py: Added a newUnsupportedOperationexception class to handle unsupported operations.Testing Enhancements:
tests/clients/test_blinkstick.py: Added tests to verify thatset_modeandget_modemethods raiseUnsupportedOperationfor unsupported variants and to ensure all methods require a backend. [1] [2]