REST client for the Lifx's API; each method of
ya-lifx
return a promise which resolve with the API's response;
use npm
to install the lib on you proyect;
npm install ya-lifx
You'll need a valid Lifx's token to use the lib; generate it from https://cloud.lifx.com/settings
var lifx = require('ya-lifx');
lifx.init('YOUR_TOKEN');
lifx.listLights()
.then(function(response){
console.log(response);
console.log('API Limits ', lifx.apiLimits());
})
.catch(function(err){
console.log('Error');
console.log(err.error);
console.log(err.warnings);
});
The available methods of the lib are:
init
: set the Lifx's tokenlistLights
: Gets lights belonging to the authenticated account.listScenes
: Lists all the scenes available in the users accountvalidateColor
: Validate a user's color string and return the hue, saturation brightness and kelvin values that the API will interpret as.setState
: Sets the state of the lights within the selector.activateScene
: Activates a scene from the users account.toggle
: Turn off lights if they are on, or turn them on if they are off.breathe
: Performs a breathe effect by slowly fading between the given colors.pulse
: Performs a pulse effect by quickly flashing between the given colors.cycle
: Make the light(s) cycle to the next or previous state in a list of states.apiRateLimits
: Return the Rate limit from the previous call.Please referer to Errors documentation for more information.
Inspired by pifx