How to use the wled.models.Sync function in wled

To help you get started, we’ve selected a few wled examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github frenck / python-wled / wled / models.py View on Github external
effects=effects,
                palettes=palettes,
                state_on=on,
                state_brightness=brightness,
            )
            for segment_id, segment in enumerate(data.get("seg", []))
        ]

        return State(
            brightness=brightness,
            nightlight=Nightlight.from_dict(data),
            on=on,
            playlist=data.get("pl", -1),
            preset=data.get("ps", -1),
            segments=segments,
            sync=Sync.from_dict(data),
            transition=data.get("transition", 0),
        )
github frenck / python-wled / wled / models.py View on Github external
def from_dict(data: Dict[str, Any]) -> Sync:
        """Return Sync object from WLED API response."""
        sync = data.get("udpn", {})
        return Sync(send=sync.get("send", False), receive=sync.get("recv", False))
github frenck / python-wled / wled / models.py View on Github external
version=data.get("ver", "Unknown"),
            wifi=Wifi.from_dict(data),
        )


@dataclass
class State:
    """Object holding the state of WLED."""

    brightness: int
    nightlight: Nightlight
    on: bool
    playlist: int
    preset: int
    segments: List[Segment]
    sync: Sync
    transition: int

    @property
    def playlist_active(self) -> bool:
        """Return if a playlist is currently active."""
        return self.playlist == -1

    @property
    def preset_active(self) -> bool:
        """Return if a preset is currently active."""
        return self.preset == -1

    @staticmethod
    def from_dict(
        data: Dict[str, Any], effects: List[Effect], palettes: List[Palette]
    ) -> State: