Skip to content

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

Open
wants to merge 9 commits into
base: release/2.0-dev
Choose a base branch
from

Conversation

robberwick
Copy link
Collaborator

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 a cached_property _config to get the hardware configuration of the connected device, and updated set_mode and get_mode methods to raise UnsupportedOperation 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 new Configuration class to represent the configuration of a BlinkStick variant, including whether mode changes are supported.

Exception Handling:

Testing Enhancements:

  • tests/clients/test_blinkstick.py: Added tests to verify that set_mode and get_mode methods raise UnsupportedOperation for unsupported variants and to ensure all methods require a backend. [1] [2]

@robberwick robberwick requested a review from Copilot February 16, 2025 11:31
Copy link

@Copilot Copilot AI left a 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

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,
),
}
Copy link
Collaborator Author

@robberwick robberwick Feb 16, 2025

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.

@robberwick robberwick requested a review from arvydas February 16, 2025 11:50
@robberwick robberwick force-pushed the release/bs-pro-set-mode branch 2 times, most recently from ef91b46 to cf6a88e Compare February 23, 2025 09:15
@robberwick robberwick force-pushed the release/bs-pro-set-mode branch from cf6a88e to 9b42a2b Compare February 23, 2025 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant