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

@mdombrock/lifx-zero

v1.0.6

Published

A (Hopefully) Better NodeJS API Wrapper For LIFX light bulbs.

Downloads

9

Readme

LIFX-ZERO

A (Hopefully) Better NodeJS API Wrapper For LIFX light bulbs.

This software is not an official LIFX product and I am not related to LIFX in any way shape or form. Do not blame me if something breaks.

Make sure to checkout the documentation for the official API at https://api.developer.lifx.com/docs/.

NOTE: I still have not implemented the full API yet, but I'm working on it.

QUICK START

const lifx  =  require('lifx-zero');
lifx.setToken('cf7348414176e9539b0678ab8c77b2d3c27a8a062c00094b325ce054dIAMFAKE');

//List all of your lights in JSON
var list = lifx.list.full();
list.then(function(data){
	console.log(data);
})

INSTALL

Using GIT

git clone https://github.com/matdombrock/lifx-zero.git

Using NPM

npm install lifx-zero

NOTE: The project is currently at @mdombrock/lifx-zero because of temporary publishing issues.

SETUP

To get started, just require the API wrapper and set your Auth Token.

From GIT

const lifx  =  require('./lifxWrapper');
lifx.setToken('cf7348414176e9539b0678ab8c77b2d3c27a8a062c00094b325ce054dIAMFAKE');

From NPM

const lifx  =  require('api-red');
lifx.setToken('cf7348414176e9539b0678ab8c77b2d3c27a8a062c00094b325ce054dIAMFAKE');

METHODS

setToken

setToken(<token>);

Example

lifx.setToken('cf7348414176e9539b0678ab8c77b2d3c27a8a062c00094b325ce054dIAMFAKE');

Arguments


list.full

list.full(<selector>);

Example

//List All Lights
var list = lifx.list.full();
list.then(function(data){
	console.log(data);
})
//List A Specific Light
var specific = lifx.list.full("My Light");
specific.then(function(data){
	console.log(data);
})

Example Object

{
	id: 'd0FAKE2cFAKE',
	uuid: '0230f455-FAKE-492c-af6d-de7a922fFAKE',
	label: 'Overhead',
	connected: true,
	power: 'on',
	color: { hue: 0, saturation: 1, kelvin: 3500 },
	brightness: 0.49999237048905165,
	effect: 'OFF',
	group: { id: '0ccdFAKE2c07c5af81da4b58b523FAKE', name: 'Mats Office' },
	location: { id: '9f0f6bFAKE29ad81bfFAKEa2a69dFAKE', name: 'Home' },
	product: {
		name: 'LIFX A19',
		identifier: 'lifx_a19',
		company: 'LIFX',
		capabilities: [Object]
	},
	last_seen: '2019-06-18T12:46:47Z',
	seconds_since_seen: 2
}

Arguments


power.on

power.on(<selector>);

Example

lifx.power.on();

Arguments


power.off

power.off(<selector>);

Example

lifx.power.off();

Arguments


power.toggle

power.toggle(<selector>);

Example

lifx.power.toggle();

Arguments


state.full

state.full(<state>, <selector>);

Example

var newState = {
	"power": "on",
	"color": "blue saturation:0.5",
	"brightness": 0.5,
	"duration": 5,
}
lifx.state.full(newState);

Arguments


state.brightness

state.brightness(<brightness>, <selector>);

Example

lifx.state.brightness(0.5);

Arguments


state.color

state.color(<color>, <selector>);

Example

lifx.state.color("red");

Arguments

RETURNING DATA

This wrapper uses "promises". Here is an example of how to return the response from the light to your main app.

const lifx  =  require('lifx-zero');
lifx.setToken('cf7348414176e9539b0678ab8c77b2d3c27a8a062c00094b325ce054dIAMFAKE');
//setup the promise
var newColor = lifx.state.color();
//follow through with the promise
newColor.then(function(data){
	console.log(data);
})

INTERACTIVE MODE

I have created an NPM script for "Interactive Mode". This loads the wrapper module and sets your key.
To enter "Interactive Mode" run:

FROM GITHUB

npm run interactive

FROM NPM

cd node_modules/lifx-zero
npm run interactive

NOTE: Make sure you create a .env file set the token value or this will not work. See .env.example. If you installed this module through NPM, you will need to create the .env file inside of the ./node_modules/lifx-zero subdirectory.