npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

wled-js

v0.0.2

Published

A simple js client for wled

Downloads

105

Readme

wled-js

Simple JavaScript client for WLED with support for JSON API, Websocket and DDP.

Installation

Use npm to install the package:

npm install wled-js

Getting Started

Here is an example of how you can use the WledClient to connect to a WLED device and perform some basic operations:

import WledClient from 'wled-js';

// Create a new WLED client
const client = new WledClient('XXX.XXX.XXX.XXX');

// Turn on the WLED device
client.turn(true).then(() => {
  console.log('WLED device is now on');
});

// Set the brightness to 128
client.setBrightness(128).then(() => {
  console.log('Brightness set to 128');
});

// Listen for live data
client.onLiveStreamData((colors) => {
  console.log('Live stream data:', colors);
});

// Trigger the live stream
client.triggerWebsocketLiveStream();

const ledStrip = [
  {r: 255, g: 0, b: 0},
  {r: 0, g: 255, b: 0},
  {r: 0, g: 0, b: 255},
];

// Set the colors of the LED strip via DDP
setInterval(() => {
  client.setColors(ledStrip);
}, 500);

API

WledClient

JSON API Methods

  • turn(on: boolean): Promise<void>: Turns on/off the LED strip.

  • setLight(color: Led, brightness: number): Promise<void>: Sets the color and brightness of the LED strip.

  • setLightPercent(color: Led, brightness: number): Promise<void>: Sets the color and brightness of the LED strip in percent.

  • setColor(color: Led): Promise<void>: Sets the color of the whole LED strip.

  • setEffect(effect: string | number): Promise<void>: Sets the effect of the LED strip (This can be the name or the index of the effect).

  • setBrightness(brightness: number): Promise<void>: Sets the brightness of the LED strip.

  • setBrightnessPercent(brightness: number): Promise<void>: Sets the brightness of the LED strip in percent.

  • updateState(state: PartialWLEDState): Promise<void>: Updates the state of the WLED device.

  • getLedCount(): Promise<number>: Retrieves the amount of LEDs from the WLED device.

  • isOn(): Promise<boolean>: Retrieves the on/off state of the WLED device.

  • getAllData(): Promise<WLEDFullResponse>: Retrieves all data from the WLED device.

  • getState(): Promise<WLEDState>: Retrieves the current state of the WLED device.

  • getEffects(): Promise<string[]>: Retrieves the available effects from the WLED device.

  • getFxData(): Promise<string[]>: Retrieves the FX data from the WLED device.

  • getNetworks(): Promise<WLEDNetworkResponse>: Retrieves the available networks from the WLED device.

  • getPalettes(): Promise<string[]>: Retrieves the available palettes from the WLED device.

  • getConfig(): Promise<WLEDConfig>: Retrieves the configuration of the WLED device.

  • getInfo(): Promise<WLEDInfo>: Retrieves the information of the WLED device.

  • getNodes(): Promise<WLEDNodesResponse>: Retrieves the available nodes from the WLED device.

  • getStateAndInfo(): Promise<WLEDStateAndInfoResponse>: Retrieves the state and information of the WLED device.

Websocket Methods

  • triggerWebsocketStateUpdate(): Promise<void>: Triggers a state update via WebSocket.
  • triggerWebsocketLiveStream(): Promise<void>: Triggers a live stream via WebSocket.
  • onStateChange(callback: WLEDStateCallback): WebsocketAddResponse: Adds a listener for state changes.
  • onLiveStreamData(callback: WLEDLiveStreamCallback): WebsocketAddResponse: Adds a listener for live stream data.

Optional:

  • connect(): Promise<void>: Manually connects to the WebSocket server.
  • disconnect(): void: Disconnects from the WebSocket server.

    The connect and disconnect functions are not necessary to call manually, as they are automatically called when using the onStateChange and onLiveStreamData methods. However, they can be used to manually connect and disconnect from the WebSocket server.

DDP Methods

  • setLedStripViaDdp(ledStrip: LedStrip, disableValidation = false): Promise<void>: Sends LED data via the DDP protocol.
  • setLedStripAsBufferViaDdp(ledStrip: Buffer, ledAmount: number): Promise<void>: Sends LED data as a buffer via the DDP protocol.
  • sendDdpPacket(packet: DdpPacket): Promise<void>: Sends a DDP packet.