Skip to content

Commit a05e0fc

Browse files
committed
feat(eu-data-act): rich device name + general channel from /vehicles payload
extractVins() now passes through nickname (camelCase nickName from the portal), licensePlate, imageLocation, role and enrollmentStatus instead of just vin + nickname. Verified live: { "vin": "WVGZZZE2ZPE019826", "nickname": "ID.4 Pro Performance", "licensePlate": "GL AM 997E", "imageLocation": "https://media.volkswagen.com/...", "role": "PRIMARY_USER", "enrollmentStatus": "COMPLETED" } discoverEuDataActVehicles uses these to: - Set the device common.name to 'Nickname (KENNZEICHEN)' so multi-VIN setups are unambiguous in the admin tree (falls back to nickname-only or VIN if either piece is missing). - Mirror all five fields under <vin>.general.* so the imageLocation can be referenced directly in vis (matches the pre-EU-Data-Act layout).
1 parent fd945d0 commit a05e0fc

2 files changed

Lines changed: 30 additions & 7 deletions

File tree

lib/euDataAct.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,16 @@ function extractVins(payload) {
215215
for (const v of list) {
216216
const vin = v && (v.vin || v.vehicleIdentificationNumber);
217217
if (typeof vin !== "string" || vin.length !== 17 || seen[vin]) continue;
218-
const nick = v.vehicleNickname || v.nickname || v.modelName;
219-
seen[vin] = nick ? { vin, nickname: nick } : { vin };
218+
seen[vin] = {
219+
vin,
220+
// Portal returns nickName (camelCase) — older payload shapes used
221+
// nickname / vehicleNickname / modelName. Try them all in priority.
222+
nickname: v.nickName || v.vehicleNickname || v.nickname || v.modelName || undefined,
223+
licensePlate: v.licensePlate || undefined,
224+
imageLocation: v.imageLocation || undefined,
225+
role: v.role || undefined,
226+
enrollmentStatus: v.enrollmentStatus || undefined,
227+
};
220228
}
221229
return Object.values(seen);
222230
}

main.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6778,15 +6778,30 @@ class VwWeconnect extends utils.Adapter {
67786778
for (const v of vehicles) {
67796779
const vin = v.vin;
67806780
this.vinArray.push(vin);
6781+
// Device name: prefer "Nickname (KENNZEICHEN)" so users with multiple
6782+
// vehicles can tell them apart at a glance, fall back to nickname-only,
6783+
// VIN-only, in that order.
6784+
let deviceName = v.nickname || vin;
6785+
if (v.nickname && v.licensePlate) {
6786+
deviceName = `${v.nickname} (${v.licensePlate})`;
6787+
}
67816788
await this.extendObjectAsync(vin, {
67826789
type: "device",
6783-
common: { name: v.nickname || vin },
6790+
common: { name: deviceName },
67846791
native: {},
67856792
});
6786-
await this.json2iob.parse(vin + ".general", { vin, nickname: v.nickname || "" }, {
6787-
forceIndex: true,
6788-
channelName: "General Information",
6789-
});
6793+
await this.json2iob.parse(
6794+
vin + ".general",
6795+
{
6796+
vin,
6797+
nickname: v.nickname || "",
6798+
licensePlate: v.licensePlate || "",
6799+
imageLocation: v.imageLocation || "",
6800+
role: v.role || "",
6801+
enrollmentStatus: v.enrollmentStatus || "",
6802+
},
6803+
{ forceIndex: true, channelName: "General Information" },
6804+
);
67906805
// _ensureEuDataActIdentifier handles its own user-facing logging.
67916806
await this._ensureEuDataActIdentifier(vin);
67926807
}

0 commit comments

Comments
 (0)