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

everlights

v1.0.0-beta.0

Published

A developer-friendly SDK for for easy integrations with EverLights (v3)

Downloads

27

Readme

EverLights SDK

This project is a Work in Progress. The basics are there, but there are bound to be some mistakes and there's currently virtually no validation or documentation.

A developer-friendly SDK for EverLights (v3 controller). I reversed engineered the API by intercepting traffic on my phone and working out the API from there.

To use, you'll need your EverLights Bridge IP address, which can be found in the app Settings -> Bridge.

No documentation yet, but I've done my best to create simple to follow and read API. You can check out ./src/v3-sdk.ts to get the basics. To me, the most import part is changing what the lights are doing. This is the only sort of non-standard thing I did. I've called this a Program, for lack of a better term. These are the patterns effects that dictate how the lights behave. So I abstracted that a bit away, and you can "start/stop programs" for zones.

Usage

Just install this from npm:

npm install everlights

You can see the Example below to get an idea of usage. More documentation coming soon-ish. Maybe?

Types

All the endpoints' requests and responses have been typed. They may not be 100% accurate right now, but it's close. So the main benefit of this SDK is using it with TypeScript to help you very quickly know what data to send and what data to return.

Set all the types used in ./src/types/.

Color Inputs

The color-normalize package is used so allow for a very wide array of color inputs. Anything that's valid in CSS can be used here (pass in the string, e.g. rgb(0, 0, 0)), as well as array and object values. Transparencies are ignored.

export interface RGBColor {
  r: number;
  g: number;
  b: number;
}

export interface RedGreenBlueColor {
  red: number;
  green: number;
  blue: number;
}

export interface HSLColor {
  h: number;
  s: number;
  l: number;
}

export interface HueSaturationLightnessColor {
  hue: number;
  saturation: number;
  lightness: number;
}

export type ColorInput = string | number | number[] | RGBColor | RedGreenBlueColor | HSLColor | HueSaturationLightnessColor;

Example

import { ColorInput, EffectInput, EffectType, EverLights, Zone } from 'everlights';

// `host` would be the one you found earlier, e.g. 192.168.1.105
const everLights = new EverLights({ host: process.env.EVER_LIGHTS_HOST! });

(async () => {
  // get the first zone (I only have one)
  const [zone]: Zone[] = await everLights.getZones();

  const pattern: ColorInput[] = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'];
  // effects are optional. some can be combined. currently, there is no input validation
  const effects: EffectInput[] = [
    {
      // enum to helper with the effects
      type: EffectType.Chase,
      // speed value 0-255
      speed: 255,
    },
  ];

  await everLights.startProgram(zone.serial, pattern, effects);

  // alternatively, you can create a "zone helper" sub-SDK to not have to keep passing the serial around
  const zoneHelper = everLights.makeZoneHelper(zone.serial);
  // this is equivalent to the everLights.startProgram above
  await zoneHelper.startProgram(pattern, effects);

  // this will turn all the lights off in the zone
  await everLights.stopProgram(zone.serial);
  
  // of you can use the zone helper
  await zoneHelper.stopProgram();
})().catch((err) => {
  console.error('Error', err?.response?.data || err.message);
});

TODO

  • Add validation.
  • Add sane defaults (e.g. don't make user generate UUIDs for creating stuff, generate timestamps, etc).
  • Documentation.
  • Keep Open API spec up to date.