Back to Projects

Local-First Smart Battery Manager

An automated, hardware-level laptop charging system built on zero-trust networking.

The Architecture

graph TD subgraph Windows Host A[Background Agent
psutil battery monitor] end subgraph Tailscale Network B((Secure VPN Bridge)) F[Remote Mobile Device
Dashboard Access] end subgraph WSL Ubuntu C[Flask API & Toolhub] E[(SQLite Logs)] end subgraph Local IoT Hardware D[Solimo Smart Plug
Tuya Local Key] end A -- Sends JSON via localhost --> C C -- Writes events --> E C -- Executes local command --> D F -- Port 5000 via Tailscale --> B B -- Routes traffic --> C

The Problem

Continuous AC power degrades laptop battery health over time. Relying on cloud-based smart home apps for automation introduces unnecessary latency, privacy concerns, and security risks by relying on external servers to dictate internal hardware states.

The Solution

A fully local, zero-latency system bridging a Windows host with a virtualized Ubuntu server. Utilizing local Tuya IoT keys, the system physically toggles AC power based on precise battery thresholds (20% to 100%), completely bypassing the cloud.

System Workflow & Features

  • The Reporter (Windows Agent) A lightweight Python background process monitors physical battery sensors invisibly, sending state data to the local server.
  • The Brain (WSL Ubuntu API) A Flask endpoint receives the telemetry, manages state logic, and securely logs charging durations into an isolated SQLite database to maintain normalized architectural standards.
  • Zero-Trust Routing (Tailscale) Asymmetric network bridging using Windows port proxies routes host traffic seamlessly into the WSL environment, allowing global dashboard access via Tailscale without open ports.