English | 简体中文
Yeelight LAN control SDK for Node.js
npm install @homeiot/yeelight
import { Discovery } from '@homeiot/yeelight'
import type { Device } from '@homeiot/yeelight'
new Discovery()
.on('error', err => console.error(err))
.on('start', () => console.log('LAN discovery started'))
.on('stop', () => console.log('LAN discovery stoped'))
.on('device', (device: Device) => {
// Smart LED is turned on
device.power = 'on'
})
.start()
import { Device } from '@homeiot/yeelight'
const device = new Device({ host: '192.168.1.239' })
.on('error', err => console.error(err))
.on('start', () => console.log('LAN device started'))
.on('stop', () => console.log('LAN device stoped'))
.on('request', data => console.log('[request]', data))
.on('response', data => console.log('[response]', data))
// Smart LED is turned on
device.power = 'on'
// Brightness percentage. Range 1 ~ 100
device.bright = 50