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

@bobfrankston/lxlan

v0.1.13

Published

LIFX LAN protocol library for device control via UDP

Readme

@bobfrankston/lxlan

Core LIFX LAN protocol library. Transport-agnostic implementation of the LIFX LAN protocol for controlling LIFX devices over local networks.

Purpose

This package provides the protocol-level implementation for LIFX device control. It knows:

  • ✅ LIFX protocol messages (SetPower, SetColor, GetState, etc.)
  • ✅ Message encoding/decoding (binary packet format)
  • ✅ Device state management (power, color, label, etc.)
  • ✅ Event emission patterns (device discovery, state updates)

It does NOT know:

  • ❌ How to send UDP packets (no Node.js dgram)
  • ❌ How to open WebSockets (no browser APIs)
  • ❌ Any specific transport implementation

Architecture Factoring

┌─────────────────────────────────────────────────┐
│  Application (your code)                        │
├─────────────────────────────────────────────────┤
│  @bobfrankston/lxlan (this package)             │
│  • LxClient - device discovery & management     │
│  • LxDevice - individual device control         │
│  • LxProtocol - message encode/decode           │
│  • LxTransport - INTERFACE ONLY                 │
├─────────────────────────────────────────────────┤
│  Transport Implementation (pick one):           │
│  • @bobfrankston/lxlan-node     → rmfudp        │
│  • @bobfrankston/lxlan-browser  → httpudp-client│
└─────────────────────────────────────────────────┘

Transport Abstraction

The package exports LxTransport interface that must be implemented by transport layers:

export interface LxTransport {
  bind(): Promise<void>;
  close(): void;
  send(ip: string, port: number, data: Buffer): void;
  broadcast(data: Buffer, port: number, addresses: string[]): void;
  onMessage(handler: (data: Buffer, rinfo: RemoteInfo) => void): void;
  onError(handler: (err: Error) => void): void;
}

Implementations:

  • Node.js: @bobfrankston/lxlan-node provides rmfudp-based transport
  • Browser: @bobfrankston/lxlan-browser provides httpudp-client-based transport

Installation

This package is typically installed as a dependency of the platform-specific wrappers:

# For Node.js projects
npm install @bobfrankston/lxlan-node

# For browser projects
npm install @bobfrankston/lxlan-browser

Direct usage (if providing your own transport):

npm install @bobfrankston/lxlan

Direct Usage (Advanced)

If you're implementing your own transport:

import { LxClient } from '@bobfrankston/lxlan';
import { MyCustomTransport } from './my-transport';

const transport = new MyCustomTransport();
const client = new LxClient({ transport });

await client.start();

client.on('device', (device) => {
  console.log('Found:', device.label);
  device.setPower(true);
  device.setColor({ h: 120, s: 100, b: 50 });
});

Features

  • 🎯 Full LIFX LAN protocol support
  • 🔍 Automatic device discovery
  • 🎨 Color control (HSB, RGB, Kelvin)
  • 💡 Power control
  • 📊 Device state caching
  • 📡 Event-driven architecture
  • 🔄 Automatic retry with configurable timeouts
  • 📝 Comprehensive device info (firmware, WiFi, uptime)

Device Control

// Power control
device.setPower(true);
device.setPower(false);

// Color control
device.setColor({ h: 180, s: 100, b: 75 });      // HSB
device.setColor({ r: 255, g: 0, b: 0 });         // RGB
device.setColor({ kelvin: 3500 });               // White temperature

// Get comprehensive device info
device.getDeviceInfo();  // Triggers 'deviceInfo' event

// State queries
console.log(device.label, device.power, device.color);

Events

client.on('device', (device) => {
  // New device discovered
});

client.on('state', (device) => {
  // Device state updated
});

client.on('deviceInfo', (device) => {
  // Complete device info received (firmware, signal, uptime)
  console.log(device.firmwareVersion, device.signal, device.uptime);
});

Dependencies

  • @bobfrankston/colorlib - Color space conversions (HSB ↔ RGB ↔ Kelvin)

Related Packages

TypeScript Configuration

This package uses strictNullChecks: false - undefined is treated as a first-class value throughout the codebase.

License

MIT