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 🙏

© 2024 – Pkg Stats / Ryan Hefner

yee-ts

v1.3.13

Published

Brand new yeelight API implementation on ts node.

Downloads

26

Readme

Yee-ts

Simple typescript implementation of yeelight API Docs

Compatibility

Package should work with all yeelight smart devices. Currently tested only with:

  • Yeelight Smart Bulb W3

Package not tested with couple yeelight devices, so discovery may cause bugs.

Usage

Make sure you turn on 3-rd party bulb control in yeelight app.

import {Yeelight, Storage} from 'yee-ts'

// Default usage (storage for device provide discovery)
async function foo() {
  const yee = new Yeelight(); // Create instance
  await yee.discover(); // Discover yeelight devices

  const device = yee.createDevice('ID') // Create device with bulb id
}

// Only light control (custom storage)
async function bar() {
  const yee = new Yeelight();
  const storage = new Storage([{
      id: 'bar',
      ip: '192.168.0.1'
    }])

  const device = yee.createDevice('bar', storage) // Create device with bulb id
}

API

import { Yeelight, Storage } from 'yee-ts';

new Yeelight()
  .getDevice() // Reffer to Storage().getOne()
  .getDevices() // Reffer to Storage().getAll()
  .createDevice(): Device // Create new device connection

new Storage(storage?: IYeeDevice[])
  .getAll(): IYeeDevice[] | null // Get array of discovered devices or null
  .getOne(id: string): IYeeDevice | null // Get single device by id or null
  .updateAll(devices: IYeeDevice[]): IYeeDevice[] // Replace old storage with new

new Yeelight().createDevice(id: string, storage?: Storage, params?: IDeviceParams) // new Device()
  .getDevice(): IYeeDevice // Get device
  .updateStorage(device: IYeeDevice, wipe?: boolean) // Rewrites device old props with new, is wipe is true, will replace old storage with new. Ip and id is required.
  .updateParams(params: IDeviceParams) // Rewrites class props.
  .closeWriteSocket() // Close write socket
  .reconnectWriteSocket() // Reconnect write socket
  .closeListenSocket() // Close listen socket
  .reconnectListenSocket() // Reconnect listen socket
  . // Implemented all methods, to use bg_ set isBg in command to true. Except methods listed below. You can see all types in yee-ts/dist/types/Device.d.ts

Device

const deviceDefaultParams: IDeviceParams = {
  writeTimeoutMs: 5000,
  writeSocketPort: 55439, // For reconnect it uses this port - 1
  listenSocketPort: 55429, // For reconnect it uses this port - 1
  listenSocketTimeout: 3600000
  defaultEffect: 'smooth',
  effectDuration: 300,
  defaultMode: 0,
  localIP: '192.168.0.1' // set the public ipv4 ip
  devCMD: false,
  forceTurnOn: false // Set power on if command requires it.
};

Excepted methods

method cron_get // Throws write socket timeout on W3 bulb. Use instead set_scene('auto_delay_off')
method get_prop // Throws write socket timeout on W3 bulb. Use instead get_prop() from storage
method set_music // W3 bulb not connecting to music server. Behaivour is not predictable, so method is not implemented.

Handlers

// ct < 1700 | > 6500 = range error / true
ctCheckRange(ct: number)
// full < 0 | > 16777215 or rgb < 0 | > 255 = range error / true. Full code is more priotired.
rgbCheckRange(full: number | null, r: number, g: number, b: number)
// hue < 0 || hue > 359 = range error / true
hueCheckRange(hue: number)
// sat < 0 || sat > 100 = range error / true
satCheckRange(sat: number)
// bright < 1 || bright > 100 = range error / true
brightCheckRange(bright: number)


// converts rgb to full number ((r * 65536) + (g * 256) + b)
rgbToFull(r: number, g: number, b: number)

Events

// Device
interface IDeviceEmitter {
  response: (data: { method: string, params: { [attr: string]: any } }, device: IYeeDevice) => void
}

Download

Package also available on NPM

npm i yee-ts

License: MIT Last update: 1.3.13 unniiiverse 2023