Frontend rewrite (frontend/, replacing backend/static/): - Vite + TypeScript + React 19, React Router 7, zustand, TanStack Query 5 - dev: vite proxy /api -> :9000; prod: npm run build -> dist/, served by the backend with SPA fallback - pages: Control (gun bays w/ scope+readiness-gated start/stop, relays), History (who/via/gun/when/duration/kWh audit), Cards (pending review, enrolled, rejected), Users (permission checkbox matrix) - self-contained: fonts bundled, no CDN; light/dark; reduced-motion safe Backend: - learn mode removed: unknown cards are always refused and queued in pending_cards; admin approves (name + owner + gun restrictions in one step) or rejects (denied_cards, silent, un-rejectable); pending count rides /api/status as the notification signal - sessions record the auth method (card tap vs in-app button) for audit - GET /api/permissions: grantable-permission catalog driving the UI matrix - SPA static serving with path-traversal guard; 503 hint when not built Smoke test: 54 checks incl. approve/reject round-trips over a fake charge point and method audit assertions.
5.3 KiB
type, updated, tags
| type | updated | tags | |
|---|---|---|---|
| meta | 2026-07-11 |
|
Overview — Anfu Home Charger OCPP Project
Goal: a private, self-hosted ocpp backend (CSMS) for a home EV charger. No billing, no public charging. Authorization via existing RFID cards ✅ and a mobile-friendly web app reached over netbird (by-vehicle ❌ closed — firmware never forwards a vehicle id). Scope expanded 2026-07-11: the same backend also controls the household wifi-relays, locally via tinytuya.
Current state (2026-07-11)
Connectivity: ✅ solved. The jc-6620 controller inside the anfu-charger reliably dials out to the CSMS — verified both on the charger's own LAN (192.168.2.114:9000) and across the NAT boundary on the WAN subnet (10.0.10.203:9000). Getting here required the fixes catalogued in troubleshooting; the network layout is in network-topology.
Software: production backend built (2026-07-11), including the web panel. station.py was ported into the ../backend/ package: one FastAPI process on port 9000 = CSMS WebSocket + /api/* (charger control, allowlist CRUD, runtime learn-mode flip) + wifi-relays on/off/toggle + multi-user auth (username/password, per-resource scopes: gun 1 / gun 2 / per-relay / admin, per-gun-restrictable RFID cards — authorization) + consumption tracking (SQLite: who charged, when, how many kWh, per-minute meter samples) + the PWA control panel at / (login, scope-filtered start/stop buttons, relay toggles, history, admin). Smoke-tested (54 checks incl. a fake charge point over the real WS route); ✅ live charger connects to it since 2026-07-11 evening; ⚠️ panel untested from a real phone. All state lives in one SQLite file (backend.db) — no config file, every change via API/panel takes effect immediately. Late 2026-07-11: learn mode replaced by the pending-card review workflow (unknown taps refused + queued for admin approve/reject), sessions audit the auth method (card vs in-app), and the panel was rebuilt as a React app (frontend). The csms-toolkit (../discovering/) remains as diagnostic tooling.
Capabilities: ✅ known. The live probe (2026-07-09-discovery-eu092025) identified the pile as SimpleCharge "MultiSocketCharger" (fw 1.24.0620.1, OCPP ID eu092025) with two guns, RemoteTrigger (verified), SmartCharging, Reservation, a 6-entry local auth list, and per-minute meter data including SoC. Only Autocharge remains unknown (physical test pending; MacEnabled is a lead — authorization).
Authorization: 2 of 3 methods ✅ verified live (2026-07-09 test session, both cars plugged, both guns charging simultaneously):
- RFID ✅ — card
…393tapped → Authorize → real charging session on gun 2 (DC, ~26 kW avg, 1.8 kWh delivered). Card enrolled as "RFID card A". - Remote (app path) ✅ — RemoteStart and RemoteStop both Accepted and executed on gun 1;
app-remotetoken enrolled. - By vehicle ❌ closed — three escalating tests (plain plug-in,
MacEnabled=truelive,MacEnabled=trueafter power-cycle) all negative; this firmware never forwards a vehicle ID over OCPP (authorization).
Hardware surprise: this is a DC-capable multi-standard charger (gun 1 EU, gun 2 Chinese GB/T @ 30 kW), not the assumed basic AC unit — see anfu-charger.
What's next
Cut the live charger over to the backend— ✅ done 2026-07-11 evening:eu092025connects topython -m backend.main(verified in events.jsonl). Remaining: a card tap + a panel button-push on the live charger.- Create the real users —
python -m backend.users add <name> --scopes ...for each household member (the API stays open until the first user exists). - Extract the Tuya local keys (
tinytuya wizard— steps in wifi-relays) and register them viaPUT /api/relays/<name>→ relays become controllable. - Restart the backend once to pick up the React panel + pending-card workflow (state changes never need restarts; code updates do).
- Test the panel from a phone —
http://<host>:9000/; verify login, a real button-push start on a ready gun, the pending-card banner (tap an unenrolled card), and add-to-home-screen over netbird. - Resolve the ❓ remote-stop restart question — did the gun-2 session auto-restart from auth cache after RemoteStop, or was the card re-tapped? Affects the app's Stop button UX (authorization).
Open decisions ❓
| Decision | Options | Status |
|---|---|---|
| Always-on host for CSMS + app | LAN PC · the 10.0.10.203 machine · dedicated box (e.g. Pi on charger LAN, joined to NetBird) |
open — now also needs subnet reachability to the [[wifi-relays |
| Web app auth | — | ✅ resolved 2026-07-11: username+password login with per-resource scopes (gun 1 / gun 2 / per-relay / admin) — see authorization. Bootstrap: create the first admin user via python -m backend.users add |
| Autocharge / by vehicle | — | ❌ closed 2026-07-09: not supported by this firmware (authorization) |
| Host IP stability | static IP · DHCP reservation | open (required either way — touchscreen URL is hardcoded) |
Sources
- 2026-07-09-findings-and-requirements — the founding findings/requirements doc