{"id":21331164,"url":"https://github.com/netbeast/react-native-tplink-bulb","last_synced_at":"2026-05-15T20:31:53.213Z","repository":{"id":147464944,"uuid":"96122766","full_name":"netbeast/react-native-tplink-bulb","owner":"netbeast","description":":bulb: A react native translation ot tplink for node.js used in Yeti Smart Home","archived":false,"fork":false,"pushed_at":"2018-10-09T07:47:55.000Z","size":98,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-07-13T01:10:15.326Z","etag":null,"topics":["iot","react-native","smart-home","tplink"],"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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-03T15:01:34.000Z","updated_at":"2022-07-26T16:59:20.000Z","dependencies_parsed_at":"2023-07-24T18:30:07.247Z","dependency_job_id":null,"html_url":"https://github.com/netbeast/react-native-tplink-bulb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/netbeast/react-native-tplink-bulb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netbeast%2Freact-native-tplink-bulb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netbeast%2Freact-native-tplink-bulb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netbeast%2Freact-native-tplink-bulb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netbeast%2Freact-native-tplink-bulb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netbeast","download_url":"https://codeload.github.com/netbeast/react-native-tplink-bulb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netbeast%2Freact-native-tplink-bulb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33078898,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T20:25:35.270Z","status":"ssl_error","status_checked_at":"2026-05-15T20:25:34.732Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["iot","react-native","smart-home","tplink"],"created_at":"2024-11-21T22:29:45.813Z","updated_at":"2026-05-15T20:31:53.195Z","avatar_url":"https://github.com/netbeast.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"http://s7d1.scene7.com/is/image/officedepot/945143_p_lb120_white_3?$OD-Dynamic$\u0026wid=200\u0026hei=200\" align=\"right\" alt=\"tested with LB120\" /\u003e\n\n# tplink-lightbulb\nControl TP-Link smart lightbulbs from nodejs\n\n[![NPM](https://nodei.co/npm/tplink-lightbulb.png?compact=true)](https://nodei.co/npm/tplink-lightbulb/)\n\nThis will allow you to control TP-Link smart lightbulbs from nodejs or the command-line. I have only tested with [LB120](http://www.tp-link.com/us/products/details/cat-5609_LB120.html) bulbs, and am eager to add support for more, so send a PR, or even just a pcap file of network traffic to add support for your lightbulb.\n\n## command-line\n\nYou can install it for your system with this:\n\n```\nnpm i -g tplink-lightbulb\n```\n\nNow, you can use it like this:\n\n```\nUsage: tplight \u003cCOMMAND\u003e\n\nCommands:\n  scan                                      Scan for lightbulbs\n  on \u003cip\u003e                                   Turn on lightbulb\n  off \u003cip\u003e                                  Turn off lightbulb\n  temp \u003cip\u003e \u003ccolor\u003e                         Set the color-temperature of the\n                                            lightbulb (for those that support\n                                            it)\n  hex \u003cip\u003e \u003ccolor\u003e                          Set color of lightbulb using hex\n                                            color (for those that support it)\n  hsb \u003cip\u003e \u003chue\u003e \u003csaturation\u003e \u003cbrightness\u003e  Set color of lightbulb using HSB\n                                            color (for those that support it)\n  cloud \u003cip\u003e                                Get cloud info\n  raw \u003cip\u003e \u003cjson\u003e                           Send a raw JSON command\n  details \u003cip\u003e                              Get details about the device\n\nOptions:\n  -?, --help  Show help                                                [boolean]\n\nExamples:\n  tplight scan -?     Get more detailed help with `scan` command\n  tplight on -?       Get more detailed help with `on` command\n  tplight off -?      Get more detailed help with `off` command\n  tplight temp -?     Get more detailed help with `temp` command\n  tplight hex -?      Get more detailed help with `hex` command\n  tplight hsb -?      Get more detailed help with `hsb` command\n  tplight cloud -?    Get more detailed help with `cloud` command\n  tplight raw -?      Get more detailed help with `raw` command\n  tplight details -?  Get more detailed help with `details` command\n```\n\n## wireshark\n\nIf you want to analyze the protocol, you can use the included `tplink-smarthome.lua`.\n\nInstall in the location listed in About Wireshark/Folders/Personal Plugins\n\nI captured packets with tcpdump running on a [raspberry pi pretending to be a router](https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point?view=all). In general, this is a really useful way to capture IOT protocols and mess around with them.\n\nI ssh'd into my pi, ran `sudo apt update \u0026\u0026 sudo apt install tcpdump`, then `tcpdump -i wlan0 -w lights.pcap`\n\nI connected the lights to that network (reset them to factory default by turning the power off/on 5 times, then configure in Kasa app.)\n\nAfter I did stuff like switch the lights on/off in app, I open the pcap file in wireshark on my desktop.\n\n## library\n\nYou can install it in your project like this:\n\n```\nnpm i -S tplink-lightbulb\n```\n\nInclude it in your project like this:\n\n```js\nconst Bulb = require('tplink-lightbulb')\n```\n\nor for ES6:\n\n```js\nimport Bulb from 'tplink-lightbulb'\n```\n\n## API\n\n\u003cdl\u003e\n\u003cdt\u003e\u003ca href=\"#module_scan\"\u003escan\u003c/a\u003e ⇒ \u003ccode\u003eEventEmitter\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eScan for lightbulbs on your network\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#module_info\"\u003einfo\u003c/a\u003e ⇒ \u003ccode\u003ePromise\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eGet info about the Bulb\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#module_send\"\u003esend\u003c/a\u003e ⇒ \u003ccode\u003ePromise\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eSend a message to a lightbulb (for RAW JS message objects)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#module_set\"\u003eset\u003c/a\u003e ⇒ \u003ccode\u003ePromise\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eChange state of lightbulb\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#module_daystat\"\u003edaystat\u003c/a\u003e ⇒ \u003ccode\u003ePromise\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eGet schedule info\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#module_cloud\"\u003ecloud\u003c/a\u003e ⇒ \u003ccode\u003ePromise\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eGet cloud info from bulb\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#module_schedule\"\u003eschedule\u003c/a\u003e ⇒ \u003ccode\u003ePromise\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eGet schedule from bulb\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#module_details\"\u003edetails\u003c/a\u003e ⇒ \u003ccode\u003ePromise\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eGet operational details from bulb\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#module_encrypt\"\u003eencrypt\u003c/a\u003e ⇒ \u003ccode\u003eBuffer\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eBadly encrypt message in format bulbs use\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#module_decrypt\"\u003edecrypt\u003c/a\u003e ⇒ \u003ccode\u003eBuffer\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eBadly decrypt message from format bulbs use\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\n\u003ca name=\"module_scan\"\u003e\u003c/a\u003e\n\n## scan ⇒ \u003ccode\u003eEventEmitter\u003c/code\u003e\nScan for lightbulbs on your network\n\n**Returns**: \u003ccode\u003eEventEmitter\u003c/code\u003e - Emit `light` events when lightbulbs are found  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| filter | \u003ccode\u003estring\u003c/code\u003e | Only return devices with this class, (ie 'IOT.SMARTBULB') |\n\n**Example**  \n```js\n// turn first discovered light off\nconst scan = Bulb.scan()\n  .on('light', light =\u003e {\n    light.set(false)\n      .then(status =\u003e {\n        console.log(status)\n        scan.stop()\n      })\n  })\n```\n\u003ca name=\"module_info\"\u003e\u003c/a\u003e\n\n## info ⇒ \u003ccode\u003ePromise\u003c/code\u003e\nGet info about the Bulb\n\n**Returns**: \u003ccode\u003ePromise\u003c/code\u003e - Resolves to info  \n**Example**  \n```js\n// get info about a light\nconst light = new Bulb('10.0.0.200')\nlight.info()\n  .then(info =\u003e {\n    console.log(info)\n  })\n```\n\u003ca name=\"module_send\"\u003e\u003c/a\u003e\n\n## send ⇒ \u003ccode\u003ePromise\u003c/code\u003e\nSend a message to a lightbulb (for RAW JS message objects)\n\n**Returns**: \u003ccode\u003ePromise\u003c/code\u003e - Resolves with answer  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| msg | \u003ccode\u003eObject\u003c/code\u003e | Message to send to bulb |\n\n**Example**  \n```js\nconst light = new Bulb('10.0.0.200')\nlight.send({\n  'smartlife.iot.smartbulb.lightingservice': {\n    'transition_light_state': {\n      'on_off': 1,\n      'transition_period': 0\n    }\n})\n.then(response =\u003e {\n  console.log(response)\n})\n.catch(e =\u003e console.error(e))\n```\n\u003ca name=\"module_set\"\u003e\u003c/a\u003e\n\n## set ⇒ \u003ccode\u003ePromise\u003c/code\u003e\nChange state of lightbulb\n\n**Returns**: \u003ccode\u003ePromise\u003c/code\u003e - Resolves to output of command  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| power | \u003ccode\u003eBoolean\u003c/code\u003e | On or off |\n| transition | \u003ccode\u003eNumber\u003c/code\u003e | Transition to new state in this time |\n| options | \u003ccode\u003eObject\u003c/code\u003e | Object containing `mode`, `hue`, `saturation`, `color_temp`, `brightness` |\n\n**Example**  \n```js\n// turn a light on\nconst light = new Bulb('10.0.0.200')\nlight.set(true)\n  .then(status =\u003e {\n    console.log(status)\n  })\n  .catch(err =\u003e console.error(err))\n```\n\u003ca name=\"module_daystat\"\u003e\u003c/a\u003e\n\n## daystat ⇒ \u003ccode\u003ePromise\u003c/code\u003e\nGet schedule info\n\n**Returns**: \u003ccode\u003ePromise\u003c/code\u003e - Resolves to schedule info  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| month | \u003ccode\u003eNumber\u003c/code\u003e | Month to check: 1-12 |\n| year | \u003ccode\u003eNumber\u003c/code\u003e | Full year to check: ie 2017 |\n\n**Example**  \n```js\n// get the light's schedule for 1/2017\nconst light = new Bulb('10.0.0.200')\nlight.schedule(1, 2017)\n  .then(schedule =\u003e {\n    console.log(schedule)\n  })\n  .catch(e =\u003e console.error(e))\n```\n\u003ca name=\"module_cloud\"\u003e\u003c/a\u003e\n\n## cloud ⇒ \u003ccode\u003ePromise\u003c/code\u003e\nGet cloud info from bulb\n\n**Returns**: \u003ccode\u003ePromise\u003c/code\u003e - Resolves to cloud info  \n**Example**  \n```js\n// get the cloud info for the light\nconst light = new Bulb('10.0.0.200')\nlight.cloud()\n  .then(info =\u003e {\n    console.log(info)\n  })\n  .catch(e =\u003e console.error(e))\n```\n\u003ca name=\"module_schedule\"\u003e\u003c/a\u003e\n\n## schedule ⇒ \u003ccode\u003ePromise\u003c/code\u003e\nGet schedule from bulb\n\n**Returns**: \u003ccode\u003ePromise\u003c/code\u003e - Resolves to schedule info  \n**Example**  \n```js\n// get the bulb's schedule\nconst light = new Bulb('10.0.0.200')\nlight.schedule()\n  .then(schedule =\u003e {\n    console.log(schedule)\n  })\n  .catch(e =\u003e console.error(e))\n```\n\u003ca name=\"module_details\"\u003e\u003c/a\u003e\n\n## details ⇒ \u003ccode\u003ePromise\u003c/code\u003e\nGet operational details from bulb\n\n**Returns**: \u003ccode\u003ePromise\u003c/code\u003e - Resolves to operational details  \n**Example**  \n```js\n// get some extra details about the light\nconst light = new Bulb('10.0.0.200')\nlight.details()\n  .then(details =\u003e {\n    console.log(details)\n  })\n  .catch(e =\u003e console.error(e))\n```\n\u003ca name=\"module_encrypt\"\u003e\u003c/a\u003e\n\n## encrypt ⇒ \u003ccode\u003eBuffer\u003c/code\u003e\nBadly encrypt message in format bulbs use\n\n**Returns**: \u003ccode\u003eBuffer\u003c/code\u003e - Encrypted data  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| buffer | \u003ccode\u003eBuffer\u003c/code\u003e | Buffer of data to encrypt |\n| key | \u003ccode\u003eNumber\u003c/code\u003e | Encryption key (default is generally correct) |\n\n**Example**  \n```js\nconst encrypted = Bulb.encrypt(Buffer.from('super secret text'))\n```\n\u003ca name=\"module_decrypt\"\u003e\u003c/a\u003e\n\n## decrypt ⇒ \u003ccode\u003eBuffer\u003c/code\u003e\nBadly decrypt message from format bulbs use\n\n**Returns**: \u003ccode\u003eBuffer\u003c/code\u003e - Decrypted data  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| buffer | \u003ccode\u003eBuffer\u003c/code\u003e | Buffer of data to decrypt |\n| key | \u003ccode\u003eNumber\u003c/code\u003e | Encryption key (default is generally correct) |\n\n**Example**  \n```js\nconst decrypted = Bulb.decrypt(encrypted)\n```\n\n## thanks\n\nThanks to [hs100-api](https://github.com/plasticrake/hs100-api) to for some good ideas, and [tplink-smartplug](https://github.com/softScheck/tplink-smartplug) for a good start to a wireshark dissector and some good ideas. @DaveGut really helped with bulb-hacking and research on LB130's.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetbeast%2Freact-native-tplink-bulb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetbeast%2Freact-native-tplink-bulb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetbeast%2Freact-native-tplink-bulb/lists"}