33import sys
44import time
55import warnings
6+ from functools import cached_property
67from typing import Callable
78
89from blinkstick .colors import (
1213 remap_rgb_value_reverse ,
1314 ColorFormat ,
1415)
15- from blinkstick .decorators import no_backend_required
16+ from blinkstick .configs import _get_device_config
1617from blinkstick .devices import BlinkStickDevice
1718from blinkstick .enums import BlinkStickVariant , Mode
18- from blinkstick .exceptions import NotConnected
19+ from blinkstick .exceptions import NotConnected , UnsupportedOperation
20+ from blinkstick .models import Configuration
1921from blinkstick .utilities import string_to_info_block_data
2022
2123if sys .platform == "win32" :
@@ -94,6 +96,15 @@ def __str__(self):
9496 return "Blinkstick - Not connected"
9597 return f"{ variant } ({ serial } )"
9698
99+ @cached_property
100+ def _config (self ) -> Configuration :
101+ """
102+ Get the hardware configuration of the connected device, using the reported variant.
103+
104+ @rtype: Configuration
105+ """
106+ return _get_device_config (self .get_variant ())
107+
97108 def get_serial (self ) -> str :
98109 """
99110 Returns the serial number of backend.::
@@ -388,6 +399,11 @@ def set_mode(self, mode: Mode | int) -> None:
388399 @type mode: int
389400 @param mode: Device mode to set
390401 """
402+ if not self ._config .mode_change_support :
403+ raise UnsupportedOperation (
404+ "This operation is only supported on BlinkStick Pro devices"
405+ )
406+
391407 # If mode is an enum, get the value
392408 # this will allow the user to pass in the enum directly, and also gate the value to the enum values
393409 if not isinstance (mode , int ):
@@ -411,6 +427,10 @@ def get_mode(self) -> int:
411427 @rtype: int
412428 @return: Device mode
413429 """
430+ if not self ._config .mode_change_support :
431+ raise UnsupportedOperation (
432+ "This operation is only supported on BlinkStick Pro devices"
433+ )
414434
415435 device_bytes = self .backend .control_transfer (0x80 | 0x20 , 0x1 , 0x0004 , 0 , 2 )
416436
0 commit comments