Skip to content

Device Settings

set_power

Set the power state of the device.

Parameters:

Name Type Description Default
on bool

True to turn on, False to turn off.

True
Source code in src/pypixelcolor/commands/set_power.py
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
def set_power(on: bool = True):
    """
    Set the power state of the device.

    Args:
        on: True to turn on, False to turn off.
    """
    if isinstance(on, str):
        on = on.lower() in ("true", "1", "yes", "on")

    # Build command
    cmd = bytes([
        5,              # Command length
        0,              # Reserved
        7,              # Command ID
        1,              # Command type ID
        1 if on else 0  # Power state
    ])
    return single_window_plan("set_power", cmd)

Examples:

# Turn on the display
client.set_power(True)

# Turn off the display
client.set_power(False)
# Turn on the display
pypixelcolor -a <MAC_ADDRESS> -c set_power true

# Turn off the display
pypixelcolor -a <MAC_ADDRESS> -c set_power false

set_brightness

Set the brightness of the device.

Parameters:

Name Type Description Default
level int

Brightness level (0-100).

required
Source code in src/pypixelcolor/commands/set_brightness.py
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
def set_brightness(level: int):
    """
    Set the brightness of the device.

    Args:
        level (int): Brightness level (0-100).
    """
    if (0 > int(level)) or (int(level) > 100):
        raise ValueError("Brightness level must be between 0 and 100")
    payload = bytes([
        5,          # Command length
        0,          # Reserved
        4,          # Command ID
        0x80,       # Command type ID
        int(level)  # Brightness value
    ])
    return single_window_plan("set_brightness", payload)

Examples:

# Set brightness to 50%
client.set_brightness(50)

# Set maximum brightness (100%)
client.set_brightness(100)
pypixelcolor -a <MAC_ADDRESS> -c set_brightness 50

set_orientation

Set the orientation of the device.

Parameters:

Name Type Description Default
orientation int

The orientation value to set (0-3).

0
Source code in src/pypixelcolor/commands/set_orientation.py
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
def set_orientation(orientation: int = 0):
    """
    Set the orientation of the device.

    Args:
        orientation (int): The orientation value to set (0-3).
    """

    if (int(orientation) < 0 or int(orientation) > 3):
        raise ValueError("Orientation must be between 0 and 3")

    payload = bytes([
        5,                  # Command length
        0,                  # Reserved  
        6,                  # Command ID
        0x80,               # Command type ID
        int(orientation)    # Orientation value
    ])
    return single_window_plan("set_orientation", payload)

Examples:

# Set default orientation (0: 0°)
client.set_orientation(0)

# Rotate display (0: 0°, 1: 90°, 2: 180°, 3: 270°)
client.set_orientation(2)
pypixelcolor -a <MAC_ADDRESS> -c set_orientation 2

set_schedule

Set an automated on/off schedule by time and day of week.

Parameters:

Name Type Description Default
hour int

Hour (0-23). Defaults to 12.

required
minute int

Minute (0-59). Defaults to 0.

required
on bool

True to turn display ON, False to turn OFF. Defaults to True.

required
days Union[ScheduleDay, int, str, list[str], None]

Active days ('mon,sat' or ['mon', 'sat']). Defaults to all days.

None
slot int

Schedule slot index (0, 1, 2, ...). Defaults to 0.

0

Returns:

Name Type Description
SendPlan SendPlan

The single window send plan for this command.

Source code in src/pypixelcolor/commands/set_schedule.py
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def set_schedule(
    hour: int,
    minute: int,
    on: bool,
    days: Union[ScheduleDay, int, str, list[str], None] = None,
    slot: int = 0,
) -> SendPlan:
    """
    Set an automated on/off schedule by time and day of week.

    Args:
        hour (int): Hour (0-23). Defaults to 12.
        minute (int): Minute (0-59). Defaults to 0.
        on (bool): True to turn display ON, False to turn OFF. Defaults to True.
        days (Union[ScheduleDay, int, str, list[str], None]): Active days ('mon,sat' or ['mon', 'sat']). Defaults to all days.
        slot (int): Schedule slot index (0, 1, 2, ...). Defaults to 0.

    Returns:
        SendPlan: The single window send plan for this command.
    """
    if isinstance(on, str):
        on = on.lower() in ("true", "1", "yes", "on")

    hour = int(hour)
    minute = int(minute)
    slot = int(slot)

    if not (0 <= hour <= 23):
        raise ValueError(f"Hour must be between 0 and 23 (got {hour})")
    if not (0 <= minute <= 59):
        raise ValueError(f"Minute must be between 0 and 59 (got {minute})")
    if not (0 <= slot <= 255):
        raise ValueError(f"Slot must be between 0 and 255 (got {slot})")

    days_mask = _parse_days(days)

    payload = bytes([
        9,                  # Command length
        0,                  # Reserved
        0x11,               # Command ID (17)
        0x80,               # Command type ID
        1 if on else 0,     # Action: 1 = on, 0 = off
        slot,               # Slot index
        days_mask,          # Days bitmask
        hour,               # Hour
        minute,             # Minute
    ])

    return single_window_plan("set_schedule", payload)

Examples:

from pypixelcolor import ScheduleDay

# Turn ON at 08:00 every day (slot 0)
client.set_schedule(hour=8, minute=0, on=True, slot=0)

# Turn OFF at 23:00 on weekdays using ScheduleDay bitmask (slot 1)
client.set_schedule(
    hour=23,
    minute=0,
    on=False,
    days=ScheduleDay.MON | ScheduleDay.TUE | ScheduleDay.WED | ScheduleDay.THU | ScheduleDay.FRI,
    slot=1,
)

# Turn ON at 10:00 on weekends using string list (slot 2)
client.set_schedule(hour=10, minute=0, on=True, days=["sat", "sun"], slot=2)
# Turn ON at 08:00 every day
pypixelcolor -a <MAC_ADDRESS> -c set_schedule hour=8 minute=0 on=true slot=0

# Turn OFF at 23:00 on weekends
pypixelcolor -a <MAC_ADDRESS> -c set_schedule hour=23 minute=0 on=false days=sat,sun slot=1

pypixelcolor.commands.set_schedule.ScheduleDay

Bases: IntFlag

Days of the week bitmask for schedule.

Source code in src/pypixelcolor/commands/set_schedule.py
10
11
12
13
14
15
16
17
18
class ScheduleDay(IntFlag):
    """Days of the week bitmask for schedule."""
    MON = 0x02
    TUE = 0x04
    WED = 0x08
    THU = 0x10
    FRI = 0x20
    SUN = 0x40
    SAT = 0x80