@mdombrock/lifx-zero

1.0.6 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @mdombrock/lifx-zero

Weekly Downloads

0

Version

1.0.6

License

GPL 3

Unpacked Size

47.7 kB

Total Files

7

Last publish

Collaborators

  • mdombrock