{"id":16188300,"url":"https://github.com/konsumer/kasa_control","last_synced_at":"2025-07-02T09:35:20.742Z","repository":{"id":44846797,"uuid":"132736929","full_name":"konsumer/kasa_control","owner":"konsumer","description":"use kasa-cloud to hit your TPLink bulbs in nodejs","archived":false,"fork":false,"pushed_at":"2023-11-12T00:28:32.000Z","size":573,"stargazers_count":10,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T22:33:16.306Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/konsumer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2018-05-09T09:54:47.000Z","updated_at":"2024-01-14T12:44:37.000Z","dependencies_parsed_at":"2024-10-20T14:34:29.280Z","dependency_job_id":null,"html_url":"https://github.com/konsumer/kasa_control","commit_stats":{"total_commits":30,"total_committers":2,"mean_commits":15.0,"dds":"0.23333333333333328","last_synced_commit":"29bdc909cbdaeee395432785cf3ec8242a799ace"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/konsumer/kasa_control","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Fkasa_control","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Fkasa_control/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Fkasa_control/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Fkasa_control/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/konsumer","download_url":"https://codeload.github.com/konsumer/kasa_control/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Fkasa_control/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263112216,"owners_count":23415569,"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-10T07:25:56.385Z","updated_at":"2025-07-02T09:35:20.711Z","avatar_url":"https://github.com/konsumer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kasa-control\n\nThis will let you use kasa-cloud to hit your TPLink bulbs in nodejs.\n\nIf you'd like to hit them directly, on your local network, use [tplink-lightbulb](https://github.com/konsumer/tplink-lightbulb). This library is for situations where you want to use a username/password (from [tplink cloud](https://www.tplinkcloud.com/).) It will allow you to acces them remotely.\n\n## installation\n\n```sh\nnpm i kasa_control\n```\n\n### example usage\n\n```js\nconst KasaControl = require('kasa_control')\nconst kasa = new KasaControl()\n\nconst main = async () =\u003e {\n  await kasa.login('email', 'password')\n  const devices = await kasa.getDevices()\n\n  // turn off first device\n  await kasa.power(devices[0].deviceId, false)\n}\nmain()\n\n```\n\n## api\n\n\u003cdl\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_getDevices\"\u003egetDevices\u003c/a\u003e ⇒ \u003ccode\u003ePromise\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eGet a list of devices for your Kasa account\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 a device\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#module_power\"\u003epower\u003c/a\u003e ⇒ \u003ccode\u003ePromise\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eSet power-state of lightbulb\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\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| deviceId | \u003ccode\u003estring\u003c/code\u003e | The deviceId of the device in your kasa app |\n| msg | \u003ccode\u003eObject\u003c/code\u003e | Message to send to bulb |\n\n**Example**\n```js\nkasa.send('80126E22B048C76F341BEED1A3EA8E77177F3484', {\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_getDevices\"\u003e\u003c/a\u003e\n\n## getDevices ⇒ \u003ccode\u003ePromise\u003c/code\u003e\nGet a list of devices for your Kasa account\n\n**Returns**: \u003ccode\u003ePromise\u003c/code\u003e - Resolves to an array of device-objects\n**Example**\n```js\nkasa.getDevices()\n  .then(devices =\u003e {\n    console.log(devices)\n  })\n  .catch(e =\u003e console.error(e))\n```\n\u003ca name=\"module_info\"\u003e\u003c/a\u003e\n\n## info ⇒ \u003ccode\u003ePromise\u003c/code\u003e\nGet info about a device\n\n**Returns**: \u003ccode\u003ePromise\u003c/code\u003e - Resolves to an info-pbject about your device\nexample\n```js\nkasa.info('80126E22B048C76F341BEED1A3EA8E77177F3484')\n  .then(info =\u003e {\n    console.log(info)\n  })\n  .catch(e =\u003e console.error(e))\n```\n\n| Param | Type | Description |\n| --- | --- | --- |\n| deviceId | \u003ccode\u003estring\u003c/code\u003e | The deviceId of the device in your kasa app |\n\n\u003ca name=\"module_power\"\u003e\u003c/a\u003e\n\n## power ⇒ \u003ccode\u003ePromise\u003c/code\u003e\nSet power-state of lightbulb\n\n**Returns**: \u003ccode\u003ePromise\u003c/code\u003e - Resolves to output of command\n\n| Param | Type | Description |\n| --- | --- | --- |\n| deviceId | \u003ccode\u003estring\u003c/code\u003e | The deviceId of the device in your kasa app |\n| powerState | \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\nkasa.power('80126E22B048C76F341BEED1A3EA8E77177F3484', true)\n  .then(status =\u003e {\n    console.log(status)\n  })\n  .catch(err =\u003e console.error(err))\n```\n\n## thanks\n\nThanks to itnerd for these 3 articles:\n\n* [authenticate](http://itnerd.space/2017/06/19/how-to-authenticate-to-tp-link-cloud-api/)\n* [deviceList](http://itnerd.space/2017/05/21/how-to-get-the-tp-link-hs100-cloud-end-point-url/)\n* [passthrough](http://itnerd.space/2017/01/22/how-to-control-your-tp-link-hs100-smartplug-from-internet/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonsumer%2Fkasa_control","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkonsumer%2Fkasa_control","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonsumer%2Fkasa_control/lists"}