{"id":16806256,"url":"https://github.com/whitslack/kasa","last_synced_at":"2025-03-17T07:50:30.799Z","repository":{"id":167431581,"uuid":"642673284","full_name":"whitslack/kasa","owner":"whitslack","description":"Kasa Smart API documentation and tools","archived":false,"fork":false,"pushed_at":"2023-05-20T00:12:13.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-23T17:19:59.931Z","etag":null,"topics":["automation","home","kasa","smart","tp-link"],"latest_commit_sha":null,"homepage":"","language":"C","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/whitslack.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":"2023-05-19T05:13:01.000Z","updated_at":"2024-10-29T10:28:01.000Z","dependencies_parsed_at":"2023-08-01T10:01:59.964Z","dependency_job_id":null,"html_url":"https://github.com/whitslack/kasa","commit_stats":null,"previous_names":["whitslack/kasa"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitslack%2Fkasa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitslack%2Fkasa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitslack%2Fkasa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitslack%2Fkasa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whitslack","download_url":"https://codeload.github.com/whitslack/kasa/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243997041,"owners_count":20380980,"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":["automation","home","kasa","smart","tp-link"],"created_at":"2024-10-13T09:50:32.641Z","updated_at":"2025-03-17T07:50:30.780Z","avatar_url":"https://github.com/whitslack.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kasa Smart\n\nThis **UNOFFICIAL** repository contains information about TP-Link's Kasa Smart API and a C-language tool for interacting with Kasa devices via the local control protocol (not via the cloud service).\n\n* [Kasa API Documentation](API.md)\n* [Known Firmware URLs](FIRMWARE.md)\n\nGitHub issues and pull requests are very welcome to help refine and expand this knowledge base.\n\n\n## Compiling\n\nThe tool should compile and run on just about any POSIX-compliant system. Linux and macOS are known to be supported.\nWindows users are probably out of luck — sorry, not sorry.\n\n```\n$ cc -O3 -o kasa kasa.c\n```\n\n## Usage\n\n```\n$ echo '{\"system\":{\"get_sysinfo\":{}}}' | ./kasa \u003cdevice-addr\u003e\n```\n\nThe tool establishes a TCP connection on port 9999 to the Kasa device specified on the command line by host name or IP address.\nEach line that is written to the tool's standard input is sent as a separate request to the connected Kasa device,\nand the tool writes each response received from the device as a separate line to its standard output.\n\n**Tip:** You can pipe the output of the tool into [jq](https://stedolan.github.io/jq/) to extract the information that interests you.\n\n### Example in Bash\n\n```bash\n#!/bin/bash\n\nif [[ ! -v 1 ]] ; then\n\techo 'Toggles the relay state of a Kasa plug/switch.'\n\techo\n\techo \"usage: ${0} \u003cdevice-addr\u003e [...]\"\n\texit 1\nfi \u003e\u00262\n\nkasa_call() {\n\tlocal - ; set -o pipefail\n\techo \"${2:?}\" | \"${KASA:-./kasa}\" \"${1:?}\" |\n\t\tjq -r \"if [ .[][].err_code != 0 ] | any then halt_error else ${3:-empty} end\"\n}\n\nfor each ; do\n\t{ read -r alias ; read -r relay_state ; } \u003c \u003c(\n\t\tkasa_call \"${each}\" '{\"system\":{\"get_sysinfo\":{}}}' \\\n\t\t\t'.system.get_sysinfo | ( .alias, .relay_state )')\n\tcase \"${relay_state}\" in\n\t\t0)\n\t\t\techo \"${alias} is switched off; switching on.\"\n\t\t\tkasa_call \"${each}\" '{\"system\":{\"set_relay_state\":{\"state\":1}}}'\n\t\t\t;;\n\t\t1)\n\t\t\techo \"${alias} is switched on; switching off.\"\n\t\t\tkasa_call \"${each}\" '{\"system\":{\"set_relay_state\":{\"state\":0}}}'\n\t\t\t;;\n\t\t*)\n\t\t\texit \"${?}\"\n\t\t\t;;\n\tesac\ndone\n```\n\n## Disclaimer\n\nThe information and code contained in this repository is provided “as is,” without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement.\nIn no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the information and code contained in this repository or the use or other dealings therewith.\n\nThe information contained in this repository may be incorrect or incomplete. Any use of what you find here is undertaken solely at your own risk.\n\nKasa is a [registered trademark](https://uspto.report/TM/87867268) of the TP-Link Research America Corporation.\nTP-Link have not endorsed or contributed to this repository and are not affiliated with it in any way.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhitslack%2Fkasa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhitslack%2Fkasa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhitslack%2Fkasa/lists"}