Files
charging_station/wiki/log.md
T
julian 069d544bb5 feat: private session history, own-permissions view, plug-gated start button
- non-admins now see ONLY their own sessions in /api/sessions (own app
  starts + own linked cards); gun scopes grant control, not visibility;
  admins see everything
- Account page shows the logged-in user's permissions in plain words
  (Administrator badge, or the guns/relays they control), built solely
  from data already visible to them
- Start button arms only when the gun reports Preparing (cable in the
  car); idle unplugged gun shows an explanatory hint instead
- keep owner's app rename to 'Art IoT'
- smoke test: 59 checks (gun-scoped user sees no foreign sessions)
2026-07-12 09:04:06 +02:00

12 KiB

type, updated, tags
type updated tags
meta 2026-07-09
log

Log

Append-only, newest at the bottom. Entry format: ## [YYYY-MM-DD] ingest|query|lint|meta | Title — so grep "^## \[" log.md | tail -5 shows recent activity.

[2026-07-09] meta | Wiki bootstrapped

Instantiated the LLM-wiki pattern for the charging-station project: schema (CLAUDE.md), index.md, log.md, and directory layout (sources/, entities/, concepts/, notes/).

[2026-07-09] ingest | Findings & Requirements (founding source)

Ingested raw/FINDINGS_AND_REQUIREMENTS.md → 2026-07-09-findings-and-requirements. Seeded overview plus entities (anfu-charger, jc-6620, csms-toolkit, netbird) and concepts (network-topology, authorization, troubleshooting, ocpp). Open decisions tracked in overview.

[2026-07-09] query | Stack decision → architecture plan filed

Discussed backend (Fastify vs FastAPI), web frontend, and Flutter. Decided: FastAPI single-process CSMS+API+PWA; Flutter deferred to optional phase 2. Filed as architecture-plan; index updated.

[2026-07-09] ingest | Live capability probe of the real charger (eu092025)

Built discovery layer into station.py (single FastAPI process on :9000 — OCPP WS + HTTP API with /status /tags /probe /start /stop /trigger /unlock /setconfig; auto-GetConfiguration on connect). The real charger connected during testing: SimpleCharge MultiSocketCharger, fw 1.24.0620.1, TWO guns, RemoteTrigger verified. Ingested raw/discovery_eu092025.json → 2026-07-09-discovery-eu092025; updated anfu-charger, authorization, csms-toolkit, overview.

[2026-07-09] meta | Discovery runbook filed

Filed discovery-runbook: physical test session plan (Autocharge plug-in test first, then RFID card taps, optional remote start). Awaiting hardware results.

[2026-07-09] meta | Event journal added to station.py

All OCPP events now persist to events.jsonl (one JSON line each) with a GET /events tail endpoint — so the upcoming Autocharge/RFID/charging test session is fully recorded for later ingest. Verified with fake charger + live eu092025 reconnect. Updated csms-toolkit.

[2026-07-09] ingest | First live plug-in test: no Autocharge by default

Car plugged into gun 2 (no card): StatusNotification Available->Preparing at 15:02:59Z, then silence — no Authorize/StartTransaction/idTag in ~2 min. Preliminary: no Autocharge out of the box; MacEnabled=true retry pending. Updated authorization.

[2026-07-09] ingest | Full live test session: RFID + remote start/stop verified, no Autocharge, charger is DC

Live session with both cars: card ...393 -> Authorize -> charging on gun 2 (GB/T DC, 30.6 kW observed, 1807 Wh delivered); RemoteStart/RemoteStop proven on gun 1 (EU, 349 Wh); two cars plugged without cards produced no idTag (Autocharge negative, MacEnabled retry remains). Superseded "basic AC unit" assumption. Card + app-remote enrolled in allowlist. Updated authorization, anfu-charger, overview. Raw record: discovering/events.jsonl.

[2026-07-09] ingest | Card B captured; gun 2 re-stop; possible auto-restart after remote stop

Card B (...395) tapped and enrolled. Gun 2 had started a NEW session (same card id ...393, ~65 s after the previous remote stop, cable still plugged) — stopped it remotely (tx 3, 2264 Wh). Open question ❓: re-tap or auth-cache auto-restart? Noted in authorization.

[2026-07-09] meta | Charger confirmed 60 kW DC; MacEnabled flipped to true

Owner confirmed: 60 kW DC fast charger (gun 1 EU/CCS, gun 2 GB/T). No vehicle id observed via OCPP yet, but DC handshake means the charger receives EVCCID (CCS) / possibly VIN (GB/T). Set MacEnabled=true (ChangeConfiguration Accepted, live). Replug test pending. Updated anfu-charger, authorization.

[2026-07-09] ingest | "By vehicle" auth definitively closed; charger is 60 kW DC

Owner confirmed 60 kW DC. Final Autocharge variant: power-cycled pile with MacEnabled=true (setting persisted, verified by post-reboot probe), EU car replugged 15:33:51Z -> no idTag in ~3.5 min. Closed method 2 as NOT SUPPORTED; MacEnabled reverted to false. Updated authorization, overview, anfu-charger, discovery-runbook. Remaining next steps: learn_mode off, PWA panel, remote-stop-restart question.

[2026-07-09] ingest | Touchscreen shows VIN of Chinese (GB/T) cars

Owner observation: the pile's own UI displays the chassis/VIN for GB/T cars -> confirms the BRM handshake delivers the VIN to the charger; firmware just never maps it to an OCPP idTag. Noted in authorization with the DataTransferVendorId long-shot lead.

[2026-07-11] ingest | Scope expansion: backend also controls the Tuya/SmartLife WiFi relays

Owner: the backend should also drive the WiFi relays currently on the SmartLife app (BLE-assisted pairing = standard Tuya onboarding; they're Tuya WiFi devices). Decision: local control via tinytuya (TCP 6668), no Tuya cloud in the day-to-day loop; one-time id/local-key extraction via tinytuya wizard pending. Created wifi-relays; updated architecture-plan, overview.

[2026-07-11] meta | Production backend built (../backend/) — architecture-plan phases 1-2

Ported station.py into the backend/ package: one FastAPI process on :9000 = OCPP CSMS + /api/* (charger control, allowlist CRUD, runtime learn-mode flip, optional api_token auth) + /api/relays/* (tinytuya via asyncio.to_thread). Allowlist migrated to backend/config.json (gitignored — holds Tuya local keys; config.example.json documents shape). Smoke-tested: 13 checks incl. fake CP BootNotification/Authorize over the real WS route. Not yet cut over on the live charger. Created backend; updated csms-toolkit (superseded-for-production callout), architecture-plan, overview, index.

[2026-07-11] meta | Multi-user auth system: username/password + per-resource scopes

Owner requirement: per-user permissions (gun 1 vs gun 2 of eu092025, per-relay or all relays). Owner chose username+password over plain tokens; per-gun RFID restriction included. Built into backend: users.py (PBKDF2 passwords, stateless HMAC sessions 30d, cookie+bearer, fnmatch scopes charger:: / relay: / admin), login/me/users CRUD endpoints, scope checks on every route, relay visibility filtering, remote starts attributed via per-user idTag, decide() enforces optional "connectors" on allowlist entries at StartTransaction. Zero users = open API (bootstrap via python -m backend.users add). Smoke test grown 13 -> 28 checks, all passing. Resolved the "web app auth" open decision. Updated authorization (new scopes section + per-gun cards), backend, overview.

[2026-07-11] meta | Consumption tracking (SQLite) + the PWA control panel

Owner requirement: button-push start when a gun is ready (and permitted) + "who charged when and how many kWh". Built store.py (sessions.db: sessions with resolved who/started/ended/Wh + per-minute samples energy/power/SoC; tx ids survive restarts; stop falls back to store after restart), /api/sessions with visibility rules (own + in-scope guns; admin all), and the phase-3 web panel in backend/static/ (vanilla JS PWA at /: login, gun cards with scope- and readiness-gated Start/Stop, relay toggles, history tab, admin tab with allowlist/users/mode). Fixed a sqlite connection leak (with-connect commits but never closes). Smoke test 28 -> 37 checks, all passing. Updated backend, architecture-plan (phases 1-3 all done), overview, index.

[2026-07-11] meta | Cards linked to users; multi-charger gaps closed

Owner requirements: cards must belong to a person (not float around as "RFID card A (tapped first...)"), and adding a second charger must be clean. Allowlist entries now take "user" (sessions attribute to the person; owner sees their card's history) and charger-qualified "guns": ["eu092025:2"] (fnmatch; replaces the charger-blind "connectors" field). Gun display names moved from hardcoded panel JS to a "chargers" config section served via /api/status. Adding a charger = point it at the same URL with a unique ChargerID + grant charger:: scopes. Panel admin tab: owner dropdown + guns field. Smoke test 37 -> 42 checks. Updated authorization, backend.

[2026-07-11] meta | config.json eliminated — one SQLite store (backend.db)

Owner pushback: two persistence stores (sessions.db + a config.json that doubled as a mutable datastore) was one too many, with confusing hand-edit-needs-restart semantics. Now everything lives in backend.db (renamed from sessions.db): sessions + samples tables plus a settings table holding the app-state sections (users, allowlist, relays, chargers, learn_mode, session_secret) as JSON blobs. All changes go through the API/panel and apply immediately; nothing to hand-edit. Legacy config.json auto-imports on first start (kept as config.json.migrated) — julian + cards + charger labels migrated. New admin endpoints PUT/DELETE /api/relays/{name} and PUT /api/chargers/{id} replace file editing (tinytuya wizard results now enter via /docs). Smoke test isolated via BACKEND_DB env override; 45 checks. Also: live cutover confirmed — eu092025 connected to the backend this evening. Updated backend, authorization, wifi-relays, overview.

[2026-07-11] meta | React frontend; pending-card review workflow; auth-method audit

Owner: full frontend revision (React + routing + zustand + TanStack Query, Vite proxy in dev, static build served by backend, professional look) and backend fixes: permissions must be understandable, cards must connect to users, unknown card taps must notify the admin for approve/reject, and sessions must audit HOW authorization happened. Backend: learn mode REMOVED -> pending_cards/denied_cards workflow (unknown taps always refused, queued for review; pending count on /api/status as notification); sessions.method column (card|app); GET /api/permissions catalog. Frontend: new ../frontend/ (React 19, instrument-panel design, copper accent, indicator-lamp signature, bundled fonts); pages Control/History/Cards/Users; permission checkbox matrix; approve-with-owner-link in one step. Old backend/static vanilla panel deleted; seen_tags.json gone. Smoke: 54 checks. Created frontend; updated backend, authorization, overview, architecture-plan, index, root CLAUDE.md.

[2026-07-12] meta | Panel live on the owner's phone; gun state language; password self-service

Owner confirmed the React panel loads on the phone after backend restart. Changes on request: (1) both guns ALWAYS render on Control — gun cards come from the chargers registry, live reports only overlay state (offline/no-status shown gray); (2) new lamp/chip language: gray=idle, pulsing blue=cable plugged, green=charging; (3) POST /api/me/password + /account page — any user changes their own password (current password required; admin reset via PUT /api/users stays). Smoke: 58 checks. Updated frontend, backend.

[2026-07-12] meta | Private history; permissions on Account; Start only when plugged; "Art IoT" rename

Owner (testing on the phone, second user created): (1) transactions are now PRIVATE — non-admins see only their own sessions (app starts + linked cards); gun scopes grant control, not visibility; admins see all. (2) Account page shows the user's own permissions in plain words (admin badge, or gun/relay list built from data they already see). (3) Start button arms ONLY when the cable is plugged (Preparing) — an idle unplugged gun shows "plug the cable into the car to enable". Owner also renamed the app to "Art IoT" (login, topbar, manifest, title) — kept. Smoke: 59 checks. Updated backend, frontend.