Skip to content

State

busylight_core.vendors.muteme.implementation.state

MuteMe device state management.

This module defines the State class that manages command construction for MuteMe devices, including simple on/off color control and device behavior settings.

Classes

busylight_core.vendors.muteme.implementation.state.State

State(value=0, length=8)

Bases: Word

Complete device state for MuteMe commands.

MuteMe devices have a simple control scheme using 1-bit fields for each color component and behavior setting. Unlike other vendors, MuteMe uses pure on/off color control rather than full 8-bit RGB values.

Create a Word instance for binary data manipulation.

Initializes a binary word with the specified bit length and initial value. The length must be a multiple of 8 to align with byte boundaries. Use this to create state objects for devices that use binary communication protocols.

:param value: Initial integer value to store in the word :param length: Total bit length, must be multiple of 8 :raises ValueError: If length is not a positive multiple of 8

Source code in src/busylight_core/word.py
def __init__(self, value: int = 0, length: int = 8) -> None:
    """Create a Word instance for binary data manipulation.

    Initializes a binary word with the specified bit length and initial value.
    The length must be a multiple of 8 to align with byte boundaries. Use this
    to create state objects for devices that use binary communication protocols.


    :param value: Initial integer value to store in the word
    :param length: Total bit length, must be multiple of 8
    :raises ValueError: If length is not a positive multiple of 8
    """
    if length <= 0 or length % 8 != 0:
        msg = "length must be a multiple of 8"
        raise ValueError(msg)

    self.initial_value = value
    self.length = length
    self.bits = array.array("B", [(value >> n) & 1 for n in self.range])
Attributes
busylight_core.vendors.muteme.implementation.state.State.red class-attribute instance-attribute
red = RedBit()
busylight_core.vendors.muteme.implementation.state.State.green class-attribute instance-attribute
green = GreenBit()
busylight_core.vendors.muteme.implementation.state.State.blue class-attribute instance-attribute
blue = BlueBit()
busylight_core.vendors.muteme.implementation.state.State.dim class-attribute instance-attribute
dim = DimBit()
blink = BlinkBit()
busylight_core.vendors.muteme.implementation.state.State.sleep class-attribute instance-attribute
sleep = SleepBit()
busylight_core.vendors.muteme.implementation.state.State.color property writable
color

Get the current color state as RGB tuple.

Returns 8-bit RGB values (0x00 or 0xFF) based on the current bit field states.

busylight_core.vendors.muteme.implementation.state.State.initial_value instance-attribute
initial_value = value
busylight_core.vendors.muteme.implementation.state.State.length instance-attribute
length = length
busylight_core.vendors.muteme.implementation.state.State.bits instance-attribute
bits = array('B', [value >> n & 1 for n in range])
busylight_core.vendors.muteme.implementation.state.State.value property
value

Return the integer value of the word.

busylight_core.vendors.muteme.implementation.state.State.range property
range

Return the range of bit offsets for this word.

busylight_core.vendors.muteme.implementation.state.State.hex property
hex

Return a string hexadecimal representation of the word.

busylight_core.vendors.muteme.implementation.state.State.bin property
bin

Return a string binary representation of the word.

Functions
busylight_core.vendors.muteme.implementation.state.State.clear
clear()

Clear all bits in the word.

Source code in src/busylight_core/word.py
def clear(self) -> None:
    """Clear all bits in the word."""
    self.bits = array.array("B", [0] * self.length)