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

nanoleaf-client-multi

v2.0.1

Published

Client app for Nanoleaf devices

Downloads

14

Readme

nanoleaf-client

NPM version MIT License Bundle size Build Coverage Status

Prerequisites

Make sure you have installed all of the following prerequisites on your development machine:

Cloning and the GitHub repository

The recommended way to get Nanoleaf Client is to use git to directly clone repository:

$ git clone https://github.com/VadimGarkusha/nanoleaf-client.git

This will clone the latest version of the Nanoleaf Client repository.

Installing the npm package

To install the dependencies, run this in the application folder from the command-line:

$ npm install nanoleaf-client

Service Discovery

In order to use the client you need to know your device IP on the network and a user token.

Get device IP. NOTE: before running this command make sure the device is plugged in and is connected to the network. You can check it with phone app.

Be careful with IPs! Sometimes, if you plug out the device or a router an IP address might change.

Getting device IP

import { ServiceDiscovery } from 'nanoleaf-client';

let serviceDiscovery = new ServiceDiscovery();

serviceDiscovery.discoverNanoleaf().then(devices => {

  // devices is an array of all Nanoleaf devices found on the network.
  // device info contains location info, uuid and device Id.
  console.log(devices);
});

Getting token

Before executing this command, hold power button on your nanoleaf device for 5 seconds until the white LED starts glowing. After that you have 30 seconds to execute this command and get a token. Client will be authorized automatically.

NOTE: Device can hold up to 5 tokens. New tokens come in FIFO order.

client.authorize().then(token => {
    console.log(token);
}).catch(err => {
    console.log(err);
});

Supported Methods

Nanoleaf Client

General Requests

  • getInfo() - returns object with information about current state of device
  • identify() - causes panels to flash in unison, returns response with status if successful
  • authorize() - authorizes nanoleaf client for future requests and returns string auth token
  • getGlobalOrientation() - returns object with global orientation value

Power

  • turnOn() - turns on the device
  • turnOff() - turns off the device
  • power(power) - accepts boolean parameter and sets device power status
  • getPowerStatus() - returns object with power status

Saturation

  • getSaturation() - returns object with current saturation value
  • setSaturation(value) - accepts numerical parameter and sets saturation value
  • incrementSaturation(increment) - accepts numerical parameter and incerements saturation value by it

Brightness

  • getBrightness() - returns object with current brightness value
  • setBrightness(value) - accepts numerical parameter and sets brightness value
  • increaseBrightness(increment) - accepts numerical parameter and incerements brightness value by it
  • setDurationBrightness(value, duration) - accepts two numerical parameter and sets brightness value for duration period

Hue

  • getHue() - returns object with current hue value
  • setHue(value) - accepts numerical parameter and sets hue value
  • increaseHue(increment) - accepts numerical parameter and incerements hue value by it

Color Temperature

  • getColorTemperature() - returns current color temperature value
  • setColorTemperature(value) - accepts numerical parameter and sets color temperature value
  • incrementColorTemperature(increment) - accepts numerical parameter and incerements color temperature value by it

Effect/Theme

  • getColorMode() - returns string with current color temperature value ct (color temperature), hs (hue/saturation), or effect
  • getSelectedEffect() - returns string with selected effect
  • getEffectInfo(effectName) - accepts string with effect name and returns object with effect properties
  • setEffect(value) - accepts string with effect names and sets it as current effect
  • getEffectList() - returns array of strings with available effects

Color

  • setHsvColor(h, s, v) - accepts three numerical parameters and sets hsv color based on them
  • setHslColor(h, s, l) - accepts three numerical parameters and sets hsl color based on them
  • setHexColor(hexString) - accepts string parameter with hex values and sets color based on it
  • setRgbColor(r, g, b) - accepts three numerical parameters and sets rgb color based on them

Examples

Setting up client

import { NanoleafClient } from 'nanoleaf-client';

 let client = new NanoleafClient('<device_ip>', '<user_token>');

// For example
let client = new NanoleafClient('192.168.0.10', 'qEQ8ZLcPuOVesarDXIW6eGQQd1Hhn1d9');

// Without token
let noTokenClient = new NanoleafClient('192.168.0.10');

// Adding token later
noTokenClient.authorize('qEQ8ZLcPuOVesarDXIW6eGQQd1Hhn1d9');

Turn on/off

client.turnOn().then(res => {
    console.log(res);
}).catch(err => {
    console.log(err);
});

client.turnOff().then(res => {
    console.log(res);
}).catch(err => {
    console.log(err);
});

Get device info

client.getInfo().then(res => {
    console.log(res);
}).catch(err => {
    console.log(err);
});

License

This project is licensed under the MIT License - see the LICENSE.md file for details