{"id":16965306,"url":"https://github.com/magicmonkey/lifxjs","last_synced_at":"2025-04-05T21:07:42.101Z","repository":{"id":12363350,"uuid":"15012567","full_name":"magicmonkey/lifxjs","owner":"magicmonkey","description":"JS library for LIFX bulbs","archived":false,"fork":false,"pushed_at":"2016-12-04T20:28:20.000Z","size":1056,"stargazers_count":274,"open_issues_count":14,"forks_count":62,"subscribers_count":40,"default_branch":"master","last_synced_at":"2025-03-29T19:07:57.928Z","etag":null,"topics":[],"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/magicmonkey.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":"2013-12-07T20:42:00.000Z","updated_at":"2024-10-31T12:46:53.000Z","dependencies_parsed_at":"2022-09-23T05:50:47.913Z","dependency_job_id":null,"html_url":"https://github.com/magicmonkey/lifxjs","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicmonkey%2Flifxjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicmonkey%2Flifxjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicmonkey%2Flifxjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicmonkey%2Flifxjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magicmonkey","download_url":"https://codeload.github.com/magicmonkey/lifxjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399877,"owners_count":20932876,"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":[],"created_at":"2024-10-13T23:45:38.464Z","updated_at":"2025-04-05T21:07:42.083Z","avatar_url":"https://github.com/magicmonkey.png","language":"JavaScript","readme":"# JS library for LIFX bulbs\n\nA NodeJS client for the [LIFX bulbs](http://lifx.co) based on my observations\nof the network protocol using tcpdump and Wireshark.  This is very much\nexperimental, so is most likely incorrect or inaccurate, although it seems to\nwork for me.  You have been warned.  Observations are documented in\n[Protocol.md](Protocol.md).\n\nThis is based on my setup of 2 bulbs in a single group.  That may or may not\naffect the network protocol.  Also, I've not looked at how the bulbs are\ninitially setup to hop onto your wireless network; I configured mine with the\niPhone app, and this library is (currently) for manipulating the bulbs once\nthey are already attached to your network.\n\n_Bonus: There's a demo web app in the \"web\" dir which just displays a colour\n        picker and sets the bulbs to the chosen colour, and a demo mqtt bridge\n        in the \"mqtt\" dir which bridges between an MQTT broker and the bulbs_\n\n## Install\n\nTo install from NPM, do ```npm install lifx```, or just clone the github repo\n(but you'll need to run ```npm install``` in this dir to get the \"clone\"\ndependency if you get from github).\n\nIf you install form NPM, then do ```require(\"lifx\");```.  If you cloned the\ngithub repo then you'll need to do something like ```require(\"./lifx\");``` (ie\nspecify the path to the dir you cloned into).\n\nIf you want to run the web or mqtt app, you also need to run ```npm install```\nin the respective dir to get their dependencies.\n\n## Files\n\nThere is 1 main file (lifx.js) which is all you need plus some example CLI\napps:\n\n  * cli.js which is an example CLI app using the library\n  * cli2.js which lets you cycle through individual parameters to get a feel\n    for what they mean\n  * cli3.js controls individual bulbs\n\nMy observations of the network protocol are documented in [this\ndoc](Protocol.md).  Hopefully LIFXLabs will release an official spec for the\nnetwork protocol which will make this a lot easier.\n\n## Usage\n\nThe file [cli.js](cli.js) is a working example.\n\nIn addition to the main \"Lifx\" object which acts as your agent to the Lifx\nbulbs, there are 2 fundamental objects in the library; a \"gateway\" object which\nrepresents the wifi interface (and can do things like discovery of the other\nbulbs, send messages to a bulb etc) and a \"bulb\" object which is useful for\nsending commands to individual bulbs.\n\nTo begin with, you must include the library and then call ```lifx.init()```\nwhich will return a new ```Lifx``` object and initialise discovery of gateways\nand bulbs.\n\n```JavaScript\nvar lifx = require('./lifx');\nvar lx   = lifx.init();\n```\n\nThe Lifx object is an EventEmitter, and emits a \"bulb\" event whenever a new bulb\nis found and a \"gateway\" event whenever a new gateway is found.  Note that\nmultiple bulbs can be acting as gateways on your network, especially if they\nhaven't yet formed their mesh network.\n\nOnce you have the Lifx object, you can use it to send commands to all of the\nbulbs in the mesh network:\n\n```Javascript\nlx.lightsOn();\nlx.lightsOff();\nlx.lightsColour(hue,    saturation, luminance, whiteColour, fadeTime);\nlx.lightsColour(0xd49e, 0xffff,     0x028f,    0x0dac,      0x0513);\n```\n\nor to target an individual bulb, pass an optional parameter:\n\n```Javascript\nvar bulb = lx.bulbs[0];\nlx.lightsOn(bulb);\nlx.lightsOff(bulb);\nlx.lightsColour(hue,    saturation, luminance, whiteColour, fadeTime, bulb);\nlx.lightsColour(0xd49e, 0xffff,     0x028f,    0x0dac,      0x0513,   bulb);\n```\n\nThe params are always 16-bit numbers, which get their bytes shuffled around\nbefore being sent over the network (see the [protocol](Protocol.md) doc for the\nunderlying details).\n\n* hue represents the colour to use, and is manipulated by the colour wheel in\n  the iPhone app.\n* saturation represents how much of the colour to use, and is generally either\n  0xffff (if using the \"Colors\" screen in the iPhone app) or 0x0000 (if using\n  the \"Whites\" screen in the iPhone app).\n* luminance is how bright the bulbs should be.\n* whiteColour is something like the colour temperatue, and is the wheel used in\n  the \"Whites\" screen in the iPhone app.\n* fadeTime says how quickly the bulbs should move to the given state, and seem\n  to roughly be in milliseconds.  Use 0 for an immediate change.\n\nThe \"packet.js\" module constructs each raw packet type, which can be sent to all\nbulbs using something like ```lx.sendToAll(packet.getLightState())```.\nSimilarly, to send a raw command to an individual bulb, use\n```lx.sendToOne(packet.getLightState(), bulb)``` passing in a bulb object from\nthe lx.bulbs array.\n\nIf you want to see debug messages (including network traffic) then call\n\n```JavaScript\nlifx.setDebug(true);\n```\n\n## Wireshark dissector\n\nThere is a wireshark dissector for the LIFX protocol in the \"wireshark\"\ndirectory.  To load it, run Wireshark with:\n\n```\n/path/to/wireshark -X lua_script:/path/to/lifx.lua\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicmonkey%2Flifxjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagicmonkey%2Flifxjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicmonkey%2Flifxjs/lists"}