Files
charging_station/wiki/log.md
T
2026-07-12 10:32:57 +02:00

110 lines
14 KiB
Markdown

---
type: meta
updated: 2026-07-09
tags: [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:<cp>:<gun> / relay:<name> / 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:<id>:<gun> 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]].
## [2026-07-12] meta | Live telemetry on the gun cards: SoC battery gauge + kW/V/A/delivered
Owner wants meter values visible per gun in Control. Backend: latest Sample.Periodic per active tx kept in memory (ACTIVE_TX telemetry) and shipped with /api/status (Transaction.Begin snapshots skipped — taken before the car's BMS is read). Also this morning's finding filed: begin/end snapshots are legitimately 0 A/0 V, and a 42 s session never gets a periodic sample. Frontend: battery gauge with red->blue->green SoC gradient + big kW readout + Delivered/Voltage/Current rows on charging bays; earlier commit added voltage_v/current_a/context columns to samples. Smoke: 60 checks. Updated [[frontend]], [[backend]] implicitly via log.
## [2026-07-12] meta | User app idTags no longer pollute the allowlist
Owner: "why do we need this app token of X? We just need the user." Agreed — decide() now validates a user's app idTag directly against the user record (and enforces their charger:<cp>:<gun> scopes at the charger-side gate too); charger_start no longer auto-enrolls; enrolling a user's tag via the allowlist API returns 400; existing "app token of <name>" entries are auto-dropped at startup. Open-mode bootstrap: "app-remote" authorizes with zero users configured. Session method audit: user tags -> "app". Smoke: 63 checks. Updated [[backend]], [[authorization]].
## [2026-07-12] lint | Session wrap-up: milestones + gaps from today filed
Owner asked whether the wiki needs updating — it did. Filed: panel verified end-to-end on the phone incl. a real in-app start on the live charger (tx 1-2, 141 Wh, who=julian/method=app; the two pre-refactor session rows' who labels were repaired in the db); six household users created; "app-remote" retired (delete from Cards when convenient); Ctrl+C shutdown fix (timeout_graceful_shutdown=3 vs the never-closing charger socket); SPA cache headers + the ":9000 serves the last build" rule; telemetry columns (V/A/context) + live telemetry on /api/status; battery gauge in Control. Refreshed [[overview]] (milestones + trimmed next steps: Tuya keys, remote-stop question, deploy as service), [[backend]], [[frontend]], [[authorization]].
## [2026-07-12] meta | CI/CD pipeline: Docker + Gitea Actions + Komodo + Traefik
Owner asked for a deployment pipeline matching his infra (Gitea workflows, Komodo-controlled compose stack behind Traefik). Added: multi-stage `Dockerfile` (node builds the panel, python:3.13-slim serves it), `compose.yaml` (port 9000 published raw for the charger's hardcoded ws:// dial-in, Traefik labels for the panel, env-tunable for Komodo), `.gitea/workflows/build.yml` (build -> 65-check smoke gate -> push to git.infra.msai.al -> HMAC Komodo redeploy, mirroring the polymarket-bot repo). Backend: `BACKEND_EVENTS` override, `GET /api/health`, smoke test promoted into `backend/smoke_test.py`. New page [[deployment]]; updated [[backend]], [[overview]], [[index]]. ⚠️ First runner build pending (no local Docker).