AM trying to provision a device with Virtual Parameter but i get this Values is not Defined error on the Script what am i missing ?
my VParams Script
let m = “”;
if (VALUES && VALUES.value) {
m = VALUES.value[0];
declare(“InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Username”, null, {value: m});
declare(“InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Password”, null, {value: m});
}
else {
let igda = declare(“InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Username”, {value: Date.now()});
let igdb = declare(“InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Password”, {value: Date.now()});
if (igda.size) {
m = igda.value[0];
}
else if (igdb.size) {
m = igdb.value[0];
}
}
return {writable: true, value: [m, “xsd:string”]};
Umm, your vparam script looks really wonky. Like you are trying to return either the username or password in the vparam script? Only do one param per vparam.
As to why you aren’t seeing any data passed in, its because your trying to get data passed in from the Date object. Thats not where the data lives…
Per the docs, get rid of the line const VALUES = Date.VALUES();
I don’t recall if VALUES or args is the preferred way of passing in values to vparams. But @zaidka would .
let value;
if ("value" in args[1]) {
// Set declared value
value = args[1].value;
} else if ("value" in args[3]) {
// No declared value, keep current value
value = args[3].value;
} else {
// No current value, use default
value = ["{}", "xsd:string"];
}