TP-Link Smarthome Local Server
This command serves Web API for TP-Link Smarthome in the LAN.
This uses plasticrake/tplink-smarthome-api: TP-Link Smarthome WiFi API to control devices. Supporting devices are according to the tplink-smarthome-api.
How to Use It
tplink-smarthome-local-server
starts a web server with REST Web API.
npx tplink-smarthome-local-server
This web server is listening port 3030 and access only allowed from local machine as default.
This command accepts these arguments.
- --port(-p) number
- port number to listening, default `3030`
- --allow(-a) IPs
- access allowed IPs separated spaces like `--allow 127.0.0.1 ::1 ::ffff:192.168.0.0/16`, default `127.0.0.1" "::1`
- --verbose
- output more logs, default `false`
To lookup the devices on the LAN, access the following link.
http://localhost:3030/discovery
To stop this service, push ctrl-c
on the executed command line.
API
Discovery
GET /discovery
Discover TP-Link Smarthome devices on the network. Returns array of object with these properties in JSON.
-
host
: IP address of the device -
type
: type of the device ["Plug" | "Bulb"] -
name
: alias which named by Kasa app of TP-Link
Set Power State
POST /state
with JSON { host:<IP address>, power:<boolean> }
Turns Plug or Bulb relay ON when the power is true
or OFF for others.
Returns report of the call with these properties in JSON.
-
host
: IP address of the device -
type
: type of the device ["Plug" | "Bulb"] -
name
: alias which named by Kasa app of TP-Link -
power
: power state of the device -
result
: true when the request success or "error" -
detail
: error message when it is needed
Get State
GET /state?host=<IP address>
Returns the state object of the device in JSON.
-
host
: IP address of the device -
type
: type of the device ["Plug" | "Bulb"] -
name
: alias which named by Kasa app of TP-Link -
power
: power state of the device -
result
: true when the request success or "error" -
detail
: error message when it is needed
🤝 Contributing
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Show your support
Give a
📝 License
Copyright © 2021 Koji Yokokawa.
This project is MIT licensed.