1
0
Fork
You've already forked castle-iot
0
IoT system. Controls Tapo smart plugs, for now
  • Rust 70.7%
  • HTML 29.3%
2026年05月24日 11:42:28 +12:00
cli Add power tab and format 2026年05月24日 11:42:28 +12:00
common Add power tab and format 2026年05月24日 11:42:28 +12:00
contrib Add power tab and format 2026年05月24日 11:42:28 +12:00
server Add power tab and format 2026年05月24日 11:42:28 +12:00
.env.example first commit 2026年05月18日 10:05:47 +12:00
.gitignore Add power tab and format 2026年05月24日 11:42:28 +12:00
Cargo.lock Add power tab and format 2026年05月24日 11:42:28 +12:00
Cargo.toml first commit 2026年05月18日 10:05:47 +12:00
QuickStartP110.md first commit 2026年05月18日 10:05:47 +12:00
README.md Update license 2026年05月24日 11:38:32 +12:00
SPEC.md first commit 2026年05月18日 10:05:47 +12:00

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