# CPE with multiple conf get the IP address {SOLVED}

**URL:** <https://forum.genieacs.com/t/cpe-with-multiple-conf-get-the-ip-address-solved/6503>\
**Category:** Uncategorized\
**Created:** [February 13, 2025, 5:32pm UTC](https://forum.genieacs.com/t/cpe-with-multiple-conf-get-the-ip-address-solved/6503 "2025-02-13T17:32:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tagore.PDE](https://avatars.discourse-cdn.com/v4/letter/t/b4bc9f/32.png) [@Tagore.PDE](https://forum.genieacs.com/u/Tagore.PDE)\
**Post date:** [February 13, 2025, 5:32pm UTC](https://forum.genieacs.com/t/cpe-with-multiple-conf-get-the-ip-address-solved/6503/1 "2025-02-13T17:32:17Z")

</div>

I have 2 CPE, one using dhcp, i get the ip using this:  
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress  
i have another CPE using PPPoE, i get the ip using this:  
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.ExternalIPAddress

reading i think i need to use virtual parameter, to have one parameter that select one or another value  
but i dont understand how, where i can get a step by step to doing this if this is doadable?

Regards.

---

<div class="post-metadata">

**Author:** ![Tagore.PDE](https://avatars.discourse-cdn.com/v4/letter/t/b4bc9f/32.png) [@Tagore.PDE](https://forum.genieacs.com/u/Tagore.PDE)\
**Post date:** [February 13, 2025, 5:44pm UTC](https://forum.genieacs.com/t/cpe-with-multiple-conf-get-the-ip-address-solved/6503/2 "2025-02-13T17:44:52Z")

</div>

solved.

---

<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:** [February 13, 2025, 6:11pm UTC](https://forum.genieacs.com/t/cpe-with-multiple-conf-get-the-ip-address-solved/6503/3 "2025-02-13T18:11:51Z")

</div>

Here is a very elegant way of handling multiple parameters to check for a value in a vparam. Replace the values under `keys` with your own.

```javascript
const keys = [
    'InternetGatewayDevice.DeviceInfo.Manufacturer',
    'Device.DeviceInfo.Manufacturer'
];

let result = {writable: false, value: [getParameterValue(keys, 'UNKNOWN'), 'xsd:string']};

return result;

function getParameterValue(keys, def) {
    for (let key of keys) {
        let d = declare(key, {value: Date.now()});

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

    return def;
}

```

---

<div class="post-metadata">

**Author:** ![dustin](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@dustin](https://forum.genieacs.com/u/dustin)\
**Post date:** [February 13, 2025, 6:34pm UTC](https://forum.genieacs.com/t/cpe-with-multiple-conf-get-the-ip-address-solved/6503/4 "2025-02-13T18:34:29Z")

</div>

Just as @akcoder did, sharing your solution helps the community.

---

<div class="post-metadata">

**Author:** ![Tagore.PDE](https://avatars.discourse-cdn.com/v4/letter/t/b4bc9f/32.png) [@Tagore.PDE](https://forum.genieacs.com/u/Tagore.PDE)\
**Post date:** [February 13, 2025, 7:22pm UTC](https://forum.genieacs.com/t/cpe-with-multiple-conf-get-the-ip-address-solved/6503/5 "2025-02-13T19:22:29Z")

</div>

virtual parameter:

```auto
// Example: Unified IP address parameter across different device models
let m = "0.0.0.0";
let d = 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]) {
      m = p.value[0];
      break;
    }
  }  
}
else if (igd.size) {
  for (let p of igd) {
    if (p.value[0]) {
      m = p.value[0];
      break;
    }
  }  
}

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

```

provision:

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

```

In the device page under the refreshed parameters:

```auto
        - type: "'summon-button'"
          parameters:
            - VirtualParameters.* <------ this
            - InternetGatewayDevice.DeviceInfo.HardwareVersion
            - InternetGatewayDevice.DeviceInfo.SoftwareVersion

```

i can do the same with the code that @akcoder provided?

---

<div class="post-metadata">

**Author:** ![dustin](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@dustin](https://forum.genieacs.com/u/dustin)\
**Post date:** [February 13, 2025, 7:26pm UTC](https://forum.genieacs.com/t/cpe-with-multiple-conf-get-the-ip-address-solved/6503/6 "2025-02-13T19:26:26Z")

</div>

For the virtual parameter, yes.
