Hi, here is some virtual parameter (sort rudimentary… sorry) that i build for my tests, using some code from the forum and modify just to bearly make it works
.
You need create a preset (trigger) and a provision (task) for that.
For this i remember that it is was not well documented, so you need to spend a lot of time find the correct post to get all togheter…doc + questions from differents posts, filling all holes…
-First you create a provision (named Refresh_VParams) with:
// Script to refresh all virtualparameters (GENIE only)
// Mtarifa 2019
// Values possibles for return on virtualparameters
// xsd:base64
// xsd:boolean
// xsd:dateTime
// xsd:hexBinary
// xsd:int
// xsd:string
// xsd:unsignedInt
const now = Date.now();
const hourly = Date.now(3600000);
const daily = Date.now(86400000);
const ten_minutes = Date.now(600000);
const five_minutes = Date.now(300000);
const two_minutes = Date.now(120000);
log('[Refresh_VParams] Updating Virtual parameters every 5 minutes only...');
declare("VirtualParameters.*", {value: five_minutes});
-Then create a preset:
Name |
Channel |
Weight |
Schedule |
Events |
Precondition |
Provision |
Refresh_VParams |
Refresh_VParams |
0 |
|
-6 CONNECTION REQUEST, -7 TRANSFER COMPLETE, -8 DIAGNOSTICS COMPLETE |
|
Refresh_VParams |
- Then you create some virtual parameter , example here is one i named IANA
// Example: Fetch IP for Internet DATA IPv6 IA-NA interface
// This script will find the interface Alias and look for the right value
// mtarifa 2020
let now = Date.now();
let m = 'None';
let x = 'temp';
let x2 = 'temp';
let ipaddress = '';
let foundintnames = false;
let founddnames = false;
const IntName_Huawei_1= "HSI"
const IntName_Huawei_2= "TR069_INTERNET"
const IntName_Huawei_3= "3_INTERNET_R_VID_450"
const IntName_Huawei_4= "3_INTERNET_R_VID_300"
const IntName_Huawei_5= "2_INTERNET_R_VID_450"
const DevName_Sagemcom= "IP_DATA"
let Manufacturer = declare("DeviceID.Manufacturer", {value: 1}).value[0];
let model = declare("DeviceID.ProductClass", {value: 1}).value[0];
switch(Manufacturer){
case "Sagemcom":
let dnames = declare("Device.IP.Interface.*.Alias",{path: now, value: now});
for (let myint of dnames) {
if (myint.value[0]== DevName_Sagemcom) {
x = myint.path.substr(0, myint.path.lastIndexOf("."));
log('[IANA] Found string of L3 root interface! Value of interface is ' + x);
if ( declare(x + ".IPv6AddressNumberOfEntries", {path: now, value: now}).value[0] >= "2"){
let dnames2 = declare(x + ".IPv6Address.*.Alias",{path: 1, value: 1});
for (let myint2 of dnames2) {
if (myint2.value[0].match(/DHCPV6/)) {
founddnames = true;
x2 = myint2.path.substr(0, myint2.path.lastIndexOf("."));
log('[IANA] Found string of interface L3 IPv6! Value of interface is ' + x2);
ipaddress = declare(x2 + ".IPAddress", {path: now, value: now});
break;
}
}
}
if (founddnames) {
log('[IANA] Value ' + ipaddress.value[0] + '') ;
m = ipaddress.value[0];
}
else{
log('[IANA] IPv6 IANA address not found!');
}
break;
}
}
break;
case "Huawei Technologies Co., Ltd":
let intnames = declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.*.WANIPConnection.1.Name",{value: now});
for (let myint of intnames) {
if ( (myint.value[0]== IntName_Huawei_1) || (myint.value[0]== IntName_Huawei_2) || (myint.value[0]== IntName_Huawei_3) || (myint.value[0]== IntName_Huawei_4) || (myint.value[0]== IntName_Huawei_5) ) {
x = myint.path.substr(0, myint.path.lastIndexOf("."));
ipaddress = declare(x + ".X_HW_IPv6.IPv6Address.1.IPAddress", {value: now});
if ( declare(x + ".X_HW_IPv6Enable", {path: now, value: now}).value[0] == true){
foundintnames = true;
ipaddress = declare(x + ".X_HW_IPv6.IPv6Address.1.IPAddress", {path: now, value: now});
log('[IANA] Value ' + declare(x + ".X_HW_IPv6.IPv6Address.1.IPAddress", {path: now, value: now}).value[0] + '' ) ;
}
if (foundintnames) {
m = ipaddress.value[0];
}
break;
}
}
break;
default:
break;
}
return {writable: false, value: [m, "xsd:string"]};
Now in each selected event (others than “-something” since “-” will tell to genie that not trigger under that event) it will execute all virtual parameters you have, since the provisioning will search for all virtualparameters.
Then and for visualize you can use the new TR069 virtual node as “VirtualParameters.IANA” per example. you can add in the index or device page
Hope this help.