{"id":15011195,"url":"https://github.com/johncwaters/lifx-node-wrapper","last_synced_at":"2026-04-26T12:31:50.207Z","repository":{"id":57701600,"uuid":"504968975","full_name":"johncwaters/lifx-node-wrapper","owner":"johncwaters","description":"Node.js LIFX HTTP Lights API Wrapper","archived":false,"fork":false,"pushed_at":"2022-07-25T02:17:28.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-04T06:36:43.530Z","etag":null,"topics":["api-rest","javascript","lifx","lights","nodejs"],"latest_commit_sha":null,"homepage":"","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/johncwaters.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":"2022-06-18T23:12:40.000Z","updated_at":"2022-06-20T02:31:40.000Z","dependencies_parsed_at":"2022-08-29T04:31:47.235Z","dependency_job_id":null,"html_url":"https://github.com/johncwaters/lifx-node-wrapper","commit_stats":null,"previous_names":["otzolive/lifx-node-wrapper"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/johncwaters/lifx-node-wrapper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johncwaters%2Flifx-node-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johncwaters%2Flifx-node-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johncwaters%2Flifx-node-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johncwaters%2Flifx-node-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johncwaters","download_url":"https://codeload.github.com/johncwaters/lifx-node-wrapper/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johncwaters%2Flifx-node-wrapper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32297893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T09:34:17.070Z","status":"ssl_error","status_checked_at":"2026-04-26T09:34:00.993Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["api-rest","javascript","lifx","lights","nodejs"],"created_at":"2024-09-24T19:39:39.972Z","updated_at":"2026-04-26T12:31:50.189Z","avatar_url":"https://github.com/johncwaters.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lifx-node-wrapper\n\nNode.js LIFX HTTP Lights API Wrapper\n\n## Features\n\n- Promise based REST API wrapper\n- Easy access to API responses\n- Supports most LIFX HTTP API endpoints (more to be added)\n- Uses Axios as only dependency\n\n## Installation\n\nInstall lifx-node-wrapper with npm:\n\n```bash\n $ npm install lifx-node-wrapper\n```\n\nTo run this project, you will need a LIFX HTTP API key.\nGet your key here: https://api.developer.lifx.com/docs/authentication\n\n## Usage\n\n#### Getting started\n\n```javascript\nimport Lifx from \"lifx-node-wrapper\";\n\n//create instance with our Lifx Token\nvar lifx = new Lifx(LIFX_KEY);\n\n//lifx.\u003cmethod\u003e will now always use the key provided\n```\n\n#### Get list of all lights\n\nMost functions require a `selector` to determine which lights to control. To stay consistent and avoid the package breaking, the wrapper uses [standard LIFX selectors](https://api.developer.lifx.com/docs/selectors) laid out in their documentation.\n\n```javascript\nvar lights = await lifx.ListLights(\"all\");\nconsole.log(lights.data);\n\n//OR\n\nlifx\n  .ListLights(\"all\")\n  //grab returned data\n  .then((data) =\u003e {\n    //handle data\n    console.log(data);\n  })\n  .catch((err) =\u003e\n    //handle errors\n    console.log(err)\n  );\n```\n\n#### Not using a parameter in a function\n\nIf you don't need a certain parameter, fill the spot with `undefined`. Note: `selector` and `power` are required if they are part of the function.\n\n```javascript\nlifx.SetState(\"group_id:6a2e3...\", \"on\", undefined, 6.0, undefined, true);\n```\n\nYou do not have to list `undefined` in every unused parameter.\n\n```javascript\nlifx.SetState(\"group_id:6a2e3...\", \"on\");\n```\n\n## API Reference\n\n#### Get all items\n\n### `lifx.ListLights()`\n\n| Parameter  | Type     | Example | Description  |\n| :--------- | :------- | :------ | :----------- |\n| `selector` | `string` | 'all'   | **Required** |\n\nReturns all available lights and their unique selectors. It's recommended to use their unique ID's instead of names like \"Living Room\" since the ID's will never change.\n\nExample response converted to JSON:\n\n```json\n[\n  {\n    \"id\": \"d07...949\",\n    \"uuid\": \"029...609d\",\n    \"label\": \"Office Light\",\n    \"connected\": true,\n    \"power\": \"off\",\n    \"color\": {\n      \"hue\": 0,\n      \"saturation\": 0,\n      \"kelvin\": 2000\n    },\n    \"brightness\": 0.3,\n    \"group\": {\n      \"id\": \"e1ad...537\",\n      \"name\": \"Office\"\n    },\n    \"location\": {\n      \"id\": \"fd599...08350\",\n      \"name\": \"Home\"\n    },\n    \"product\": {\n      \"name\": \"LIFX Mini Day and Dusk\",\n      \"identifier\": \"lifx_mini_day_and_dusk2\",\n      \"company\": \"LIFX\",\n      \"vendor_id\": 1,\n      \"product_id\": 60,\n      \"capabilities\": {\n        \"has_color\": false,\n        \"has_variable_color_temp\": true,\n        \"has_ir\": false,\n        \"has_hev\": false,\n        \"has_chain\": false,\n        \"has_matrix\": false,\n        \"has_multizone\": false,\n        \"min_kelvin\": 1500,\n        \"max_kelvin\": 4000\n      }\n    },\n    \"last_seen\": \"2022-06-19T02:50:56Z\",\n    \"seconds_since_seen\": 0\n  }\n]\n```\n\n### `lifx.SetState()`\n\n| Parameter    | Type      | Example              | Description       |\n| :----------- | :-------- | :------------------- | :---------------- |\n| `selector`   | `string`  | 'group_id:6a2e3b...' | **Required**      |\n| `power`      | `string`  | 'on'                 | **Required**      |\n| `color`      | `string`  |                      |                   |\n| `brightness` | `double`  | 0.1                  |                   |\n| `duration`   | `double`  | 1.0                  | Defaults to 1.0   |\n| `infared`    | `double`  | '0.5'                |                   |\n| `fast`       | `boolean` | false                | Defaults to false |\n\n### `lifx.TogglePower()`\n\n| Parameter  | Type     | Example        | Description  |\n| :--------- | :------- | :------------- | :----------- |\n| `selector` | `string` | 'id:3a9b0x...' | **Required** |\n\nTurn off lights if any of them are on, or turn them on if they are all off.\n\n### `lifx.ListScenes()`\n\nLists all scenes associated with the API Key provided.\n\nExample response converted to JSON:\n\n```json\n[\n  {\n    \"uuid\": \"1b3a...s3451\",\n    \"name\": \"Night Time\",\n    \"account\": {\n      \"uuid\": \"435dza...5182z\"\n    },\n    \"states\": [\n      {\n        \"selector\": \"id:d07...ee46\",\n        \"power\": \"on\",\n        \"brightness\": 0.1297,\n        \"color\": {\n          \"hue\": 350.6141,\n          \"saturation\": 1,\n          \"kelvin\": 3500\n        }\n      }\n    ],\n    \"created_at\": 1639715780,\n    \"updated_at\": 1652936342\n  }\n]\n```\n\n### `lifx.ActivateScene()`\n\n| Parameter   | Type      | Example              | Description                  |\n| :---------- | :-------- | :------------------- | :--------------------------- |\n| `selector`  | `string`  | 'scene_id:6a2e3b...' | **Required**                 |\n| `duration`  | `double`  | 1.0                  | Defaults to 1.0              |\n| `ignore`    | `array`   |                      | **This has not been tested** |\n| `overrides` | `array`   |                      | **This has not been tested** |\n| `fast`      | `boolean` | false                | Defaults to false            |\n\n## Examples\n\n#### Turn on a group of lights over 10 seconds with fast mode enabled\n\n```javascript\nlifx.SetState('group_id:6a2e3...', 'on', undefined, 10.0, undefined, true)\n\n//OR\n\n//Note: no response is given in fast mode\nlifx.SetState('group_id:6a2e3...', 'on', undefined, 10.0, undefined, true)\n    .catch(err =\u003e\n        //handle errors\n    );\n```\n\n#### Toggle all lights off/on\n\n```javascript\nlifx.TogglePower('group_id:6a2e3...', 'on')\n\n//OR\n\nlifx.TogglePower('group_id:6a2e3...', 'on')\n    //grab returned data\n    .then(data =\u003e {\n        //handle data\n    })\n    .catch(err =\u003e\n        //handle errors\n    );\n```\n\n#### Activate a scene that was previously set-up in the LIFX app\n\n```javascript\nlifx.ActivateScene('scene_id:1c4d3c7...338fa9', 1.0)\n\n//OR\n\nlifx.ActivateScene('scene_id:1c4d3c7...338fa9', 1.0)\n    //grab returned data\n    .then(data =\u003e {\n        //handle data\n    })\n    .catch(err =\u003e\n        //handle errors\n    );\n```\n\n## Future Goals\n\n- Add remaining API Endpoints\n\n- Add additional error handling to improve usability\n\n- Implement automated tests / checks using jest\n\n- Remove Axios as dependency and add custom fetch function instead\n\n## Related\n\nInspired by other related projects:\n\n[ywadi/lifx](https://github.com/ywadi/lifx)\n\n[thanoskrg/lifxjs](https://github.com/thanoskrg/lifxjs)\n\n## 📖 Feedback\n\nI wrote this wrapper to use in my personal project to control my apartments smart devices through a custom Telegram Bot. LIFX lights had several nodejs libraries available, but few were up to date.\n\nMy goal was to not only to reduce outside dependencies in my own projects, but also make the API easier to use for others.\n\nWriting this wrapper introduced me to javascript prototypes, classes, publishing NPM packages, and exporting/importing ES modules. Now to update my Telegram Bot to support this module...\n\nAny and all feedback is appreciated.\n\n### 🔗 Links\n\n[![telegram](https://img.shields.io/badge/Telegram-%40OtzoLive-blue?style=flat-square\u0026logo=telegram)](https://t.me/OtzoLive/)\n[![twitter](https://img.shields.io/badge/Twitter-%40OtzoLive-blue?style=flat-square\u0026logo=twitter)](https://twitter.com/OtzoLive/)\n[![wakatime](https://wakatime.com/badge/user/7a991802-ef44-4138-9f49-6e4ab5ccfd96/project/4b86aa02-792d-406d-9c71-7cea3b77d57b.svg?style=flat-square)](https://wakatime.com/badge/user/7a991802-ef44-4138-9f49-6e4ab5ccfd96/project/4b86aa02-792d-406d-9c71-7cea3b77d57b)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohncwaters%2Flifx-node-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohncwaters%2Flifx-node-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohncwaters%2Flifx-node-wrapper/lists"}