Multi brand - Devices tab

Hi guys,

due to different CPE brands, (TP-Link, Mikrotik and Zyxel) I want to have a couple of details on the Devices tab, like PPPoE Username, IP, SSIDs, but those value are on a different interfaces. I tried to use * sign, but isn’t working, is there a way to sort this out?

Use a VirtualParameter. This vparam will work for both TR-069 and TR-181.

let username = '';
const now = Date.now();

if ("value" in args[1]) {
    username = args[1].value[0];
    declare('InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Username', {path: now, value: now}, {value: username})
    declare('Device.PPP.Interface.*.Username', {path: now, value: now}, {value: username})
} else {
    let keys = [
        'InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Username',
        'Device.PPP.Interface.*.Username'
    ];

    username = getParameterValue(keys);
}

log('PPPoEUsername: ' + username);
return {writable: true, value: [username, "xsd:string"]};

function getParameterValue(keys) {
    for (let key of keys) {
        let d = declare(key, {path: Date.now() - (120 * 1000), value: Date.now()});

        for (let item of d) {
            if (item.value && item.value[0]) {
                return item.value[0];
            }
        }
    }

    return 'UNKNOWN';
}
1 Like

Which provision is the ideal to call it? Calling it on default could call several more times than needed.

Check my default:

const now = Date.now();

const hourly = Date.now(3600000);
const daily = Date.now(86400000);
const weekly = Date.now(604800000);
const informTime = daily % 86400000;

// Refresh basic parameters hourly
declare("InternetGatewayDevice.DeviceInfo.HardwareVersion", {path: hourly, value: hourly});
declare("InternetGatewayDevice.DeviceInfo.SoftwareVersion", {path: hourly, value: hourly});
declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.MACAddress", {path: hourly, value: hourly});
declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.ExternalIPAddress", {path: hourly, value: hourly});
declare("InternetGatewayDevice.LANDevice.*.WLANConfiguration.*.SSID", {path: hourly, value: hourly});
declare("VirtualParameters.*", {value: weekly}, {value: informTime});
// 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});

For the PPPoE assigned IP, is there any chance of using VirtualParameter?

Thanks

I don’t know if it will work for you, but I use coalesce when I have different parameters on different devices that I want in the same label, for example:

  • label: “‘IP’”
    parameter: COALESCE(Device.IP.Interface.3.IPv4Address.1.IPAddress,Device.DHCPv4.Client.1.IPAddress)
1 Like

Yes you can.
Follow the code that akcoder provided and substitute the parameters with those for the PPPoE IP.

Here is another example:

let ip = "0.0.0.0";
let d = declare("Device.PPP.Interface.1.IPCP.LocalIPAddress", {value: Date.now()});
let igip = declare ("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANIPConnection.*.ExternalIPAddress", {value: Date.now()});
let igd = declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.ExternalIPAddress", {value: Date.now()});

if (d.size) {
  for (let p of d) {
    if (p.value[0]) {
      ip = p.value[0];
      break;
    }
  }
}
else if (igd.size) {
  for (let p of igd) {
    if (p.value[0]) {
      ip = p.value[0];
      break;
    }
  }
}
else if (igip.size) {
  for (let p of igip) {
    if (p.value[0]) {
      ip = p.value[0];
      break;
    }
  }
}

return {writable: false, value: [ip, "xsd:string"]};

Hope that helps.

DR