How to use the wled.models.Nightlight 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
def from_dict(data: Dict[str, Any]) -> Nightlight:
        """Return Nightlight object from WLED API response."""
        nightlight = data.get("nl", {})
        return Nightlight(
            duration=nightlight.get("dur", 1),
            fade=nightlight.get("fade", False),
            on=nightlight.get("on", False),
            target_brightness=nightlight.get("tbri"),
        )
github frenck / python-wled / wled / models.py View on Github external
pallet_count=data.get("palcount", 0),
            product=data.get("product", "DIY Light"),
            udp_port=data.get("udpport", 0),
            uptime=data.get("uptime", 0),
            version_id=data.get("vid", "Unknown"),
            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
github frenck / python-wled / wled / models.py View on Github external
segments = [
            Segment.from_dict(
                segment_id=segment_id,
                data=segment,
                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),
        )