Add OCPP control for the Anker Solix EV charger (Own/Proxy CSMS)
The Anker Solix connector was read-only (cloud monitoring only). Add an
OCPP 1.6J control path with a per-user, cascading control mode:
- off monitoring only (default, unchanged behavior)
- own DriverVault is the charger's Central System (full control)
- proxy DriverVault relays to Anker's cloud and injects commands
New internal/ocpp subsystem (stdlib-only, hand-rolled RFC 6455): a CSMS
with session management, inbound dispatch, and typed control commands
(RemoteStart/Stop, SetChargingProfile current limit, ChangeAvailability,
Reset, UnlockConnector, TriggerMessage, Get/ChangeConfiguration). Own- and
proxy-mode paths are verified end-to-end against a simulated charge point.
The charger connects to /ocpp/{serial}, authenticated with OCPP Basic auth
(serial + a per-charger control token) resolved to the owning user via an
in-memory token index. Control REST endpoints mirror the monitoring ones and
reuse the same cascade gate plus a live-session check. controlMode is a new
cascade field (global -> org -> user) advertised as a select on the plugin.
Frontend: control-mode select + provisioning card in Settings, and a real
Start/Stop/limit/reset control panel in Charging, gated on the active mode.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
367113f538
commit
a1519f6e89
22 files changed
+2850
-11
No files matched your search
@@ -405,7 +405,7 @@ async function testToyotaConnection() {
|
||||
|
||||
const anker = ref(null); // resolved view from the server
|
||||
const ankerScope = ref("user"); // "user" | "org" (org admins only)
|
||||
const ankerForm = ref({ email: "", password: "", country: "" });
|
||||
const ankerForm = ref({ email: "", password: "", country: "", controlMode: "off" });
|
||||
const ankerSaving = ref(false);
|
||||
const ankerSaved = ref(false);
|
||||
const ankerError = ref("");
|
||||
@@ -440,9 +440,46 @@ function fillAnkerForm() {
|
||||
email: f.email?.locked ? "" : f.email?.own || "",
|
||||
password: "",
|
||||
country: f.country?.locked ? "" : f.country?.own || "",
|
||||
// controlMode isn't secret, so show the effective value when it's locked.
|
||||
controlMode: f.controlMode?.locked ? f.controlMode?.effective || "off" : f.controlMode?.own || "off",
|
||||
};
|
||||
}
|
||||
|
||||
// Effective OCPP control mode (off | own | proxy) — gates the control panel.
|
||||
const ankerControlMode = computed(() => anker.value?.controlMode || "off");
|
||||
|
||||
// --- Anker Solix OCPP control (per-charger provisioning + connection status) ---
|
||||
const ankerCtlSerial = ref("");
|
||||
const ankerCtl = ref(null); // { endpoint, token, connected, status, ... }
|
||||
const ankerCtlLoading = ref(false);
|
||||
const ankerCtlError = ref("");
|
||||
|
||||
async function loadAnkerControl() {
|
||||
const sn = ankerCtlSerial.value.trim();
|
||||
if (!sn) return;
|
||||
ankerCtlError.value = "";
|
||||
ankerCtlLoading.value = true;
|
||||
try {
|
||||
ankerCtl.value = await api.getAnkerControl(sn);
|
||||
} catch (e) {
|
||||
ankerCtlError.value = e.message;
|
||||
} finally {
|
||||
ankerCtlLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function generateAnkerToken() {
|
||||
const sn = ankerCtlSerial.value.trim();
|
||||
if (!sn) return;
|
||||
ankerCtlError.value = "";
|
||||
try {
|
||||
await api.ankerControlToken(sn);
|
||||
await loadAnkerControl();
|
||||
} catch (e) {
|
||||
ankerCtlError.value = e.message;
|
||||
}
|
||||
}
|
||||
|
||||
function applyAnkerView(body) {
|
||||
anker.value = body;
|
||||
if (ankerScope.value === "org" && !body.canEditOrg) ankerScope.value = "user";
|
||||
@@ -479,7 +516,7 @@ async function saveAnkerSettings() {
|
||||
ankerSaving.value = true;
|
||||
ankerSaved.value = false;
|
||||
const config = {};
|
||||
for (const k of ["email", "password", "country"]) {
|
||||
for (const k of ["email", "password", "country", "controlMode"]) {
|
||||
if (ankerLocked(k)) continue;
|
||||
if (k === "password" && !ankerForm.value.password) continue;
|
||||
config[k] = ankerForm.value[k];
|
||||
@@ -1045,6 +1082,16 @@ onBeforeUnmount(() => {
|
||||
<p v-if="ankerField('country').locked" class="mt-1 text-xs text-muted">{{ ankerSourceLabel('country') }}</p>
|
||||
<p v-else class="mt-1 text-xs text-muted">{{ t("settings.integrations.countryHint") }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="dh-label">{{ t("settings.integrations.controlMode") }}</label>
|
||||
<select v-model="ankerForm.controlMode" class="dh-input" :disabled="ankerLocked('controlMode')">
|
||||
<option value="off">{{ t("settings.integrations.controlOff") }}</option>
|
||||
<option value="own">{{ t("settings.integrations.controlOwn") }}</option>
|
||||
<option value="proxy">{{ t("settings.integrations.controlProxy") }}</option>
|
||||
</select>
|
||||
<p v-if="ankerField('controlMode').locked" class="mt-1 text-xs text-muted">{{ ankerSourceLabel('controlMode') }}</p>
|
||||
<p v-else class="mt-1 text-xs text-muted">{{ t("settings.integrations.controlModeHint") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 flex items-center gap-2">
|
||||
@@ -1068,6 +1115,46 @@ onBeforeUnmount(() => {
|
||||
>
|
||||
{{ ankerHealth.detail || ankerHealth.status }}
|
||||
</p>
|
||||
|
||||
<!-- OCPP control provisioning (only when a control mode is active) -->
|
||||
<div v-if="ankerControlMode !== 'off'" class="mt-5 rounded-control border border-subtle bg-sunken/40 p-4">
|
||||
<p class="text-sm font-semibold text-strong">{{ t("settings.integrations.controlTitle") }}</p>
|
||||
<p class="mt-0.5 text-xs text-muted">
|
||||
{{ ankerControlMode === 'own' ? t("settings.integrations.controlOwnHint") : t("settings.integrations.controlProxyHint") }}
|
||||
</p>
|
||||
|
||||
<div class="mt-3 flex flex-wrap items-end gap-2">
|
||||
<div class="grow">
|
||||
<label class="dh-label">{{ t("settings.integrations.chargerSerial") }}</label>
|
||||
<input v-model="ankerCtlSerial" class="dh-input" placeholder="A5191-XXXXXXXX" autocomplete="off" />
|
||||
</div>
|
||||
<button class="dh-btn dh-btn-ghost" :disabled="!ankerCtlSerial.trim() || ankerCtlLoading" @click="loadAnkerControl">
|
||||
{{ ankerCtlLoading ? t("settings.integrations.testing") : t("settings.integrations.controlCheck") }}
|
||||
</button>
|
||||
<button class="dh-btn dh-btn-primary" :disabled="!ankerCtlSerial.trim()" @click="generateAnkerToken">
|
||||
{{ t("settings.integrations.controlGenerate") }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="ankerCtl" class="mt-3 grid gap-2 text-sm">
|
||||
<div>
|
||||
<span class="text-muted">{{ t("settings.integrations.controlEndpoint") }}: </span>
|
||||
<code class="data break-all text-body">{{ ankerCtl.endpoint }}</code>
|
||||
</div>
|
||||
<div v-if="ankerCtl.token">
|
||||
<span class="text-muted">{{ t("settings.integrations.controlToken") }}: </span>
|
||||
<code class="data break-all text-body">{{ ankerCtl.token }}</code>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="dh-badge" :class="ankerCtl.connected ? 'dh-badge-success' : 'dh-badge-warning'">
|
||||
{{ ankerCtl.connected ? t("settings.integrations.controlConnected") : t("settings.integrations.controlDisconnected") }}
|
||||
</span>
|
||||
<span v-if="ankerCtl.status?.connectorStatus" class="text-muted">{{ ankerCtl.status.connectorStatus }}</span>
|
||||
</div>
|
||||
<p class="text-xs text-muted">{{ t("settings.integrations.controlProvisionSteps") }}</p>
|
||||
</div>
|
||||
<p v-if="ankerCtlError" class="mt-2 text-sm text-danger">{{ ankerCtlError }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<p v-if="ankerError" class="mt-2 text-sm text-danger">{{ ankerError }}</p>
|
||||
|
||||
Reference in new issue
Block a user