51 lines
5.3 KiB
Markdown
51 lines
5.3 KiB
Markdown
---
|
||
type: meta
|
||
updated: 2026-07-12
|
||
tags: [synthesis]
|
||
---
|
||
|
||
# Overview — Anfu Home Charger OCPP Project
|
||
|
||
**Goal:** a private, self-hosted [[ocpp|OCPP 1.6J]] 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|NetBird]] (by-vehicle ❌ closed — firmware never forwards a vehicle id). **Scope expanded 2026-07-11:** the same backend also controls the household [[wifi-relays|Tuya/SmartLife WiFi relays]], locally via tinytuya.
|
||
|
||
## Current state (2026-07-11)
|
||
|
||
**Connectivity: ✅ solved.** The [[jc-6620|JC-6620]] controller inside the [[anfu-charger|charging pile]] 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|Tuya relay]] 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 `…393` tapped → 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-remote` token enrolled.
|
||
- **By vehicle** ❌ **closed** — three escalating tests (plain plug-in, `MacEnabled=true` live, `MacEnabled=true` after 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]].
|
||
|
||
## Milestones reached (2026-07-12)
|
||
|
||
- ✅ Live cutover: `eu092025` connects to `python -m backend.main` (2026-07-11 evening)
|
||
- ✅ **The panel works end-to-end on the owner's phone**: login, and a real in-app remote start on gun 1 of the live charger (2026-07-12 morning, tx 1–2, 141 Wh, attributed who=julian / method=app)
|
||
- ✅ Six household users created (admin + scoped members)
|
||
|
||
## What's next
|
||
|
||
1. **Extract the Tuya local keys** (`tinytuya wizard` — steps in [[wifi-relays]]) and register them via `PUT /api/relays/<name>` → relays become controllable.
|
||
2. **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]]). Test: remote-stop, touch nothing for 5 min.
|
||
3. **Deploy as an always-on service** ([[architecture-plan]] phase 4) — decide the host (❓ below), run under NSSM/systemd, DHCP reservation.
|
||
4. Housekeeping: delete the retired `app-remote` allowlist entry from the Cards page; tap the remaining household cards so they pend and can be linked to their owners.
|
||
|
||
## 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|relays]] for local Tuya control |
|
||
| 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
|