Yeelight Client
A TypeScript library for local LAN control of Yeelight devices.
What this is
A zero-dependency Node.js library that communicates with Yeelight WiFi devices directly over TCP — no cloud, no Xiaomi account, no external API.
The library targets the Yeelight inter-operation protocol (port 55443, JSON-RPC over plain-text socket) and is built around a channel abstraction that works uniformly across the entire device lineup — from simple white bulbs to dual-zone light bars.
A companion CLI tool (yeelight-cli) is also available for terminal control.
Target hardware
Primary test device: Yeelight Light Bar Pro (lamp15 / YLTD003) — the most capable device in the lineup, with a CT main channel and a dual-zone RGB rear strip.
The library is designed to work with the full Yeelight lineup. See Devices for the compatibility matrix.
Quick start
import { YeelightDevice, Flow } from 'yeelight-client'
const [device] = await YeelightDevice.discover()
await device.connect()
// Basic control
await device.main.setColorTemp(4000)
await device.main.setBrightness(80)
await device.background?.setRGB(255, 0, 128)
// Turn on and apply state atomically (even if device is off)
await device.setScene({ type: 'ct', colorTemp: 3000, brightness: 60 })
// Relative adjustments — no need to know the current value
await device.main.adjustBrightness(+20)
await device.main.setAdjust('increase', 'ct')
// Color flow presets
await device.main.startFlow(Flow.candle())
// Sleep timer
await device.cronAdd(30) // turn off in 30 minutes
device.disconnect()