IoT system. Controls Tapo smart plugs, for now
| cli | Add power tab and format | |
| common | Add power tab and format | |
| contrib | Add power tab and format | |
| server | Add power tab and format | |
| .env.example | first commit | |
| .gitignore | Add power tab and format | |
| Cargo.lock | Add power tab and format | |
| Cargo.toml | first commit | |
| QuickStartP110.md | first commit | |
| README.md | Update license | |
| SPEC.md | first commit | |
Castle IoT
Control Tapo P110 smart plugs from a Raspberry Pi 4.
Overview
This project provides a three‐part system:
- Server – headless daemon with HTTP API and device management.
- Web Front‐End – simple web interface with interactive SVG switches.
- CLI – command‐line tool for remote control (e.g., over SSH).
Built in Rust, using the unofficial Tapo library.
Features
- Device discovery on the local network.
- Turn devices on/off via web UI or CLI.
- Real‐time state updates (polling).
- Transitional state feedback (Turning‐On, Turning‐Off).
- Extensible device abstraction (ready for other smart‐home brands).
Requirements
- Raspberry Pi 4 (or any Linux machine) with Debian 13 (or similar).
- Tapo P110 smart plug(s) on the same network.
- Tapo account credentials (username/password).
Building
# Clone the repository
git clone https://github.com/fook/castle-iot.git
cd castle-iot
# Build all crates
cargo build --release
# The binaries will be in target/release/
# - server
# - cli
Running
Server
Set the Tapo credentials as environment variables:
export TAPO_USERNAME=your@email.com
export TAPO_PASSWORD=your_password
./target/release/server
The server will listen on 0.0.0.0:3000. Open http://<pi‐ip>:3000 in a browser.
CLI
./target/release/cli --server http://localhost:3000 discover
./target/release/cli list
./target/release/cli switch <device-id> on
Project Structure
common/– shared types and traits (device abstraction).server/– Axum web server with REST API and static file serving.cli/– command‐line client.server/static/– web front‐end (HTML, CSS, JavaScript).SPEC.md– detailed specification of the system.
Testing
Run unit tests:
cargo test
Integration tests (requires a real Tapo device) are not yet implemented.
Deployment on Raspberry Pi
Cross‐compile for aarch64‐unknown‐linux‐gnu:
rustup target add aarch64-unknown-linux-gnu
cargo build --release --target aarch64-unknown-linux-gnu
Copy the binaries to the Pi and create a systemd service (example in contrib/).
License
GPL3