Problem with virtual parameters
Hello,
I have different models of routers. I want to display their serial numbers in the device tab. I’ve figured out that I need to make a virtual parameter that combines the two values for each router model.
I’ve been reading the documentation on the official site all afternoon but I can’t do it. I realized that just creating the virtual parameter wasn’t enough. But I can’t manage it.
Here’s my virtual parameter:
let m = "";
let serial1 = declare("InternetGatewayDevice.DeviceInfo.SoftwareVersion", {value: Date.now()});
let serial2 = declare("Device.DeviceInfo.SoftwareVersion", {value: Date.now()});
if (serial1.size) {
for (let p of serial1) {
if (p.value[0]) {
m = p.value[0];
break;
}
}
}
else if (serial2.size) {
for (let p of serial2) {
if (p.value[0]) {
m = p.value[0];
break;
}
}
}
Here are my default provisions:
const hourly = Date.now(3600000);
// Refresh basic parameters hourly
declare("InternetGatewayDevice.DeviceInfo.HardwareVersion", {path: hourly, value: hourly});
declare("InternetGatewayDevice.DeviceInfo.SoftwareVersion", {path: hourly, value: hourly});
declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANIPConnection.*.MACAddress", {path: hourly, value: hourly});
declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANIPConnection.*.ExternalIPAddress", {path: hourly, value: hourly});
declare("InternetGatewayDevice.LANDevice.*.WLANConfiguration.*.SSID", {path: hourly, value: hourly});
// Don't refresh password field periodically because CPEs always report blank passowrds for security reasons
declare("InternetGatewayDevice.LANDevice.*.WLANConfiguration.*.KeyPassphrase", {path: hourly, value: 1});
declare("InternetGatewayDevice.LANDevice.*.Hosts.Host.*.HostName", {path: hourly, value: hourly});
declare("InternetGatewayDevice.LANDevice.*.Hosts.Host.*.IPAddress", {path: hourly, value: hourly});
declare("InternetGatewayDevice.LANDevice.*.Hosts.Host.*.MACAddress", {path: hourly, value: hourly});
Here are my inform provisions:
// Device ID as user name
const username = declare("DeviceID.ID", {value: 1}).value[0]
// Password will be fixed for a given device because Math.random() is seeded with device ID by default.
const password = Math.trunc(Math.random() * Number.MAX_SAFE_INTEGER).toString(36);
const informInterval = 300;
// Refresh values daily
const daily = Date.now(86400000);
// Unique inform offset per device for better load distribution
const informTime = daily % 86400000;
declare("InternetGatewayDevice.ManagementServer.ConnectionRequestUsername", {value: daily}, {value: username});
declare("InternetGatewayDevice.ManagementServer.ConnectionRequestPassword", {value: daily}, {value: password});
declare("InternetGatewayDevice.ManagementServer.PeriodicInformEnable", {value: daily}, {value: true});
declare("InternetGatewayDevice.ManagementServer.PeriodicInformInterval", {value: daily}, {value: informInterval});
declare("InternetGatewayDevice.ManagementServer.PeriodicInformTime", {value: daily}, {value: informTime});
declare("Device.ManagementServer.ConnectionRequestUsername", {value: daily}, {value: username});
declare("Device.ManagementServer.ConnectionRequestPassword", {value: daily}, {value: password});
declare("Device.ManagementServer.PeriodicInformEnable", {value: daily}, {value: true});
declare("Device.ManagementServer.PeriodicInformInterval", {value: daily}, {value: informInterval});
declare("Device.ManagementServer.PeriodicInformTime", {value: daily}, {value: informTime});
// Paramètres Virtuels
declare("VirtualParameters.macaddress", {value: daily}, {value: informTime});
declare("VirtualParameters.serialnumber", {value: daily}, {value: informTime});
Here’s my Device page:
- label: "'Serial number'"
parameter: VirtualParameters.serialnumber
Here’s the error:
task_64ee16e184affe1f85f5e62c script Invalid virtual parameter return value 0 29/08/2023 18:03:45
Please help me. Despite my research and numerous tests, I can’t find it. Thank’s !