Skip to content

Commit

Permalink
add honk flash
Browse files Browse the repository at this point in the history
  • Loading branch information
TA2k committed Nov 29, 2023
1 parent 2a79cf8 commit af8cf7c
Showing 1 changed file with 55 additions and 2 deletions.
57 changes: 55 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1977,6 +1977,28 @@ class VwWeconnect extends utils.Adapter {
},
native: {},
});
this.extendObject(vin + ".remote.honkandflash", {
type: "state",
common: {
name: "Hupen und Licht Honk and Flash",
type: "boolean",
role: "boolean",
def: false,
write: true,
},
native: {},
});
this.extendObject(vin + ".remote.flash", {
type: "state",
common: {
name: "Licht Flash",
type: "boolean",
role: "boolean",
def: false,
write: true,
},
native: {},
});
}
resolve();
return;
Expand Down Expand Up @@ -3632,16 +3654,38 @@ class VwWeconnect extends utils.Adapter {

// body = JSON.stringify(body);
}
if (action === "honkandflash" || action === "flash") {
const latState = await this.getStateAsync(vin + ".parkingposition.lat");
const longState = await this.getStateAsync(vin + ".parkingposition.lon");
if (!latState || !longState) {
this.log.error("No parking position found");
reject();
return;
}
body = {
duration_s: 15,
mode: action,
userPosition: {
latitude: latState.val,
longitude: longState.val,
},
};
action = "honkandflash";
}
let method = "POST";
if (value === "settings") {
method = "PUT";
}
this.log.debug("https://emea.bff.cariad.digital/vehicle/v1/vehicles/" + vin + "/" + action + "/" + value);
let url = "https://emea.bff.cariad.digital/vehicle/v1/vehicles/" + vin + "/" + action;
if (value) {
url += "/" + value;
}
this.log.debug(url);
this.log.debug(JSON.stringify(body));
request(
{
method: method,
url: "https://emea.bff.cariad.digital/vehicle/v1/vehicles/" + vin + "/" + action + "/" + value,
url: url,

headers: {
"content-type": "application/json",
Expand Down Expand Up @@ -5486,6 +5530,15 @@ class VwWeconnect extends utils.Adapter {
this.log.error("failed set state");
});
}

if (action === "honkandflash" || action === "flash") {
if (this.config.type === "id" || this.config.type === "audietron") {
this.setIdRemote(vin, action).catch(() => {
this.log.error("failed set state " + action);
});
return;
}
}
if (action === "flash") {
//HONK_AND_FLASH
const idArray = id.split(".");
Expand Down

0 comments on commit af8cf7c

Please sign in to comment.