--- type: entity updated: 2026-07-11 tags: [software, csms] --- # CSMS Toolkit (`../discovering/`) The Python scripts that play the CSMS (backend) side of the [[ocpp|OCPP]] link. Currently discovery/tester-grade; `station.py` is the seed of the real controller. Per [[2026-07-09-findings-and-requirements]]: > [!warning] Superseded for production (2026-07-11): `station.py` was ported into the [[backend]] package (`../backend/`), which adds allowlist CRUD, optional API token auth, and [[wifi-relays|Tuya relay]] control. `discovering/` stays as the discovery/diagnostic toolkit (`csms.py`, `rawlisten.py`, fake charge point) — don't run `station.py` and the backend at the same time; both bind port 9000. | File | Purpose | |---|---| | `csms.py` | Minimal OCPP 1.6J server — accepts everything, logs raw frames. Discovery/tester. | | `rawlisten.py` | Dumb TCP listener on `:9000` — shows whether *any* bytes arrive. Fallback diagnostic. | | `station.py` | **The real controller.** Allowlist-based auth + learn mode + hooks for remote start/stop. | | `station_config.json` | `{ "learn_mode": bool, "authorized": { "": {name, kind} } }` | | `seen_tags.json` | Auto-recorded log of every idTag observed (discovery / Autocharge testing). | - **Runtime:** Python venv with `fastapi` + `uvicorn` + `ocpp` (2026-07-09: `station.py` moved from raw `websockets` to a single FastAPI/uvicorn process — the phase-1 shape from [[architecture-plan]]). - **Single port 9000:** the OCPP WebSocket (`ws://0.0.0.0:9000/`, any path) *and* the discovery HTTP API share it, so the hardcoded touchscreen URL never changes. - **The one gate:** every [[authorization]] method funnels through `decide(id_tag)` in `station.py` — Accepted/Rejected against the allowlist. - **Host requirements:** inbound TCP 9000 open (Windows firewall silently drops otherwise — see [[troubleshooting]]) and a stable IP, since the [[anfu-charger|charger touchscreen]] URL is hardcoded. ## Discovery API (in `station.py`, docs at `http://:9000/docs`) - Auto-interrogation on every charger connect: `GetConfiguration` (all keys) + `TriggerMessage(StatusNotification)` → saved to `discovery_.json` (first real capture: [[2026-07-09-discovery-eu092025]]) - **Event journal:** every OCPP event (connect/disconnect, boot, status, authorize, start/stop transaction, meter values) is appended as one JSON line to `events.jsonl` — permanent, restart-proof, greppable; tail it via `GET /events?limit=N&event=` - `GET /status` (chargers, guns, transactions, auth events) · `GET /tags` (seen + authorized) - `POST /probe` · `/start` · `/stop[/{tx}]` · `/trigger/{status|meter|heartbeat|boot}` · `/unlock/{connector}` · `/setconfig?key=&value=` - With one charger connected, `?cp=` may be omitted. ✅ Verified end-to-end against both a fake charge point and the real charger. ## Still to build The web control panel (remote start/stop, live status, allowlist management) served behind [[netbird|NetBird]] — now on the [[backend]], see [[overview]] for the plan and open host decision.