feat: bootstrap wiki for Anfu home EV charger OCPP integration project
- Created initial wiki structure with CLAUDE.md schema, index.md, and log.md. - Ingested findings and requirements document into the wiki. - Added concepts for authorization methods, network topology, OCPP protocol, and troubleshooting. - Documented entities including the Anfu charger, JC-6620 controller, and CSMS toolkit. - Established configuration files for Obsidian app settings and workspace layout. - Implemented core plugins and appearance settings for the wiki.
This commit is contained in:
+220
@@ -0,0 +1,220 @@
|
|||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[codz]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
*.py.cover
|
||||||
|
*.lcov
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
cover/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
db.sqlite3-journal
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
.pybuilder/
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
# For a library or package, you might want to ignore these files since the code is
|
||||||
|
# intended to run in multiple environments; otherwise, check them in:
|
||||||
|
# .python-version
|
||||||
|
|
||||||
|
# pipenv
|
||||||
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||||
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||||
|
# install all needed dependencies.
|
||||||
|
# Pipfile.lock
|
||||||
|
|
||||||
|
# UV
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
||||||
|
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||||
|
# commonly ignored for libraries.
|
||||||
|
# uv.lock
|
||||||
|
|
||||||
|
# poetry
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||||
|
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||||
|
# commonly ignored for libraries.
|
||||||
|
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||||
|
# poetry.lock
|
||||||
|
# poetry.toml
|
||||||
|
|
||||||
|
# pdm
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||||
|
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
||||||
|
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
||||||
|
# pdm.lock
|
||||||
|
# pdm.toml
|
||||||
|
.pdm-python
|
||||||
|
.pdm-build/
|
||||||
|
|
||||||
|
# pixi
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
||||||
|
# pixi.lock
|
||||||
|
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
||||||
|
# in the .venv directory. It is recommended not to include this directory in version control.
|
||||||
|
.pixi/*
|
||||||
|
!.pixi/config.toml
|
||||||
|
|
||||||
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||||
|
__pypackages__/
|
||||||
|
|
||||||
|
# Celery stuff
|
||||||
|
celerybeat-schedule*
|
||||||
|
celerybeat.pid
|
||||||
|
|
||||||
|
# Redis
|
||||||
|
*.rdb
|
||||||
|
*.aof
|
||||||
|
*.pid
|
||||||
|
|
||||||
|
# RabbitMQ
|
||||||
|
mnesia/
|
||||||
|
rabbitmq/
|
||||||
|
rabbitmq-data/
|
||||||
|
|
||||||
|
# ActiveMQ
|
||||||
|
activemq-data/
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.envrc
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
|
# pytype static type analyzer
|
||||||
|
.pytype/
|
||||||
|
|
||||||
|
# Cython debug symbols
|
||||||
|
cython_debug/
|
||||||
|
|
||||||
|
# PyCharm
|
||||||
|
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||||
|
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||||
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
|
# .idea/
|
||||||
|
|
||||||
|
# Abstra
|
||||||
|
# Abstra is an AI-powered process automation framework.
|
||||||
|
# Ignore directories containing user credentials, local state, and settings.
|
||||||
|
# Learn more at https://abstra.io/docs
|
||||||
|
.abstra/
|
||||||
|
|
||||||
|
# Visual Studio Code
|
||||||
|
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
||||||
|
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
||||||
|
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
||||||
|
# you could uncomment the following to ignore the entire vscode folder
|
||||||
|
# .vscode/
|
||||||
|
# Temporary file for partial code execution
|
||||||
|
tempCodeRunnerFile.py
|
||||||
|
|
||||||
|
# Ruff stuff:
|
||||||
|
.ruff_cache/
|
||||||
|
|
||||||
|
# PyPI configuration file
|
||||||
|
.pypirc
|
||||||
|
|
||||||
|
# Marimo
|
||||||
|
marimo/_static/
|
||||||
|
marimo/_lsp/
|
||||||
|
__marimo__/
|
||||||
|
|
||||||
|
# Streamlit
|
||||||
|
.streamlit/secrets.toml
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# Charging Station Project
|
||||||
|
|
||||||
|
Two parts:
|
||||||
|
|
||||||
|
- **`wiki/`** — an LLM-maintained knowledge base about the Anfu home charger OCPP integration. **Read `wiki/CLAUDE.md` before touching anything in it** — it defines the schema, conventions, and ingest/query/lint workflows. `wiki/raw/` is immutable source material; never edit it.
|
||||||
|
- **`discovering/`** — throwaway-ish Python scripts to test the charging station connection and watch WebSocket payloads in realtime (`csms.py`, `rawlisten.py`, `station.py`). Documented in the wiki at `wiki/entities/csms-toolkit.md`.
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
"""Minimal OCPP 1.6J central system for discovering/testing a charge point.
|
||||||
|
|
||||||
|
Accepts any charge point ID on ws://0.0.0.0:9000/<id>, answers the standard
|
||||||
|
message set with "Accepted", and logs every raw frame in both directions.
|
||||||
|
|
||||||
|
Run: .venv/bin/python csms.py
|
||||||
|
Then point the charger's OCPP backend URL at ws://<host-ip>:9000/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
import logging
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
|
import websockets
|
||||||
|
|
||||||
|
from ocpp.routing import on
|
||||||
|
from ocpp.v16 import ChargePoint as OcppChargePoint
|
||||||
|
from ocpp.v16 import call_result
|
||||||
|
from ocpp.v16.enums import (
|
||||||
|
Action,
|
||||||
|
AuthorizationStatus,
|
||||||
|
DataTransferStatus,
|
||||||
|
RegistrationStatus,
|
||||||
|
)
|
||||||
|
|
||||||
|
logging.basicConfig(
|
||||||
|
level=logging.INFO,
|
||||||
|
format="%(asctime)s %(levelname)s %(name)s | %(message)s",
|
||||||
|
)
|
||||||
|
log = logging.getLogger("csms")
|
||||||
|
|
||||||
|
|
||||||
|
def now() -> str:
|
||||||
|
return datetime.now(timezone.utc).isoformat()
|
||||||
|
|
||||||
|
|
||||||
|
class ChargePoint(OcppChargePoint):
|
||||||
|
@on(Action.boot_notification)
|
||||||
|
async def on_boot_notification(self, charge_point_vendor, charge_point_model, **kwargs):
|
||||||
|
log.info(
|
||||||
|
"BootNotification: vendor=%r model=%r extra=%r",
|
||||||
|
charge_point_vendor, charge_point_model, kwargs,
|
||||||
|
)
|
||||||
|
return call_result.BootNotification(
|
||||||
|
current_time=now(), interval=30, status=RegistrationStatus.accepted
|
||||||
|
)
|
||||||
|
|
||||||
|
@on(Action.heartbeat)
|
||||||
|
async def on_heartbeat(self):
|
||||||
|
return call_result.Heartbeat(current_time=now())
|
||||||
|
|
||||||
|
@on(Action.status_notification)
|
||||||
|
async def on_status_notification(self, connector_id, error_code, status, **kwargs):
|
||||||
|
log.info(
|
||||||
|
"StatusNotification: connector=%s status=%s error=%s extra=%r",
|
||||||
|
connector_id, status, error_code, kwargs,
|
||||||
|
)
|
||||||
|
return call_result.StatusNotification()
|
||||||
|
|
||||||
|
@on(Action.authorize)
|
||||||
|
async def on_authorize(self, id_tag, **kwargs):
|
||||||
|
log.info("Authorize: id_tag=%r", id_tag)
|
||||||
|
return call_result.Authorize(id_tag_info={"status": AuthorizationStatus.accepted})
|
||||||
|
|
||||||
|
@on(Action.start_transaction)
|
||||||
|
async def on_start_transaction(self, connector_id, id_tag, meter_start, timestamp, **kwargs):
|
||||||
|
log.info(
|
||||||
|
"StartTransaction: connector=%s id_tag=%r meter_start=%s",
|
||||||
|
connector_id, id_tag, meter_start,
|
||||||
|
)
|
||||||
|
return call_result.StartTransaction(
|
||||||
|
transaction_id=1,
|
||||||
|
id_tag_info={"status": AuthorizationStatus.accepted},
|
||||||
|
)
|
||||||
|
|
||||||
|
@on(Action.stop_transaction)
|
||||||
|
async def on_stop_transaction(self, meter_stop, timestamp, transaction_id, **kwargs):
|
||||||
|
log.info(
|
||||||
|
"StopTransaction: tx=%s meter_stop=%s extra=%r",
|
||||||
|
transaction_id, meter_stop, kwargs,
|
||||||
|
)
|
||||||
|
return call_result.StopTransaction(
|
||||||
|
id_tag_info={"status": AuthorizationStatus.accepted}
|
||||||
|
)
|
||||||
|
|
||||||
|
@on(Action.meter_values)
|
||||||
|
async def on_meter_values(self, connector_id, meter_value, **kwargs):
|
||||||
|
log.info("MeterValues: connector=%s values=%r", connector_id, meter_value)
|
||||||
|
return call_result.MeterValues()
|
||||||
|
|
||||||
|
@on(Action.data_transfer)
|
||||||
|
async def on_data_transfer(self, vendor_id, **kwargs):
|
||||||
|
log.info("DataTransfer: vendor_id=%r extra=%r", vendor_id, kwargs)
|
||||||
|
return call_result.DataTransfer(status=DataTransferStatus.accepted)
|
||||||
|
|
||||||
|
@on(Action.firmware_status_notification)
|
||||||
|
async def on_firmware_status(self, status, **kwargs):
|
||||||
|
log.info("FirmwareStatusNotification: %s", status)
|
||||||
|
return call_result.FirmwareStatusNotification()
|
||||||
|
|
||||||
|
@on(Action.diagnostics_status_notification)
|
||||||
|
async def on_diagnostics_status(self, status, **kwargs):
|
||||||
|
log.info("DiagnosticsStatusNotification: %s", status)
|
||||||
|
return call_result.DiagnosticsStatusNotification()
|
||||||
|
|
||||||
|
|
||||||
|
async def on_connect(connection):
|
||||||
|
path = connection.request.path
|
||||||
|
charge_point_id = path.strip("/").split("/")[-1] or "unknown"
|
||||||
|
log.info(
|
||||||
|
"Connection from %s | path=%r -> charge_point_id=%r | subprotocol=%r",
|
||||||
|
connection.remote_address, path, charge_point_id, connection.subprotocol,
|
||||||
|
)
|
||||||
|
if connection.subprotocol is None:
|
||||||
|
log.warning(
|
||||||
|
"Charge point %r connected WITHOUT an ocpp subprotocol header. "
|
||||||
|
"Handling it anyway so we can see its traffic.",
|
||||||
|
charge_point_id,
|
||||||
|
)
|
||||||
|
cp = ChargePoint(charge_point_id, connection)
|
||||||
|
try:
|
||||||
|
await cp.start()
|
||||||
|
except websockets.exceptions.ConnectionClosed:
|
||||||
|
log.info("Charge point %r disconnected", charge_point_id)
|
||||||
|
|
||||||
|
|
||||||
|
async def process_request(connection, request):
|
||||||
|
"""Log every inbound HTTP/WS request line so we see even failed attempts."""
|
||||||
|
log.info(
|
||||||
|
"HTTP request from %s: %s %s | headers=%s",
|
||||||
|
connection.remote_address,
|
||||||
|
request.method if hasattr(request, "method") else "?",
|
||||||
|
request.path,
|
||||||
|
dict(request.headers),
|
||||||
|
)
|
||||||
|
return None # let the handshake proceed normally
|
||||||
|
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
# select_subprotocol tolerates clients that omit the ocpp1.6 header
|
||||||
|
# (some cheap firmwares do), so we still see their traffic instead of a 400.
|
||||||
|
def select_subprotocol(connection, subprotocols):
|
||||||
|
return "ocpp1.6"
|
||||||
|
|
||||||
|
server = await websockets.serve(
|
||||||
|
on_connect,
|
||||||
|
"0.0.0.0",
|
||||||
|
9000,
|
||||||
|
subprotocols=["ocpp1.6"],
|
||||||
|
select_subprotocol=select_subprotocol,
|
||||||
|
process_request=process_request,
|
||||||
|
)
|
||||||
|
log.info("OCPP 1.6J CSMS listening on ws://0.0.0.0:9000/<charge_point_id>")
|
||||||
|
await server.wait_closed()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
asyncio.run(main())
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
"""Dumb TCP listener on :9000 — logs the raw first bytes of anything that
|
||||||
|
connects, then closes. Use to see whether the charger reaches us at all and
|
||||||
|
what it actually sends (valid WS handshake? garbage? YKC binary?).
|
||||||
|
|
||||||
|
Run: .venv/bin/python rawlisten.py (stop csms.py first — same port)
|
||||||
|
"""
|
||||||
|
import functools
|
||||||
|
import socket
|
||||||
|
import sys
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
# force line-buffered output so logs appear immediately even when piped to a file
|
||||||
|
print = functools.partial(print, flush=True) # noqa: A001
|
||||||
|
sys.stdout.reconfigure(line_buffering=True)
|
||||||
|
|
||||||
|
HOST, PORT = "0.0.0.0", 9000
|
||||||
|
|
||||||
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
|
s.bind((HOST, PORT))
|
||||||
|
s.listen(5)
|
||||||
|
print(f"raw TCP listener on {HOST}:{PORT} — waiting for any connection...")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
conn, addr = s.accept()
|
||||||
|
ts = datetime.now().isoformat(timespec="seconds")
|
||||||
|
print(f"\n[{ts}] CONNECTION from {addr[0]}:{addr[1]}")
|
||||||
|
conn.settimeout(3.0)
|
||||||
|
try:
|
||||||
|
data = conn.recv(4096)
|
||||||
|
if data:
|
||||||
|
print(f" {len(data)} bytes, first line / hex:")
|
||||||
|
# printable view
|
||||||
|
try:
|
||||||
|
text = data.decode("utf-8", errors="replace")
|
||||||
|
for line in text.splitlines()[:20]:
|
||||||
|
print(f" | {line}")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
print(f" hex[:64]: {data[:64].hex(' ')}")
|
||||||
|
else:
|
||||||
|
print(" connected but sent no data (then closed)")
|
||||||
|
except socket.timeout:
|
||||||
|
print(" connected but sent nothing within 3s")
|
||||||
|
finally:
|
||||||
|
conn.close()
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
attrs==26.1.0
|
||||||
|
jsonschema==4.26.0
|
||||||
|
jsonschema-specifications==2025.9.1
|
||||||
|
ocpp==2.1.0
|
||||||
|
pypdf==6.14.2
|
||||||
|
referencing==0.37.0
|
||||||
|
rpds-py==2026.6.3
|
||||||
|
websockets==16.0
|
||||||
@@ -0,0 +1,251 @@
|
|||||||
|
"""Private OCPP 1.6J controller for a home EV charger.
|
||||||
|
|
||||||
|
Beyond the minimal csms.py, this adds:
|
||||||
|
* An allowlist of authorized idTags (RFID cards, autocharge/vehicle IDs, app tokens).
|
||||||
|
* A "learn mode" that accepts + records any unseen idTag, so you can discover what
|
||||||
|
your cards send and whether your car presents an autocharge id on plug-in.
|
||||||
|
* Live state tracking + a registry of connected chargers, so a control app (added
|
||||||
|
next) can trigger RemoteStartTransaction / RemoteStopTransaction.
|
||||||
|
|
||||||
|
Config lives in station_config.json next to this file:
|
||||||
|
{
|
||||||
|
"learn_mode": true,
|
||||||
|
"authorized": { "<idTag>": {"name": "Home card", "kind": "card|car|app"} }
|
||||||
|
}
|
||||||
|
|
||||||
|
Workflow:
|
||||||
|
1. Run in learn_mode (default). Tap each card / plug in each car once.
|
||||||
|
2. Read the captured ids from the log or seen_tags.json.
|
||||||
|
3. Move the ones you want into "authorized" in station_config.json, name them.
|
||||||
|
4. Set "learn_mode": false and restart -> only your ids are accepted.
|
||||||
|
|
||||||
|
Run: venv/Scripts/python station.py
|
||||||
|
"""
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
from collections import deque
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import websockets
|
||||||
|
|
||||||
|
from ocpp.routing import on
|
||||||
|
from ocpp.v16 import ChargePoint as OcppChargePoint
|
||||||
|
from ocpp.v16 import call, call_result
|
||||||
|
from ocpp.v16.enums import (
|
||||||
|
Action,
|
||||||
|
AuthorizationStatus,
|
||||||
|
DataTransferStatus,
|
||||||
|
RegistrationStatus,
|
||||||
|
)
|
||||||
|
|
||||||
|
HERE = Path(__file__).resolve().parent
|
||||||
|
CONFIG_PATH = HERE / "station_config.json"
|
||||||
|
SEEN_PATH = HERE / "seen_tags.json"
|
||||||
|
|
||||||
|
logging.basicConfig(
|
||||||
|
level=logging.INFO,
|
||||||
|
format="%(asctime)s %(levelname)s %(name)s | %(message)s",
|
||||||
|
)
|
||||||
|
log = logging.getLogger("station")
|
||||||
|
|
||||||
|
|
||||||
|
def now() -> str:
|
||||||
|
return datetime.now(timezone.utc).isoformat()
|
||||||
|
|
||||||
|
|
||||||
|
# ---- shared runtime state (the control app added next reads/uses these) ----
|
||||||
|
CONNECTED: dict = {} # cp_id -> ChargePoint instance (for remote control)
|
||||||
|
CONNECTORS: dict = {} # (cp_id, connector_id) -> latest status string
|
||||||
|
ACTIVE_TX: dict = {} # transaction_id -> {cp, connector, id_tag, meter_start, started}
|
||||||
|
AUTH_EVENTS = deque(maxlen=50) # recent authorization attempts (for the app UI)
|
||||||
|
_tx_counter = {"n": 0}
|
||||||
|
|
||||||
|
|
||||||
|
def load_config() -> dict:
|
||||||
|
if CONFIG_PATH.exists():
|
||||||
|
cfg = json.loads(CONFIG_PATH.read_text(encoding="utf-8"))
|
||||||
|
else:
|
||||||
|
cfg = {"learn_mode": True, "authorized": {}}
|
||||||
|
CONFIG_PATH.write_text(json.dumps(cfg, indent=2), encoding="utf-8")
|
||||||
|
log.info("Created default %s (learn_mode=on, empty allowlist)", CONFIG_PATH.name)
|
||||||
|
cfg.setdefault("learn_mode", True)
|
||||||
|
cfg.setdefault("authorized", {})
|
||||||
|
return cfg
|
||||||
|
|
||||||
|
|
||||||
|
CONFIG = load_config()
|
||||||
|
|
||||||
|
|
||||||
|
def record_seen(id_tag: str, context: str) -> None:
|
||||||
|
"""Append/refresh an entry in seen_tags.json so you can harvest ids later."""
|
||||||
|
try:
|
||||||
|
seen = json.loads(SEEN_PATH.read_text(encoding="utf-8")) if SEEN_PATH.exists() else {}
|
||||||
|
except Exception:
|
||||||
|
seen = {}
|
||||||
|
entry = seen.get(id_tag, {"count": 0, "first_seen": now(), "contexts": []})
|
||||||
|
entry["count"] += 1
|
||||||
|
entry["last_seen"] = now()
|
||||||
|
if context not in entry["contexts"]:
|
||||||
|
entry["contexts"].append(context)
|
||||||
|
seen[id_tag] = entry
|
||||||
|
SEEN_PATH.write_text(json.dumps(seen, indent=2), encoding="utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
def decide(id_tag: str, context: str) -> AuthorizationStatus:
|
||||||
|
"""The one gate every auth method flows through: is this idTag allowed?"""
|
||||||
|
known = id_tag in CONFIG["authorized"]
|
||||||
|
if known:
|
||||||
|
name = CONFIG["authorized"][id_tag].get("name", "?")
|
||||||
|
log.info("[OK] AUTHORIZED idTag=%r (%s) via %s", id_tag, name, context)
|
||||||
|
status = AuthorizationStatus.accepted
|
||||||
|
elif CONFIG.get("learn_mode"):
|
||||||
|
log.warning(
|
||||||
|
"[LEARN] NEW idTag=%r via %s -> accepting & recording. "
|
||||||
|
"Add it to 'authorized' in %s, then set learn_mode=false to enforce.",
|
||||||
|
id_tag, context, CONFIG_PATH.name,
|
||||||
|
)
|
||||||
|
record_seen(id_tag, context)
|
||||||
|
status = AuthorizationStatus.accepted
|
||||||
|
else:
|
||||||
|
log.warning("[NO] REJECTED unknown idTag=%r via %s", id_tag, context)
|
||||||
|
record_seen(id_tag, context)
|
||||||
|
status = AuthorizationStatus.invalid
|
||||||
|
AUTH_EVENTS.append(
|
||||||
|
{"time": now(), "id_tag": id_tag, "context": context,
|
||||||
|
"result": status.value, "known": known}
|
||||||
|
)
|
||||||
|
return status
|
||||||
|
|
||||||
|
|
||||||
|
class ChargePoint(OcppChargePoint):
|
||||||
|
@on(Action.boot_notification)
|
||||||
|
async def on_boot_notification(self, charge_point_vendor, charge_point_model, **kwargs):
|
||||||
|
log.info("BootNotification: vendor=%r model=%r extra=%r",
|
||||||
|
charge_point_vendor, charge_point_model, kwargs)
|
||||||
|
return call_result.BootNotification(
|
||||||
|
current_time=now(), interval=30, status=RegistrationStatus.accepted
|
||||||
|
)
|
||||||
|
|
||||||
|
@on(Action.heartbeat)
|
||||||
|
async def on_heartbeat(self):
|
||||||
|
return call_result.Heartbeat(current_time=now())
|
||||||
|
|
||||||
|
@on(Action.status_notification)
|
||||||
|
async def on_status_notification(self, connector_id, error_code, status, **kwargs):
|
||||||
|
CONNECTORS[(self.id, connector_id)] = status
|
||||||
|
log.info("StatusNotification: connector=%s status=%s error=%s",
|
||||||
|
connector_id, status, error_code)
|
||||||
|
return call_result.StatusNotification()
|
||||||
|
|
||||||
|
@on(Action.authorize)
|
||||||
|
async def on_authorize(self, id_tag, **kwargs):
|
||||||
|
# RFID card tap, or app pre-auth. Plug-in autocharge sometimes lands here too.
|
||||||
|
status = decide(id_tag, "Authorize (card/app/autocharge)")
|
||||||
|
return call_result.Authorize(id_tag_info={"status": status})
|
||||||
|
|
||||||
|
@on(Action.start_transaction)
|
||||||
|
async def on_start_transaction(self, connector_id, id_tag, meter_start, timestamp, **kwargs):
|
||||||
|
status = decide(id_tag, f"StartTransaction (connector {connector_id})")
|
||||||
|
if status == AuthorizationStatus.accepted:
|
||||||
|
_tx_counter["n"] += 1
|
||||||
|
tx = _tx_counter["n"]
|
||||||
|
ACTIVE_TX[tx] = {
|
||||||
|
"cp": self.id, "connector": connector_id, "id_tag": id_tag,
|
||||||
|
"meter_start": meter_start, "started": now(),
|
||||||
|
}
|
||||||
|
log.info("Transaction %s STARTED on connector %s (meter_start=%s)",
|
||||||
|
tx, connector_id, meter_start)
|
||||||
|
else:
|
||||||
|
tx = 0 # 0 tells the charger the transaction is not authorized
|
||||||
|
return call_result.StartTransaction(
|
||||||
|
transaction_id=tx, id_tag_info={"status": status}
|
||||||
|
)
|
||||||
|
|
||||||
|
@on(Action.stop_transaction)
|
||||||
|
async def on_stop_transaction(self, meter_stop, timestamp, transaction_id, **kwargs):
|
||||||
|
info = ACTIVE_TX.pop(transaction_id, None)
|
||||||
|
used = (meter_stop - info["meter_start"]) if info else "?"
|
||||||
|
log.info("Transaction %s STOPPED (meter_stop=%s, delivered=%s Wh)",
|
||||||
|
transaction_id, meter_stop, used)
|
||||||
|
return call_result.StopTransaction(
|
||||||
|
id_tag_info={"status": AuthorizationStatus.accepted}
|
||||||
|
)
|
||||||
|
|
||||||
|
@on(Action.meter_values)
|
||||||
|
async def on_meter_values(self, connector_id, meter_value, **kwargs):
|
||||||
|
log.info("MeterValues: connector=%s values=%r", connector_id, meter_value)
|
||||||
|
return call_result.MeterValues()
|
||||||
|
|
||||||
|
@on(Action.data_transfer)
|
||||||
|
async def on_data_transfer(self, vendor_id, **kwargs):
|
||||||
|
log.info("DataTransfer: vendor_id=%r extra=%r", vendor_id, kwargs)
|
||||||
|
return call_result.DataTransfer(status=DataTransferStatus.accepted)
|
||||||
|
|
||||||
|
@on(Action.firmware_status_notification)
|
||||||
|
async def on_firmware_status(self, status, **kwargs):
|
||||||
|
log.info("FirmwareStatusNotification: %s", status)
|
||||||
|
return call_result.FirmwareStatusNotification()
|
||||||
|
|
||||||
|
@on(Action.diagnostics_status_notification)
|
||||||
|
async def on_diagnostics_status(self, status, **kwargs):
|
||||||
|
log.info("DiagnosticsStatusNotification: %s", status)
|
||||||
|
return call_result.DiagnosticsStatusNotification()
|
||||||
|
|
||||||
|
|
||||||
|
# ---- helpers the control app (added next) will call to drive the charger ----
|
||||||
|
async def remote_start(cp_id: str, id_tag: str, connector_id: int = 1) -> str:
|
||||||
|
cp = CONNECTED.get(cp_id)
|
||||||
|
if cp is None:
|
||||||
|
raise RuntimeError(f"charge point {cp_id!r} is not connected")
|
||||||
|
resp = await cp.call(call.RemoteStartTransaction(id_tag=id_tag, connector_id=connector_id))
|
||||||
|
log.info("RemoteStartTransaction(%s, connector=%s) -> %s", id_tag, connector_id, resp.status)
|
||||||
|
return resp.status
|
||||||
|
|
||||||
|
|
||||||
|
async def remote_stop(transaction_id: int) -> str:
|
||||||
|
info = ACTIVE_TX.get(transaction_id)
|
||||||
|
if info is None:
|
||||||
|
raise RuntimeError(f"no active transaction {transaction_id}")
|
||||||
|
cp = CONNECTED.get(info["cp"])
|
||||||
|
if cp is None:
|
||||||
|
raise RuntimeError("charge point is not connected")
|
||||||
|
resp = await cp.call(call.RemoteStopTransaction(transaction_id=transaction_id))
|
||||||
|
log.info("RemoteStopTransaction(%s) -> %s", transaction_id, resp.status)
|
||||||
|
return resp.status
|
||||||
|
|
||||||
|
|
||||||
|
async def on_connect(connection):
|
||||||
|
path = connection.request.path
|
||||||
|
cp_id = path.strip("/").split("/")[-1] or "unknown"
|
||||||
|
log.info("Charger connected: id=%r from %s subprotocol=%r",
|
||||||
|
cp_id, connection.remote_address, connection.subprotocol)
|
||||||
|
cp = ChargePoint(cp_id, connection)
|
||||||
|
CONNECTED[cp_id] = cp
|
||||||
|
try:
|
||||||
|
await cp.start()
|
||||||
|
except websockets.exceptions.ConnectionClosed:
|
||||||
|
log.info("Charger %r disconnected", cp_id)
|
||||||
|
finally:
|
||||||
|
CONNECTED.pop(cp_id, None)
|
||||||
|
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
def select_subprotocol(connection, subprotocols):
|
||||||
|
return "ocpp1.6"
|
||||||
|
|
||||||
|
server = await websockets.serve(
|
||||||
|
on_connect, "0.0.0.0", 9000,
|
||||||
|
subprotocols=["ocpp1.6"],
|
||||||
|
select_subprotocol=select_subprotocol,
|
||||||
|
)
|
||||||
|
mode = "LEARN (accepting & recording new ids)" if CONFIG["learn_mode"] else "ENFORCING allowlist"
|
||||||
|
log.info("Private CSMS on ws://0.0.0.0:9000/<id> | mode: %s | %d authorized id(s)",
|
||||||
|
mode, len(CONFIG["authorized"]))
|
||||||
|
await server.wait_closed()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
asyncio.run(main())
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"learn_mode": true,
|
||||||
|
"authorized": {}
|
||||||
|
}
|
||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
Vendored
+33
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"file-explorer": true,
|
||||||
|
"global-search": true,
|
||||||
|
"switcher": true,
|
||||||
|
"graph": true,
|
||||||
|
"backlink": true,
|
||||||
|
"canvas": true,
|
||||||
|
"outgoing-link": true,
|
||||||
|
"tag-pane": true,
|
||||||
|
"footnotes": false,
|
||||||
|
"properties": true,
|
||||||
|
"page-preview": true,
|
||||||
|
"daily-notes": true,
|
||||||
|
"templates": true,
|
||||||
|
"note-composer": true,
|
||||||
|
"command-palette": true,
|
||||||
|
"slash-command": false,
|
||||||
|
"editor-status": true,
|
||||||
|
"bookmarks": true,
|
||||||
|
"markdown-importer": false,
|
||||||
|
"zk-prefixer": false,
|
||||||
|
"random-note": false,
|
||||||
|
"outline": true,
|
||||||
|
"word-count": true,
|
||||||
|
"slides": false,
|
||||||
|
"audio-recorder": false,
|
||||||
|
"workspaces": false,
|
||||||
|
"file-recovery": true,
|
||||||
|
"publish": false,
|
||||||
|
"sync": true,
|
||||||
|
"bases": true,
|
||||||
|
"webviewer": false
|
||||||
|
}
|
||||||
Vendored
+22
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"collapse-filter": true,
|
||||||
|
"search": "",
|
||||||
|
"showTags": false,
|
||||||
|
"showAttachments": false,
|
||||||
|
"hideUnresolved": false,
|
||||||
|
"showOrphans": true,
|
||||||
|
"collapse-color-groups": true,
|
||||||
|
"colorGroups": [],
|
||||||
|
"collapse-display": true,
|
||||||
|
"showArrow": false,
|
||||||
|
"textFadeMultiplier": 0,
|
||||||
|
"nodeSizeMultiplier": 1,
|
||||||
|
"lineSizeMultiplier": 1,
|
||||||
|
"collapse-forces": true,
|
||||||
|
"centerStrength": 0.518713248970312,
|
||||||
|
"repelStrength": 10,
|
||||||
|
"linkStrength": 1,
|
||||||
|
"linkDistance": 250,
|
||||||
|
"scale": 1,
|
||||||
|
"close": true
|
||||||
|
}
|
||||||
Vendored
+201
@@ -0,0 +1,201 @@
|
|||||||
|
{
|
||||||
|
"main": {
|
||||||
|
"id": "845e7cc05ff72205",
|
||||||
|
"type": "split",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "c87b25e7f6c6596d",
|
||||||
|
"type": "tabs",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "071e92b44b13465b",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "empty",
|
||||||
|
"state": {},
|
||||||
|
"icon": "lucide-file",
|
||||||
|
"title": "New tab"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "b805d2e359ad49be",
|
||||||
|
"type": "tabs",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "dd91c0d1025f5890",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "graph",
|
||||||
|
"state": {},
|
||||||
|
"icon": "lucide-git-fork",
|
||||||
|
"title": "Graph view"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"direction": "vertical"
|
||||||
|
},
|
||||||
|
"left": {
|
||||||
|
"id": "a06802947500e445",
|
||||||
|
"type": "split",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "6bd8575a63e3dd1f",
|
||||||
|
"type": "tabs",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "3ea02b4f3a691ec9",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "file-explorer",
|
||||||
|
"state": {
|
||||||
|
"sortOrder": "alphabetical",
|
||||||
|
"autoReveal": false
|
||||||
|
},
|
||||||
|
"icon": "lucide-folder-closed",
|
||||||
|
"title": "Files"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "00dc74c738414327",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "search",
|
||||||
|
"state": {
|
||||||
|
"query": "",
|
||||||
|
"matchingCase": false,
|
||||||
|
"explainSearch": false,
|
||||||
|
"collapseAll": false,
|
||||||
|
"extraContext": false,
|
||||||
|
"sortOrder": "alphabetical"
|
||||||
|
},
|
||||||
|
"icon": "lucide-search",
|
||||||
|
"title": "Search"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "1f107c9db45dc3b9",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "bookmarks",
|
||||||
|
"state": {},
|
||||||
|
"icon": "lucide-bookmark",
|
||||||
|
"title": "Bookmarks"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"direction": "horizontal",
|
||||||
|
"width": 300
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"id": "7415e57f7aad22c6",
|
||||||
|
"type": "split",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "b67160b2e3a4972b",
|
||||||
|
"type": "tabs",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "be528c0dbc2ec0e6",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "backlink",
|
||||||
|
"state": {
|
||||||
|
"collapseAll": false,
|
||||||
|
"extraContext": false,
|
||||||
|
"sortOrder": "alphabetical",
|
||||||
|
"showSearch": false,
|
||||||
|
"searchQuery": "",
|
||||||
|
"backlinkCollapsed": false,
|
||||||
|
"unlinkedCollapsed": true
|
||||||
|
},
|
||||||
|
"icon": "links-coming-in",
|
||||||
|
"title": "Backlinks"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "c931e44020bf77d2",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "outgoing-link",
|
||||||
|
"state": {
|
||||||
|
"linksCollapsed": false,
|
||||||
|
"unlinkedCollapsed": true
|
||||||
|
},
|
||||||
|
"icon": "links-going-out",
|
||||||
|
"title": "Outgoing links"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "9be8694026ba3bcf",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "tag",
|
||||||
|
"state": {
|
||||||
|
"sortOrder": "frequency",
|
||||||
|
"useHierarchy": true,
|
||||||
|
"showSearch": false,
|
||||||
|
"searchQuery": ""
|
||||||
|
},
|
||||||
|
"icon": "lucide-tags",
|
||||||
|
"title": "Tags"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "a01f0aa6cc119a63",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "all-properties",
|
||||||
|
"state": {
|
||||||
|
"sortOrder": "frequency",
|
||||||
|
"showSearch": false,
|
||||||
|
"searchQuery": ""
|
||||||
|
},
|
||||||
|
"icon": "lucide-archive",
|
||||||
|
"title": "All properties"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "dae30b8411945c80",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "outline",
|
||||||
|
"state": {
|
||||||
|
"followCursor": false,
|
||||||
|
"showSearch": false,
|
||||||
|
"searchQuery": ""
|
||||||
|
},
|
||||||
|
"icon": "lucide-list",
|
||||||
|
"title": "Outline"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"direction": "horizontal",
|
||||||
|
"width": 300,
|
||||||
|
"collapsed": true
|
||||||
|
},
|
||||||
|
"left-ribbon": {
|
||||||
|
"hiddenItems": {
|
||||||
|
"switcher:Open quick switcher": false,
|
||||||
|
"graph:Open graph view": false,
|
||||||
|
"canvas:Create new canvas": false,
|
||||||
|
"daily-notes:Open today's daily note": false,
|
||||||
|
"templates:Insert template": false,
|
||||||
|
"command-palette:Open command palette": false,
|
||||||
|
"bases:Create new base": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"active": "071e92b44b13465b",
|
||||||
|
"lastOpenFiles": [
|
||||||
|
"raw/FINDINGS_AND_REQUIREMENTS.md",
|
||||||
|
"raw",
|
||||||
|
"Welcome.md"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
# Wiki Schema — Charging Station Knowledge Base
|
||||||
|
|
||||||
|
This directory is an LLM-maintained wiki about the **Anfu home EV charger OCPP integration project**: running a private, self-hosted OCPP 1.6J backend (CSMS) for a home charger, with RFID / vehicle / web-app authorization. The human curates sources and asks questions; the LLM (you) writes and maintains every wiki page.
|
||||||
|
|
||||||
|
The human browses this vault in Obsidian while you edit it. Related code lives in `../discovering/` (connection-test scripts — read-only context, not part of the wiki).
|
||||||
|
|
||||||
|
## Layout
|
||||||
|
|
||||||
|
```
|
||||||
|
wiki/
|
||||||
|
CLAUDE.md ← this schema (co-evolved with the human)
|
||||||
|
index.md ← catalog of every page, by category; update on every ingest
|
||||||
|
log.md ← append-only chronological record of ingests/queries/lints
|
||||||
|
overview.md ← the living synthesis: current state, what works, what's next
|
||||||
|
raw/ ← IMMUTABLE source documents. Never edit anything in here.
|
||||||
|
sources/ ← one summary page per raw source
|
||||||
|
entities/ ← pages for concrete things (devices, software, services)
|
||||||
|
concepts/ ← pages for ideas, protocols, procedures, recurring themes
|
||||||
|
notes/ ← filed answers to questions, analyses, decisions
|
||||||
|
```
|
||||||
|
|
||||||
|
## Conventions
|
||||||
|
|
||||||
|
- **Filenames**: lowercase kebab-case (`jc-6620.md`). Source pages are prefixed with ingest date: `2026-07-09-findings-and-requirements.md`.
|
||||||
|
- **Links**: Obsidian wikilinks, `[[jc-6620]]` or `[[jc-6620|JC-6620]]` when display text matters. Link liberally — links to not-yet-existing pages are fine; they mark pages worth creating.
|
||||||
|
- **Frontmatter** on every page (Dataview-friendly):
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
type: source | entity | concept | note | meta
|
||||||
|
updated: YYYY-MM-DD
|
||||||
|
tags: []
|
||||||
|
---
|
||||||
|
```
|
||||||
|
Source pages also get `raw: raw/<filename>` and `ingested: YYYY-MM-DD`.
|
||||||
|
- **Citations**: wiki pages cite the source *summary* page (e.g. "per [[2026-07-09-findings-and-requirements]]"); the summary page links to its raw file. Raw files are the ground truth.
|
||||||
|
- **Contradictions**: when a new source contradicts an existing claim, don't silently overwrite — note it inline: `> [!warning] Superseded: <old claim> (per [[old-source]]); now <new claim> (per [[new-source]])`. Resolve only when the human confirms.
|
||||||
|
- **Status markers**: this is an active hardware project, so mark claims as ✅ verified, ⚠️ untested / needs physical test, or ❓ open question. `overview.md` keeps the authoritative list of open decisions.
|
||||||
|
|
||||||
|
## Workflows
|
||||||
|
|
||||||
|
### Ingest
|
||||||
|
1. Human drops a file into `raw/` and asks to process it.
|
||||||
|
2. Read the raw source fully. Briefly discuss key takeaways with the human (what's new, what conflicts).
|
||||||
|
3. Write a summary page in `sources/` (frontmatter, TL;DR, key facts, what changed in the wiki because of it).
|
||||||
|
4. Update or create affected `entities/`, `concepts/`, and `overview.md`. Flag contradictions per the convention above.
|
||||||
|
5. Update `index.md`; append a `log.md` entry.
|
||||||
|
|
||||||
|
### Query
|
||||||
|
1. Read `index.md` first to locate relevant pages; drill into them (grep the wiki if the index isn't enough).
|
||||||
|
2. Answer with citations to wiki pages / raw sources.
|
||||||
|
3. If the answer is durable (a comparison, a decision, an analysis), offer to file it under `notes/` so it compounds.
|
||||||
|
|
||||||
|
### Lint (on request, or suggest when the wiki feels stale)
|
||||||
|
Check for: contradictions between pages, claims superseded by newer sources, orphan pages (no inbound links), concepts mentioned ≥2 times without their own page, stale `overview.md`, `index.md` entries out of sync with reality. Report findings; fix with the human's blessing.
|
||||||
|
|
||||||
|
## Log format
|
||||||
|
|
||||||
|
Append-only, newest at the bottom. Each entry starts:
|
||||||
|
|
||||||
|
```
|
||||||
|
## [YYYY-MM-DD] ingest|query|lint|meta | Short title
|
||||||
|
```
|
||||||
|
|
||||||
|
so `grep "^## \[" log.md | tail -5` shows recent activity. Body: 1–4 lines on what was done and which pages were touched.
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
type: concept
|
||||||
|
updated: 2026-07-09
|
||||||
|
tags: [auth, requirements]
|
||||||
|
---
|
||||||
|
|
||||||
|
# Authorization Methods
|
||||||
|
|
||||||
|
The three planned ways to authorize a charging session. Architecturally they all collapse to one gate: **`decide(id_tag)` in `station.py`** ([[csms-toolkit]]) returns Accepted/Rejected against the allowlist in `station_config.json`. Per [[2026-07-09-findings-and-requirements]]:
|
||||||
|
|
||||||
|
## 1. RFID cards — ✅ mechanism built, enrollment pending
|
||||||
|
|
||||||
|
Use the cards already owned. Flow: enable learn mode → tap each card once → harvest its idTag from `seen_tags.json` → add to `authorized` with a name (`kind: "card"`) → set `learn_mode=false` to enforce.
|
||||||
|
|
||||||
|
## 2. By vehicle / chassis — ⚠️ needs a physical test
|
||||||
|
|
||||||
|
True VIN-based **ISO 15118 Plug & Charge is unlikely** on a basic AC unit. The realistic option is **Autocharge**: some chargers automatically send a per-vehicle idTag when a car plugs in, no card tap needed.
|
||||||
|
|
||||||
|
**The test:** plug the car in *without* tapping a card. If a stable idTag shows up in `seen_tags.json`, whitelist it as `kind: "car"` and "by vehicle" works. If nothing appears, this method is not achievable on the [[anfu-charger|Anfu hardware]] — drop it.
|
||||||
|
|
||||||
|
## 3. Mobile / web app — 📋 to build
|
||||||
|
|
||||||
|
A mobile-friendly web control panel (no app store):
|
||||||
|
|
||||||
|
- Start/Stop via OCPP `RemoteStartTransaction` / `RemoteStopTransaction`
|
||||||
|
- Live charger status
|
||||||
|
- Clickable allowlist management
|
||||||
|
- Bound to `0.0.0.0`, reached only over [[netbird|NetBird]]; optional PIN/token for defense-in-depth (❓ open decision, see [[overview]])
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
type: concept
|
||||||
|
updated: 2026-07-09
|
||||||
|
tags: [network]
|
||||||
|
---
|
||||||
|
|
||||||
|
# Network Topology
|
||||||
|
|
||||||
|
How the [[anfu-charger|charging pile]]'s internal network sits behind the household network. Per [[2026-07-09-findings-and-requirements]]:
|
||||||
|
|
||||||
|
```
|
||||||
|
10.0.10.0/24 (upstream / WAN — main gateway lives here)
|
||||||
|
│
|
||||||
|
┌──┴────────────────┐
|
||||||
|
│ Four-Faith router │ WAN gets a 10.0.10.x address; NAT boundary
|
||||||
|
└──┬────────────────┘
|
||||||
|
│ LAN = 192.168.2.1 (mask 255.255.255.0)
|
||||||
|
├── 192.168.2.228 JC-6620 OCPP controller ← the OCPP client
|
||||||
|
├── 192.168.2.118 EV charging controller (main board), DHCP
|
||||||
|
└── 192.168.2.114 maintenance PC (LAN side)
|
||||||
|
```
|
||||||
|
|
||||||
|
- Wiring is the manufacturer's **star** topology: the EV controller and the [[jc-6620|JC-6620]]'s fixed-IP (right) port each plug into a router LAN1–4 port.
|
||||||
|
- **Traffic direction matters:** the JC-6620 dials *outbound* to the CSMS, so NAT just works — ✅ no port-forwarding needed on the Four-Faith router. Port-forwarding would only matter for inbound connections, which don't occur.
|
||||||
|
- A CSMS can live either on the charger LAN (`192.168.2.x`) or upstream on the WAN subnet (`10.0.10.x`) — both ✅ verified — **provided** the JC-6620's default gateway is `192.168.2.1` (it shipped pointing at itself; see [[troubleshooting]]).
|
||||||
|
- The CSMS host itself must allow inbound TCP 9000 and keep a stable IP (see [[csms-toolkit]]).
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
type: concept
|
||||||
|
updated: 2026-07-09
|
||||||
|
tags: [protocol]
|
||||||
|
---
|
||||||
|
|
||||||
|
# OCPP 1.6J
|
||||||
|
|
||||||
|
**Open Charge Point Protocol**, version 1.6, JSON variant ("J") — the protocol between a charge point and its backend (**CSMS**, Charging Station Management System). Messages are JSON frames over a WebSocket that the *charge point* opens toward the CSMS.
|
||||||
|
|
||||||
|
How it maps onto this project:
|
||||||
|
|
||||||
|
- **Charge point / client:** the [[jc-6620|JC-6620]] inside the [[anfu-charger|Anfu pile]]
|
||||||
|
- **CSMS / server:** the [[csms-toolkit]] scripts, listening on `ws://0.0.0.0:9000/<chargePointId>`
|
||||||
|
- **Messages in play so far:**
|
||||||
|
- `BootNotification` — ✅ full exchange verified in both LAN and WAN setups (per [[2026-07-09-findings-and-requirements]])
|
||||||
|
- `Authorize` — carries the idTag that `decide(id_tag)` accepts/rejects; the heart of [[authorization]]
|
||||||
|
- `RemoteStartTransaction` / `RemoteStopTransaction` — the CSMS-initiated calls the future web panel will use
|
||||||
|
|
||||||
|
Because the charge point is always the connecting party, the CSMS needs a reachable, stable address — but the charger network needs no inbound rules (see [[network-topology]]).
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
type: concept
|
||||||
|
updated: 2026-07-09
|
||||||
|
tags: [troubleshooting, gotchas]
|
||||||
|
---
|
||||||
|
|
||||||
|
# Troubleshooting Checklist
|
||||||
|
|
||||||
|
Hard-won gotchas from getting the first connection working. **If the charger "never connects," check these in order.** Per [[2026-07-09-findings-and-requirements]]:
|
||||||
|
|
||||||
|
1. **CSMS host firewall** — inbound TCP 9000 must be allowed. Windows silently drops otherwise; looks identical to "charger never dials."
|
||||||
|
2. **`Billing Mode` must be `BackgroundBilling`** — until it is, the [[jc-6620|JC-6620]] never dials out *at all* (zero TCP SYNs on the wire). This was the blocker for the very first connection.
|
||||||
|
3. **`Communication Method` must be `Ethernet`** — not 4G/SIM.
|
||||||
|
4. **Power-cycle after changes** — URL / network changes on the [[anfu-charger|touchscreen]] only take effect after power-cycling the pile.
|
||||||
|
5. **JC-6620 default gateway must be `192.168.2.1`** — it shipped as `192.168.2.228` (itself). Symptom: a same-subnet (`192.168.2.x`) CSMS works but an off-subnet (`10.0.10.x`) one silently doesn't.
|
||||||
|
6. **No port-forwarding needed** — the JC-6620 is the client and dials outbound; see [[network-topology]]. Don't waste time on the router's forwarding rules.
|
||||||
|
7. **CSMS host IP must be stable** — the touchscreen URL is hardcoded; a DHCP-shifted host looks like a dead CSMS.
|
||||||
|
|
||||||
|
Diagnostic ladder (from [[csms-toolkit]]): `rawlisten.py` (do *any* bytes arrive?) → `csms.py` (does OCPP handshake complete?) → `station.py` (full controller).
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
type: entity
|
||||||
|
updated: 2026-07-09
|
||||||
|
tags: [hardware]
|
||||||
|
---
|
||||||
|
|
||||||
|
# Anfu Home Charger (charging pile)
|
||||||
|
|
||||||
|
The physical home EV charger this whole project revolves around. It is not a single device but a small network of three, behind its own Four-Faith router (see [[network-topology]]). Per [[2026-07-09-findings-and-requirements]]:
|
||||||
|
|
||||||
|
- **[[jc-6620|JC-6620]]** (`192.168.2.228`) — OCPP communication controller; the OCPP client that dials the CSMS
|
||||||
|
- **EV charging controller** (`192.168.2.118`, DHCP) — the main control board that actually manages charging; the JC-6620 talks to it on port 2403
|
||||||
|
- **Touchscreen** — where all charger-side configuration happens
|
||||||
|
|
||||||
|
## Touchscreen configuration (working values)
|
||||||
|
|
||||||
|
| Screen | Setting | Value |
|
||||||
|
|---|---|---|
|
||||||
|
| General Settings → Charger INEO | URL | `ws://<CSMS-IP>:9000` |
|
||||||
|
| General Settings → Charger INEO | ChargerID | any |
|
||||||
|
| Back Office → Universal | Billing Mode | **`BackgroundBilling`** (required — see [[troubleshooting]]) |
|
||||||
|
| Back Office → Universal | Communication Method | `Ethernet` (not 4G/SIM) |
|
||||||
|
| Back Office → Universal | JC-6620 IP / Port | `192.168.2.228` / `2403` |
|
||||||
|
|
||||||
|
> [!warning] Power-cycle required
|
||||||
|
> URL or network changes only take effect after power-cycling the pile.
|
||||||
|
|
||||||
|
## Capabilities in question
|
||||||
|
|
||||||
|
- ✅ OCPP 1.6J over WebSocket — verified working
|
||||||
|
- ⚠️ Autocharge (per-vehicle idTag on plug-in) — needs a physical test; see [[authorization]]
|
||||||
|
- ❌ True ISO 15118 Plug & Charge — unlikely on a basic AC unit
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
type: entity
|
||||||
|
updated: 2026-07-09
|
||||||
|
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]]:
|
||||||
|
|
||||||
|
| 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": { "<idTag>": {name, kind} } }` |
|
||||||
|
| `seen_tags.json` | Auto-recorded log of every idTag observed (discovery / Autocharge testing). |
|
||||||
|
|
||||||
|
- **Runtime:** Python venv with `websockets` 16.0 + `ocpp`; listens on `ws://0.0.0.0:9000/<chargePointId>`.
|
||||||
|
- **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.
|
||||||
|
|
||||||
|
## Still to build
|
||||||
|
|
||||||
|
The web control panel (remote start/stop, live status, allowlist management) served behind [[netbird|NetBird]] — see [[overview]] for the plan and open host decision.
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
type: entity
|
||||||
|
updated: 2026-07-09
|
||||||
|
tags: [hardware, ocpp-client]
|
||||||
|
---
|
||||||
|
|
||||||
|
# JC-6620 — OCPP Communication Controller
|
||||||
|
|
||||||
|
The dedicated OCPP communication controller inside the [[anfu-charger|Anfu charging pile]]. **This is the device that acts as the OCPP client** — it opens the outbound WebSocket to the CSMS. (Per [[2026-07-09-findings-and-requirements]].)
|
||||||
|
|
||||||
|
## Network identity
|
||||||
|
|
||||||
|
- Static IP **`192.168.2.228`**, mask `255.255.255.0`, on the charger's internal LAN (see [[network-topology]])
|
||||||
|
- Default gateway must be **`192.168.2.1`** (the Four-Faith router)
|
||||||
|
- DNS not needed — the CSMS URL is a bare IP
|
||||||
|
- Talks to the EV charging controller (`192.168.2.118`) locally on port **2403**
|
||||||
|
|
||||||
|
## Gotchas specific to this device
|
||||||
|
|
||||||
|
> [!warning] Shipped misconfigured
|
||||||
|
> The JC-6620 arrived with its default gateway set to `192.168.2.228` — **pointing at itself**. That works for a same-subnet CSMS but cannot route to the WAN, which is why a `192.168.2.x` CSMS worked while a `10.0.10.x` CSMS silently didn't, until the gateway was corrected. (Config screen is in Chinese: 静态 IP = static IP, 默认网关 = default gateway.)
|
||||||
|
|
||||||
|
- It only dials out at all once the touchscreen's `Billing Mode = BackgroundBilling` is set — see [[troubleshooting]].
|
||||||
|
- Network/URL changes require a full pile power-cycle to take effect.
|
||||||
|
|
||||||
|
## Verified behavior ✅
|
||||||
|
|
||||||
|
Connected and completed the full BootNotification exchange against both a LAN CSMS (`192.168.2.114:9000`) and a WAN CSMS (`10.0.10.203:9000`). Since it's the *client*, no port-forwarding is needed on the charger router — NAT handles the outbound connection.
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
type: entity
|
||||||
|
updated: 2026-07-09
|
||||||
|
tags: [software, network, security]
|
||||||
|
---
|
||||||
|
|
||||||
|
# NetBird
|
||||||
|
|
||||||
|
The WireGuard-based private overlay network the household already runs. Its role in this project: **the security boundary for the web control panel** — the panel binds to `0.0.0.0` but is only reachable over the NetBird network, so nothing is exposed to the public internet. (Per [[2026-07-09-findings-and-requirements]].)
|
||||||
|
|
||||||
|
Related open decisions (tracked in [[overview]]):
|
||||||
|
|
||||||
|
- ❓ Rely on NetBird isolation alone, or add a PIN/access token to the web app for defense-in-depth?
|
||||||
|
- ❓ If a dedicated always-on box (e.g. a Pi on the charger LAN) becomes the CSMS host, it would join NetBird to stay reachable.
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
---
|
||||||
|
type: meta
|
||||||
|
updated: 2026-07-09
|
||||||
|
tags: [index]
|
||||||
|
---
|
||||||
|
|
||||||
|
# Index
|
||||||
|
|
||||||
|
Catalog of every wiki page. Updated on every ingest. (Schema/conventions live in `CLAUDE.md`.)
|
||||||
|
|
||||||
|
## Synthesis
|
||||||
|
|
||||||
|
- [[overview]] — current project state, what's next, open decisions ❓ (2026-07-09)
|
||||||
|
|
||||||
|
## Entities
|
||||||
|
|
||||||
|
- [[anfu-charger]] — the charging pile: its three internal devices + working touchscreen config
|
||||||
|
- [[jc-6620]] — the OCPP communication controller / client; its IPs and shipped-gateway gotcha
|
||||||
|
- [[csms-toolkit]] — the Python CSMS scripts in `../discovering/` and what each does
|
||||||
|
- [[netbird]] — the private overlay network; security boundary for the future web panel
|
||||||
|
|
||||||
|
## Concepts
|
||||||
|
|
||||||
|
- [[network-topology]] — charger LAN behind the Four-Faith router, NAT direction, what's verified
|
||||||
|
- [[authorization]] — the three auth methods (RFID ✅ / Autocharge ⚠️ / web app 📋) and the `decide()` gate
|
||||||
|
- [[troubleshooting]] — ordered "charger won't connect" checklist of hard-won gotchas
|
||||||
|
- [[ocpp]] — OCPP 1.6J basics and how the roles/messages map to this project
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
*(none yet — filed answers to questions go here)*
|
||||||
|
|
||||||
|
## Sources
|
||||||
|
|
||||||
|
- [[2026-07-09-findings-and-requirements]] — founding findings/requirements doc (ingested 2026-07-09, 1 raw file)
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
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]].
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
type: meta
|
||||||
|
updated: 2026-07-09
|
||||||
|
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. Three ways to authorize a charge: existing RFID cards, by vehicle (if the hardware allows — ⚠️ untested), and a mobile-friendly web app reached over [[netbird|NetBird]].
|
||||||
|
|
||||||
|
## Current state (2026-07-09)
|
||||||
|
|
||||||
|
**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: discovery-grade.** The [[csms-toolkit]] (`../discovering/`) can accept connections, log frames, and enforce an allowlist with learn mode. It is a tester/foundation, not yet the always-on production service.
|
||||||
|
|
||||||
|
**Authorization: designed, partially built.** All three methods funnel through one gate — `decide(id_tag)` in `station.py`. See [[authorization]] for the plan per method.
|
||||||
|
|
||||||
|
## What's next
|
||||||
|
|
||||||
|
1. **RFID enrollment** — tap each card in learn mode, harvest idTags from `seen_tags.json`, add to the allowlist, then flip `learn_mode=false`. (Mechanism already implemented.)
|
||||||
|
2. **Autocharge test** — ⚠️ plug the car in *without* tapping a card; if a stable idTag appears, "by vehicle" works. If not, it's off the table for this hardware. See [[authorization]].
|
||||||
|
3. **Web control panel** — Start/Stop via OCPP `RemoteStartTransaction`/`RemoteStopTransaction`, live status, allowlist management. Served behind NetBird.
|
||||||
|
|
||||||
|
## 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 |
|
||||||
|
| Web app auth | NetBird isolation only · also PIN/token | open |
|
||||||
|
| Autocharge | run the plug-in test or skip "by chassis" | open — needs physical test |
|
||||||
|
| 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
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
# Anfu Home Charger — OCPP Integration: Findings & Requirements
|
||||||
|
|
||||||
|
_Last updated: 2026-07-09_
|
||||||
|
|
||||||
|
## 1. Goal
|
||||||
|
|
||||||
|
Run a **private, self-hosted OCPP 1.6J backend (CSMS)** for a home EV charger.
|
||||||
|
No billing, no public charging. Authorization should be possible via:
|
||||||
|
|
||||||
|
1. **RFID cards** already owned (tap to charge).
|
||||||
|
2. **By vehicle / chassis**, if the hardware supports it (see §7 — has a caveat).
|
||||||
|
3. A **mobile / web app** (start/stop charging), hosted securely behind an existing
|
||||||
|
**NetBird** private network.
|
||||||
|
|
||||||
|
## 2. Hardware & Topology
|
||||||
|
|
||||||
|
The charging pile contains three networked devices behind its own router:
|
||||||
|
|
||||||
|
```
|
||||||
|
10.0.10.0/24 (upstream / WAN — main gateway lives here)
|
||||||
|
│
|
||||||
|
┌──┴───────────────┐
|
||||||
|
│ Four-Faith router │ WAN gets a 10.0.10.x address; NAT boundary
|
||||||
|
└──┬───────────────┘
|
||||||
|
│ LAN = 192.168.2.1 (mask 255.255.255.0)
|
||||||
|
├── 192.168.2.228 JC-6620 OCPP communication controller ← the OCPP client
|
||||||
|
├── 192.168.2.118 EV charging controller (main control board), DHCP
|
||||||
|
└── 192.168.2.114 maintenance PC (LAN side)
|
||||||
|
```
|
||||||
|
|
||||||
|
- Wiring is the manufacturer's **star** topology: the EV charging controller **and** the
|
||||||
|
JC-6620's fixed-IP (right) port each connect to a router LAN1–4 port.
|
||||||
|
- **The JC-6620 (192.168.2.228) is the device that opens the outbound OCPP WebSocket**
|
||||||
|
to the CSMS. It talks to the EV controller locally on port **2403**.
|
||||||
|
|
||||||
|
## 3. CSMS software (this repo)
|
||||||
|
|
||||||
|
| 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": { "<idTag>": {name, kind} } }` |
|
||||||
|
| `seen_tags.json` | Auto-recorded log of every idTag observed (for discovery). |
|
||||||
|
|
||||||
|
Runtime: Python venv with `websockets` (16.0) + `ocpp`. Server listens on
|
||||||
|
`ws://0.0.0.0:9000/<chargePointId>`.
|
||||||
|
|
||||||
|
## 4. Charger-side configuration (touchscreen)
|
||||||
|
|
||||||
|
- **General Settings → Charger INEO:** `URL = ws://<CSMS-IP>:9000`, `ChargerID = <any>`
|
||||||
|
- **Back Office → Universal:** `Billing Mode = BackgroundBilling`,
|
||||||
|
`Communication Method = Ethernet`, `JC-6620 IP = 192.168.2.228`, `Port = 2403`
|
||||||
|
- **JC-6620 network config (静态 IP):** IP `192.168.2.228`, mask `255.255.255.0`,
|
||||||
|
**default gateway (默认网关) `192.168.2.1`** (DNS not needed — CSMS is a bare IP).
|
||||||
|
|
||||||
|
## 5. Findings / gotchas (hard-won — check these first if it breaks)
|
||||||
|
|
||||||
|
1. **CSMS host firewall** must allow inbound **TCP 9000**. Windows silently drops
|
||||||
|
otherwise → looks like "charger never connects."
|
||||||
|
2. **`Billing Mode` must be `BackgroundBilling`.** Until it is, the OCPP client never
|
||||||
|
dials out *at all* (zero TCP SYNs). This was the blocker for the first connection.
|
||||||
|
3. **`Communication Method` must be `Ethernet`** (not 4G/SIM).
|
||||||
|
4. **URL / network changes require a pile power-cycle** to take effect.
|
||||||
|
5. **JC-6620 default gateway must be `192.168.2.1`.** It shipped as `192.168.2.228`
|
||||||
|
(pointing at itself) — which reaches a *same-subnet* CSMS but **cannot route to the
|
||||||
|
WAN**. This is why a `192.168.2.x` CSMS worked but a `10.0.10.x` CSMS did not, until
|
||||||
|
the gateway was fixed.
|
||||||
|
6. **No port-forwarding needed on the charger router.** The JC-6620 is the *client* and
|
||||||
|
dials outbound; NAT handles LAN→WAN. Port-forwarding would only matter for inbound.
|
||||||
|
7. **The CSMS host needs a stable IP.** The touchscreen URL is hardcoded, so the host
|
||||||
|
must not change address (static IP or a DHCP reservation).
|
||||||
|
|
||||||
|
## 6. Verified working
|
||||||
|
|
||||||
|
- ✅ **Local CSMS** at `192.168.2.114:9000` — JC-6620 connected, full BootNotification
|
||||||
|
exchange.
|
||||||
|
- ✅ **Remote / WAN CSMS** at `10.0.10.203:9000` (on the router's WAN subnet) — connected
|
||||||
|
after fixing the JC-6620 default gateway. Confirms the CSMS can live upstream / off-subnet.
|
||||||
|
|
||||||
|
## 7. Requirements to build next
|
||||||
|
|
||||||
|
All three authorization methods funnel through one gate in `station.py` —
|
||||||
|
`decide(id_tag)` → Accepted/Rejected against the allowlist. So the build is:
|
||||||
|
|
||||||
|
- **Allowlist enforcement** — already implemented. Learn mode captures ids; flip
|
||||||
|
`learn_mode=false` to enforce.
|
||||||
|
- **RFID cards** — tap each card once in learn mode, harvest its idTag from
|
||||||
|
`seen_tags.json`, add to `authorized` with a name. Works with existing cards.
|
||||||
|
- **By vehicle / chassis** — ⚠️ **needs a physical test.** True VIN / Plug & Charge
|
||||||
|
(ISO 15118) is unlikely on a basic AC unit. The lighter option is **Autocharge**: some
|
||||||
|
chargers auto-send a per-vehicle idTag on plug-in (no card). Test = plug car in without
|
||||||
|
tapping; if a stable idTag appears in `seen_tags.json`, whitelist it as `kind:"car"`.
|
||||||
|
If nothing appears, "by chassis" is not achievable on this hardware.
|
||||||
|
- **Mobile / web app** — a web control panel (mobile-friendly, no app store) exposing
|
||||||
|
Start/Stop via OCPP `RemoteStartTransaction` / `RemoteStopTransaction`, plus live status
|
||||||
|
and clickable allowlist management. Bind to `0.0.0.0`, reach it over **NetBird**.
|
||||||
|
Optional access token/PIN for defense-in-depth.
|
||||||
|
|
||||||
|
## 8. Open decisions (for you)
|
||||||
|
|
||||||
|
- **Final host** for the always-on CSMS + app: the LAN PC, the `10.0.10.203` machine, or
|
||||||
|
a dedicated always-on box (e.g. a Pi on the charger LAN joined to NetBird)?
|
||||||
|
- **Web app auth:** rely on NetBird network isolation only, or also require a PIN/token?
|
||||||
|
- **Autocharge:** do we run the plug-in test to see if "by chassis" is even possible?
|
||||||
|
- **IP stability:** static IP vs DHCP reservation for the chosen host.
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
---
|
||||||
|
type: source
|
||||||
|
updated: 2026-07-09
|
||||||
|
ingested: 2026-07-09
|
||||||
|
raw: raw/FINDINGS_AND_REQUIREMENTS.md
|
||||||
|
tags: [ocpp, hardware, requirements]
|
||||||
|
---
|
||||||
|
|
||||||
|
# Findings & Requirements — Anfu Home Charger OCPP Integration
|
||||||
|
|
||||||
|
**Raw source:** [FINDINGS_AND_REQUIREMENTS.md](../raw/FINDINGS_AND_REQUIREMENTS.md) (project findings doc, last updated 2026-07-09)
|
||||||
|
|
||||||
|
## TL;DR
|
||||||
|
|
||||||
|
The goal is a private, self-hosted **OCPP 1.6J CSMS** for a home EV charger — no billing, no public charging. Authorization via existing RFID cards, possibly by vehicle (Autocharge, ⚠️ untested), and a web app reached over [[netbird|NetBird]]. Connectivity is **✅ solved**: the [[jc-6620|JC-6620]] controller inside the [[anfu-charger|charging pile]] successfully dials out to a CSMS both on the local LAN and across the NAT boundary on the WAN subnet, after several hard-won configuration fixes.
|
||||||
|
|
||||||
|
## Key facts
|
||||||
|
|
||||||
|
- **Hardware topology** — three devices behind a Four-Faith router (LAN `192.168.2.0/24`, WAN on `10.0.10.0/24`): the JC-6620 OCPP controller (`.228`), the EV charging controller (`.118`), and a maintenance PC (`.114`). Details in [[network-topology]].
|
||||||
|
- **The JC-6620 is the OCPP client.** It opens the outbound WebSocket to the CSMS and talks to the EV controller locally on port 2403.
|
||||||
|
- **CSMS software** is the scripts in `../discovering/` — see [[csms-toolkit]]. `station.py` is the real controller with allowlist auth + learn mode.
|
||||||
|
- **Charger-side config** happens on the pile's touchscreen: CSMS URL, ChargerID, `Billing Mode = BackgroundBilling`, `Communication Method = Ethernet`, JC-6620 static IP with gateway `192.168.2.1`.
|
||||||
|
- **Gotchas** (each cost real debugging time) are catalogued in [[troubleshooting]] — notably: no `BackgroundBilling` = zero TCP SYNs, and the JC-6620 shipped with its gateway pointing at itself.
|
||||||
|
- **Verified working:** ✅ local CSMS at `192.168.2.114:9000`; ✅ WAN CSMS at `10.0.10.203:9000` after the gateway fix.
|
||||||
|
- **Next build:** the three [[authorization]] methods, all funneling through `decide(id_tag)` in `station.py`.
|
||||||
|
- **Open decisions** (host choice, web-app auth, Autocharge test, IP stability) tracked in [[overview]].
|
||||||
|
|
||||||
|
## Wiki changes from this ingest
|
||||||
|
|
||||||
|
First source — seeded the entire wiki: [[overview]], [[jc-6620]], [[anfu-charger]], [[csms-toolkit]], [[network-topology]], [[authorization]], [[troubleshooting]], [[ocpp]], [[netbird]].
|
||||||
Reference in New Issue
Block a user