# Creating a virtual parameter for fetching PPPoE across different ONTs

**URL:** <https://forum.genieacs.com/t/creating-a-virtual-parameter-for-fetching-pppoe-across-different-onts/6757>\
**Category:** Uncategorized\
**Created:** [April 13, 2025, 5:51pm UTC](https://forum.genieacs.com/t/creating-a-virtual-parameter-for-fetching-pppoe-across-different-onts/6757 "2025-04-13T17:51:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shahidcodes](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@shahidcodes](https://forum.genieacs.com/u/shahidcodes)\
**Post date:** [April 13, 2025, 5:51pm UTC](https://forum.genieacs.com/t/creating-a-virtual-parameter-for-fetching-pppoe-across-different-onts/6757/1 "2025-04-13T17:51:08Z")

</div>

Hi,

I followed the docs and Wiki in github to create a virtual parameter to get PPPoE username for different model of ONTs.

I have create a virtual parameter called `FirstWANDevicePPPoEUsername`

```auto
// FirstWANDevicePPPoEUsername - Gets PPPoE username from first WAN device
// Parameter name to use in index.page.yml: FirstWANDevicePPPoEUsername

let username = "";
let d = declare(
  "Device.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Username",
  { value: Date.now() }
);

log(d);

if (d.size) {
  for (let p of d) {
    if (p.value[0]) {
      username = p.value[0];
      break;
    }
  }
}
return { writable: false, value: [username, "xsd:string"] };

```

Then following the guide I created a provisioning called `Refresh_VParams`

```auto
declare("VirtualParameters.*", {value: Date.now()});

```

then created a Preset using the same provisioning script `Refresh_VParams` without any other parameters (i.e precondition etc)

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/genieacs/original/2X/4/4d6b142e76f60a608daf4c155c63e982ca0b8925.png)

However when I go to a device and search for `FirstWANDevicePPPoEUsername` or `VirtualParameter` I don’t see anything. I waited and several inform request came from ONT and even summned couple of times.

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [April 14, 2025, 5:24pm UTC](https://forum.genieacs.com/t/creating-a-virtual-parameter-for-fetching-pppoe-across-different-onts/6757/2 "2025-04-14T17:24:28Z")

</div>

> [@shahidcodes](#):
>
> What am I doing wrong?

What you have should work. Are you sure that the Refresh\_VParams script is being run? Add a call to `log('in refresh_vparams');` to the code and then check in the `genieacs-cwmp-access.log` file for that line.

Another thing to try is:

```auto
declare("VirtualParameters.*", { value: Date.now(), path: Date.now() });

```

---

<div class="post-metadata">

**Author:** ![shahidcodes](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@shahidcodes](https://forum.genieacs.com/u/shahidcodes)\
**Post date:** [April 15, 2025, 5:52am UTC](https://forum.genieacs.com/t/creating-a-virtual-parameter-for-fetching-pppoe-across-different-onts/6757/3 "2025-04-15T05:52:35Z")

</div>

it does execute but d.size is always undefined (and JSON.stringify(d) just prints {}) even if just do this

```auto
let d = declare(
  "Device.WANDevice",
  { value: Date.now() }
);

```

or

```auto
let d = declare(
  "Device.WANDevice.1",
  { value: Date.now() }
);

```

not sure what is the problem. I could see the `Device.WANDevice.1` exists in Device Details page.

I am trying to get the list of usernames set on WANPPPConnections regardless of WAN interface numbering set by the device (i.e. Calix ONT sets WANDevice.5 and Huawei sets WANDevice.1 so on)

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [April 15, 2025, 4:19pm UTC](https://forum.genieacs.com/t/creating-a-virtual-parameter-for-fetching-pppoe-across-different-onts/6757/4 "2025-04-15T16:19:34Z")

</div>

Those two script blocks you posted would never work. You aren’t asking for anything specific, you are asking for the instance of an object, instead of a parameter.

While putting together the script below, I see what you are doing wrong now. You appear to be mixing two different version of parameter paths. `InternetGatewayDevice` has `WANDevice` and is v1. `Device` is v2, and does not have `WANDevice`.

Here is the script I use for my username vparam:

```auto
let result = '';

if ('value' in args[1]) {
    result = args[1].value[0];
} else {
    const keys = [
        'InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Username',
        'Device.PPP.Interface.*.Username'
    ];

    result = getParameterValue(keys);
}

return {writable: true, value: [result, "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';
}

```
