Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ ignore-imports = true
max-line-length = 88

[tool.pylint.DESIGN]
max-attributes = 20
max-attributes = 40

[tool.pylint.TYPECHECK]
ignored-modules = ["orjson", "zeroconf", "zeroconf.asyncio"]
Expand Down
9 changes: 8 additions & 1 deletion src/wled/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
"""Asynchronous Python client for WLED."""

from .const import LightCapability, LiveDataOverride, NightlightMode, SyncGroup
from .const import (
LightCapability,
LiveDataOverride,
NightlightMode,
SoundSimulationType,
SyncGroup,
)
from .exceptions import (
WLEDConnectionClosedError,
WLEDConnectionError,
Expand Down Expand Up @@ -42,6 +48,7 @@
"Preset",
"Releases",
"Segment",
"SoundSimulationType",
"State",
"SyncGroup",
"UDPSync",
Expand Down
9 changes: 9 additions & 0 deletions src/wled/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ class NightlightMode(IntEnum):
SUNRISE = 3


class SoundSimulationType(IntEnum):
"""Enumeration representing sound simulation types for audio effects."""

BEAT_SIN = 0
WE_WILL_ROCK_YOU = 1
TEN_THREE = 2
FOURTEEN_THREE = 3


class SyncGroup(IntFlag):
"""Bitfield for UDP sync groups 1-8."""

Expand Down
118 changes: 88 additions & 30 deletions src/wled/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
LightCapability,
LiveDataOverride,
NightlightMode,
SoundSimulationType,
SyncGroup,
)
from .exceptions import WLEDUnsupportedVersionError
Expand Down Expand Up @@ -126,6 +127,9 @@ class Nightlight(BaseModel):
on: bool = field(default=False)
"""Nightlight currently active."""

remaining: int = field(default=-1, metadata=field_options(alias="rem"))
"""Remaining nightlight duration in seconds. -1 if not active."""

target_brightness: int = field(default=0, metadata=field_options(alias="tbri"))
"""Target brightness of nightlight feature."""

Expand Down Expand Up @@ -203,6 +207,13 @@ class Segment(BaseModel):
~ to increment, ~- to decrement. w~40 to increment by 40, wrapping.
"""

cct: int = field(default=0)
"""White spectrum color temperature.

0 indicates the warmest possible color temperature,
255 indicates the coldest temperature.
"""

clones: int = field(default=-1, metadata=field_options(alias="cln"))
"""The segment this segment clones."""

Expand All @@ -216,15 +227,30 @@ class Segment(BaseModel):
automatically convert those to RGB values to keep the data consistent.
"""

custom1: int = field(default=128, metadata=field_options(alias="c1"))
"""Effect custom slider 1 value (0-255)."""

custom2: int = field(default=128, metadata=field_options(alias="c2"))
"""Effect custom slider 2 value (0-255)."""

custom3: int = field(default=16, metadata=field_options(alias="c3"))
"""Effect custom slider 3 value (0-31)."""

effect_id: int | str = field(default=0, metadata=field_options(alias="fx"))
"""ID of the effect.

~ to increment, ~- to decrement, or "r" for random.
"""

expand_1d: int = field(default=0, metadata=field_options(alias="m12"))
"""Setting of segment field 'Expand 1D FX' (0-4)."""

freeze: bool = field(default=False, metadata=field_options(alias="frz"))
"""Freeze the current segment state."""

grouping: int = field(default=1, metadata=field_options(alias="grp"))
"""How many consecutive LEDs are grouped to the same color."""

intensity: int | str = field(default=0, metadata=field_options(alias="ix"))
"""Intensity of the segment.

Expand All @@ -238,41 +264,62 @@ class Segment(BaseModel):
Stop has preference, so if it is included, length is ignored.
"""

mirror: bool = field(default=False, metadata=field_options(alias="mi"))
"""Mirrors the segment (horizontal for 2D)."""

mirror_y: bool = field(default=False, metadata=field_options(alias="mY"))
"""Mirrors the 2D segment in the vertical dimension."""

name: str | None = field(default=None, metadata=field_options(alias="n"))
"""User-defined name of the segment."""

offset: int = field(default=0, metadata=field_options(alias="of"))
"""How many LEDs to rotate the virtual start of the segment."""

on: bool | None = field(default=None)
"""The on/off state of the segment."""

option1: bool = field(default=False, metadata=field_options(alias="o1"))
"""Effect option 1."""

option2: bool = field(default=False, metadata=field_options(alias="o2"))
"""Effect option 2."""

option3: bool = field(default=False, metadata=field_options(alias="o3"))
"""Effect option 3."""

palette_id: int | str = field(default=0, metadata=field_options(alias="pal"))
"""ID of the palette.

~ to increment, ~- to decrement, or r for random.
"""

reverse: bool = field(default=False, metadata=field_options(alias="rev"))
"""
Flips the segment (in horizontal dimension for 2D set-up),
causing animations to change direction.
"""
"""Flips the segment (horizontal for 2D), causing animations to change direction."""

reverse_y: bool = field(default=False, metadata=field_options(alias="rY"))
"""Flips the 2D segment in the vertical dimension."""

segment_id: int | None = field(default=None, metadata=field_options(alias="id"))
"""The ID of the segment."""

selected: bool = field(default=False, metadata=field_options(alias="sel"))
"""
Indicates if the segment is selected.
"""Indicates if the segment is selected.

Selected segments will have their state (color/FX) updated by APIs that
don't support segments (e.g. UDP sync, HTTP API). If no segment is selected,
the first segment (id:0) will behave as if selected.
don't support segments (e.g. UDP sync, HTTP API).
"""

WLED will report the state of the first (lowest id) segment that is selected
to APIs (HTTP, MQTT, Blynk...), or mainseg in case no segment is selected
and for the UDP API.
set_id: int = field(default=0, metadata=field_options(alias="set"))
"""Group or set ID assigned to the segment (0-3)."""

Live data is always applied to all LEDs regardless of segment configuration.
"""
sound_simulation: SoundSimulationType = field(
default=SoundSimulationType.BEAT_SIN, metadata=field_options(alias="si")
)
"""Sound simulation type for audio enhanced effects."""

spacing: int = field(default=0, metadata=field_options(alias="spc"))
"""How many LEDs are turned off and skipped between each group."""

speed: int | str = field(default=0, metadata=field_options(alias="sx"))
"""Relative effect speed.
Expand All @@ -281,34 +328,28 @@ class Segment(BaseModel):
"""

start: int = 0
"""LED the segment starts at.
"""LED the segment starts at (column for 2D)."""

For 2D set-up it determines column where segment starts,
from top-left corner of the matrix.
"""
start_y: int = field(default=0, metadata=field_options(alias="startY"))
"""Start row from top-left corner of the matrix (2D only)."""

stop: int = 0
"""LED the segment stops at, not included in range.
"""LED the segment stops at, not included in range (column for 2D)."""

If stop is set to a lower or equal value than start (setting to 0 is
recommended), the segment is invalidated and deleted.
stop_y: int = field(default=0, metadata=field_options(alias="stopY"))
"""Stop row from top-left corner of the matrix (2D only)."""

For 2D set-up it determines column where segment stops,
from top-left corner of the matrix.
"""

cct: int = field(default=0)
"""White spectrum color temperature.

0 indicates the warmest possible color temperature,
255 indicates the coldest temperature
"""
transpose: bool = field(default=False, metadata=field_options(alias="tp"))
"""Transposes the segment, swapping X and Y dimensions (2D only)."""


@dataclass(kw_only=True)
class Leds:
"""Object holding leds info from WLED."""

cct: bool = False
"""True if the LEDs support color temperature control."""

count: int = 0
"""Total LED count."""

Expand All @@ -332,11 +373,17 @@ class Leds:
0 if ABL is disabled.
"""

rgbw: bool = False
"""True if the LEDs are 4-channel (RGB + White)."""

segment_light_capabilities: list[LightCapability] = field(
default_factory=list, metadata=field_options(alias="seglc")
)
"""Capabilities of each segment."""

wv: bool = False
"""True if the white channel slider should be displayed."""


@dataclass(kw_only=True)
class Wifi(BaseModel):
Expand Down Expand Up @@ -489,6 +536,11 @@ class Info(BaseModel): # pylint: disable=too-many-instance-attributes
upgrades (e.g. "ESP32", "ESP32_Ethernet", "ESP8266_160").
"""

sync_toggle_receive: bool = field(
default=False, metadata=field_options(alias="str")
)
"""If true, UI toggling also toggles sync receive."""

udp_port: int = field(default=0, metadata=field_options(alias="udpport"))
"""The UDP port for realtime packets and WLED broadcast."""

Expand Down Expand Up @@ -544,6 +596,12 @@ class State(BaseModel):
The state response will never have the value 0 for bri.
"""

ledmap: int = field(default=0)
"""Currently loaded LED map. 0 is the default map."""

main_segment_id: int = field(default=0, metadata=field_options(alias="mainseg"))
"""ID of the main segment."""

nightlight: Nightlight = field(metadata=field_options(alias="nl"))
"""Nightlight state."""

Expand Down
Loading
Loading