Skip to content

Latest commit

 

History

History

yeelight

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

@homeiot/yeelight

License Version Minzip

English | 简体中文

Yeelight LAN control SDK for Node.js

Installation

npm install @homeiot/yeelight

Usage

Discover LAN device

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()

Control LAN device

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

Official documentation

Yeelight WiFi Light Inter-Operation Specification