{"id":21331147,"url":"https://github.com/netbeast/react-native-lifx","last_synced_at":"2025-07-12T09:31:32.969Z","repository":{"id":57338043,"uuid":"65382980","full_name":"netbeast/react-native-lifx","owner":"netbeast","description":"React native wrapper around node-lifx library","archived":false,"fork":false,"pushed_at":"2018-01-29T16:55:52.000Z","size":60,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-28T14:16:32.704Z","etag":null,"topics":["client-sdk","discovery","light","react-native"],"latest_commit_sha":null,"homepage":"https://getyeti.co","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/netbeast.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-10T13:02:14.000Z","updated_at":"2018-06-02T20:02:11.000Z","dependencies_parsed_at":"2022-09-10T02:51:35.305Z","dependency_job_id":null,"html_url":"https://github.com/netbeast/react-native-lifx","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/netbeast/react-native-lifx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netbeast%2Freact-native-lifx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netbeast%2Freact-native-lifx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netbeast%2Freact-native-lifx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netbeast%2Freact-native-lifx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netbeast","download_url":"https://codeload.github.com/netbeast/react-native-lifx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netbeast%2Freact-native-lifx/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264972148,"owners_count":23691375,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client-sdk","discovery","light","react-native"],"created_at":"2024-11-21T22:29:36.603Z","updated_at":"2025-07-12T09:31:32.668Z","avatar_url":"https://github.com/netbeast.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LIFX Node.js Library\n\n[![NPM Version](https://img.shields.io/npm/v/node-lifx.svg)](https://www.npmjs.com/package/node-lifx)\n[![Build Status](https://img.shields.io/travis/MariusRumpf/node-lifx/master.svg)](https://travis-ci.org/MariusRumpf/node-lifx)\n[![Build status](https://img.shields.io/appveyor/ci/MariusRumpf/node-lifx/master.svg)](https://ci.appveyor.com/project/MariusRumpf/node-lifx)\n[![Dependency Status](https://img.shields.io/versioneye/d/nodejs/node-lifx.svg)](https://www.versioneye.com/nodejs/node-lifx/)\n[![Inline docs](https://inch-ci.org/github/mariusrumpf/node-lifx.svg?branch=master)](https://inch-ci.org/github/mariusrumpf/node-lifx)\n[![codecov.io](https://img.shields.io/codecov/c/github/MariusRumpf/node-lifx/master.svg)](https://codecov.io/github/MariusRumpf/node-lifx?branch=master)\n\n\nA Node.js implementation of the [LIFX protocol](https://github.com/LIFX/lifx-protocol-docs). Developed to work with a minimum firmware version of 2.0.\n\nThis library is not, in any way, affiliated or related to LiFi Labs, Inc.. Use it at your own risk.\n\n## Installation\n\n```sh\n$ npm install node-lifx --save\n```\n\n## Compatibility\n\nNode.js 0.12+ and io.js are tested and supported on Mac, Linux and Windows.\n\n## Usage\nThe file `cli.js` contains a working example.\n\n### Client\nThe library uses a client for network communication. This client handles communication with all lights in the network.\n```js\nvar LifxClient = require('node-lifx').Client;\nvar client = new LifxClient();\n\nclient.init();\n```\nThe `Client` object is an EventEmitter and emmits events whenever any changes occur. This can be a new light discovery, a light sending a message or similar.  \nThe client starts discovery of lights right after it is initialized with the `init` method. If a new light is found the client emmits a `light-new` event. This event contains the light as an object on which methods can be called then:\n\n```js\nvar LifxClient = require('node-lifx').Client;\nvar client = new LifxClient();\n\nclient.on('light-new', function(light) {\n  // Change light state here\n});\n\nclient.init();\n```\n\n### Changing light state\nThe states of a light can be changed with different methods:\n\n#### `light.on([duration], [callback])`\nThis turns a light on.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`duration` | int | 0 | Turning on will be faded over the time (in milliseconds).\n`callback` | function | null | `function(error) {}` Called after the command has reached the light or after `client.resendMaxTimes` with `client.resendPacketDelay` in case it has not. `error` is `null` in case of success and given if the sending has failed.\n_Note: Using callback multiplies network load for this command by two or more times._\n\nUsage examples:\n```js\nlight.on(); // Turns the light on instantly\nlight.on(2000); // Fading the light on over two seconds\n```\n\n#### `light.off([duration], [callback])`\nThis turns a light off.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`duration` | int | 0 | Turning off will be faded over the time (in milliseconds).\n`callback` | function | null | `function(error) {}` Called after the command has reached the light or after `client.resendMaxTimes` with `client.resendPacketDelay` in case it has not. `error` is `null` in case of success and given if the sending has failed.\n_Note: Using callback multiplies network load for this command by two or more times._\n\nUsage examples:\n```js\nlight.off(); // Turns the light off instantly\nlight.off(2000); // Fading the light off over two seconds\n```\n\n#### `light.color(hue, saturation, brightness, [kelvin], [duration], [callback])`\nChanges the color off a light.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`hue` | int | | Between 0 and 360, representing the color hue in degree which changes the color.\n`saturation` | int | | Between 0 and 100, representing the color intensity from 0% to 100%.\n`brightness` | int | | Between 0 and 100, representing the light brightness from 0% to 100%.\n`kelvin` | int | 3500 | Between 2500 and 9000, representing the color temperature.\n`duration` | int | 0 | Fade the color to the new value over time (in milliseconds).\n`callback` | function | null | `function(error) {}` Called after the command has reached the light or after `client.resendMaxTimes` with `client.resendPacketDelay` in case it has not. `error` is `null` in case of success and given if the sending has failed.\n_Note: Using callback multiplies network load for this command by two or more times._\n\nUsage examples:\n```js\nlight.color(0, 100, 50); // Set to red at 50% brightness\nlight.color(50, 50, 80, 3500, 2000); // Set to a light green at 80% brightness over next two seconds\n```\n\n### Requesting light state and info\nInfos of the state and spec of the light can be requested with the following methods:\n\n#### `light.getState(callback)`\nRequests general info from a light, this includes color, label and power state. This function is asynchronous.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`callback` | function | | `function(error, data) {}`\n\nExample result:\n```js\nnull,\n{\n  color: { hue: 120, saturation: 0, brightness: 100, kelvin: 8994 },\n  power: 0,\n  label: 'Kitchen'\n}\n```\n\n#### `light.getPower(callback)`\nRequests current power state (on or off). This function is asynchronous.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`callback` | function | | `function(error, data) {}`\n\nExample result:\n```js\nnull,\n0 // off\n```\n\n#### `light.getFirmwareVersion(callback)`\nRequests the firmware version from a light (minor and major version). This function is asynchronous.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`callback` | function | | `function(error, data) {}`\n\nExample result:\n```js\nnull,\n{\n  majorVersion: 2,\n  minorVersion: 1\n}\n```\n\n#### `light.getHardwareVersion(callback)`\nRequests the hardware version from a light (vendor, product and version). This function is asynchronous.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`callback` | function | | `function(error, data) {}`\n\nExample result:\n```js\nnull,\n{\n  vendorId: 1,\n  vendorName: 'LIFX',\n  productId: 1,\n  productName: 'Original 1000',\n  version: 6\n}\n```\n\n#### `light.getFirmwareInfo(callback)`\nRequests info from the micro controller unit of a light (signal, tx and rx). This function is asynchronous.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`callback` | function | | `function(error, data) {}`\n\nExample result:\n```js\nnull,\n{\n  signal: 0,\n  tx: 0,\n  rx: 0\n}\n```\n\n#### `light.getWifiInfo(callback)`\nRequests wifi info from a light (signal, tx and rx). This function is asynchronous.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`callback` | function | | `function(error, data) {}`\n\nExample result:\n```js\nnull,\n{\n  signal: 0.000009999999747378752,\n  tx: 16584,\n  rx: 12580\n}\n```\n\n#### `light.getWifiVersion(callback)`\nRequests the wifi firmware version from the light (minor and major version). This function is asynchronous.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`callback` | function | | `function(error, data) {}`\n\nExample result:\n```js\nnull,\n{\n  majorVersion: 2,\n  minorVersion: 1\n}\n```\n\n#### `light.getAmbientLight(callback)`\nRequests the ambient light value in flux from the light. This function is asynchronous.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`callback` | function | | `function(error, data) {}`\n\n\nExample result:\n```js\nnull,\n10\n```\n\n### Labels\nLabels of lights can be requested and set using the following methods:\n\n#### `light.getLabel(callback, [cache])`\nRequests the label of a light. This function is asynchronous.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`callback` | function | | `function(error, data) {}`\n`cache`    | boolean  | false | Use the last known value for the label and and do not request from the light again\n\nExample result:\n```js\nnull,\n'Kitchen'\n```\n\n#### `light.setLabel(label, [callback])`\nSets a new label for a light.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`label` | string | | New Label with 32 bit size maximum (which is a length of 32 with non unicode chars).\n`callback` | function | null | `function(error) {}` Called after the command has reached the light or after `client.resendMaxTimes` with `client.resendPacketDelay` in case it has not. `error` is `null` in case of success and given if the sending has failed.\n_Note: Using callback multiplies network load for this command by two or more times._\n\n\nUsage examples:\n```js\nlight.setLabel('Bedroom Light');\nlight.setLabel('Kitchen Light 4', function(err) {\n  if (err) { throw err; }\n  console.log('New light label has been set');\n});\n```\n\n### Get a light\n#### `client.light(identifier)`\nFind a light in the list off all lights by ip, label or id.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`identifier` | string | | Light label (case sensitive) `client.light('Kitchen')`, the ip address `client.light('192.168.2.102')` or the light id `client.light('0123456789012')`\n\nReturns a light object that can then be used to call methods on it. For example `client.light('192.168.2.102').on()`.\n\n### Get all lights\n\n#### `client.lights([filter])`\nGet a list of all known lights\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`filter` | string | null | Filter list of lights to return only active (`null` or `'on'`), inactive (`'off'`) or all (`''`)\n\n### Client events\nThe following events might be thrown by the client.\n\n#### `light-new`\nThis event is thrown when there is a new light discovery that has not been seen at runtime before. This event is provided with the new light object.  \n`client.on('light-new', function(light) {});`\n\n#### `light-offline`\nThis event is thrown when a light hasn't been discovered for a time. The light given is no longer expected to be reachable.  \n`client.on('light-offline', function(light) {});`\n\n#### `light-online`\nThis event is thrown when a light is discovered again after being offline.  \n`client.on('light-online', function(light) {});`\n\n### Start / Stop discovery\nThe discovery for each client can be started and stopped at runtime using these commands:\n\n#### `client.startDiscovery()`\nStarts the discovery process.\n\n#### `client.stopDiscovery()`\nStops the discovery process.\n\n### Client settings\nFor the initialization of the client different settings can be provided. This is an example with the default options:\n\n```js\nvar LifxClient = require('node-lifx').Client;\nvar client = new LifxClient();\n\n// ...\n\nclient.init({\n  lightOfflineTolerance: 3, // A light is offline if not seen for the given amount of discoveries\n  messageHandlerTimeout: 45000, // in ms, if not answer in time an error is provided to get methods\n  startDiscovery: true, // start discovery after initialization\n  resendPacketDelay: 150, // delay between packages if light did not receive a packet (for setting methods with callback)\n  resendMaxTimes: 3, // resend packages x times if light did not receive a packet (for setting methods with callback)\n  debug: false, // logs all messages in console if turned on\n  address: '0.0.0.0', // the IPv4 address to bind the udp connection to\n  broadcast: '255.255.255.255', // set's the IPv4 broadcast address which is addressed to discover bulbs\n  lights: [] // Can be used provide a list of known light IPv4 ip addresses if broadcast packets in network are not allowed\n             // For example: ['192.168.0.112', '192.168.0.114'], this will then be addressed directly\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetbeast%2Freact-native-lifx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetbeast%2Freact-native-lifx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetbeast%2Freact-native-lifx/lists"}