Skip to content

State

busylight_core.vendors.embrava.implementation.state

Embrava Blynclight device state management.

This module defines the State class that manages the complete command structure for Embrava Blynclight devices, including LED control and audio functionality.

Classes

busylight_core.vendors.embrava.implementation.state.State

State()

Bases: Word

Complete device state for Embrava Blynclight commands.

The State class manages the full command structure sent to Embrava devices. It controls both LED behavior (color, brightness, flashing) and audio functionality (ringtones, volume, playback control). The state is serialized to bytes for transmission to the hardware.

Source code in src/busylight_core/vendors/embrava/implementation/state.py
def __init__(self) -> None:
    super().__init__(0, 48)
Attributes
busylight_core.vendors.embrava.implementation.state.State.red class-attribute instance-attribute
red = RedField()
busylight_core.vendors.embrava.implementation.state.State.blue class-attribute instance-attribute
blue = BlueField()
busylight_core.vendors.embrava.implementation.state.State.green class-attribute instance-attribute
green = GreenField()
busylight_core.vendors.embrava.implementation.state.State.off class-attribute instance-attribute
off = OffBit()
busylight_core.vendors.embrava.implementation.state.State.dim class-attribute instance-attribute
dim = DimBit()
busylight_core.vendors.embrava.implementation.state.State.flash class-attribute instance-attribute
flash = FlashBit()
busylight_core.vendors.embrava.implementation.state.State.speed class-attribute instance-attribute
speed = SpeedField()
busylight_core.vendors.embrava.implementation.state.State.repeat class-attribute instance-attribute
repeat = RepeatBit()
busylight_core.vendors.embrava.implementation.state.State.play class-attribute instance-attribute
play = PlayBit()
busylight_core.vendors.embrava.implementation.state.State.music class-attribute instance-attribute
music = MusicField()
busylight_core.vendors.embrava.implementation.state.State.volume class-attribute instance-attribute
volume = VolumeField()
busylight_core.vendors.embrava.implementation.state.State.mute class-attribute instance-attribute
mute = MuteBit()
busylight_core.vendors.embrava.implementation.state.State.initial_value instance-attribute
initial_value = value
busylight_core.vendors.embrava.implementation.state.State.length instance-attribute
length = length
busylight_core.vendors.embrava.implementation.state.State.bits instance-attribute
bits = array('B', [value >> n & 1 for n in range])
busylight_core.vendors.embrava.implementation.state.State.value property
value

Return the integer value of the word.

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

Return the range of bit offsets for this word.

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

Return a string hexadecimal representation of the word.

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

Return a string binary representation of the word.

Functions
busylight_core.vendors.embrava.implementation.state.State.reset
reset()

Reset the state to default values.

Sets the device to off state with no audio playback and default flash speed settings.

Source code in src/busylight_core/vendors/embrava/implementation/state.py
def reset(self) -> None:
    """Reset the state to default values.

    Sets the device to off state with no audio playback and
    default flash speed settings.
    """
    self.red = 0
    self.blue = 0
    self.green = 0
    self.off = True
    self.dim = False
    self.flash = False
    self.speed = FlashSpeed.slow.value
    self.play = False
    self.mute = False
    self.repeat = False
    self.music = 0
    self.volume = 0
busylight_core.vendors.embrava.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)