# Filter in more than one parameter

**URL:** <https://forum.genieacs.com/t/filter-in-more-than-one-parameter/843>\
**Category:** Uncategorized\
**Created:** [June 17, 2020, 6:54pm UTC](https://forum.genieacs.com/t/filter-in-more-than-one-parameter/843 "2020-06-17T18:54:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rogerioalves](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/rogerioalves/32/613_2.png) [@rogerioalves](https://forum.genieacs.com/u/rogerioalves)\
**Post date:** [June 17, 2020, 6:54pm UTC](https://forum.genieacs.com/t/filter-in-more-than-one-parameter/843/1 "2020-06-17T18:54:31Z")

</div>

Hello, does anyone know how to filter different patch parameters? Example, I want to search for MACs of connected devices but there are more than one, parameter: InternetGatewayDevice.LANDevice.1.Hosts.Host. (Here is the device number) .MACAddress.

---

<div class="post-metadata">

**Author:** ![lavira](https://avatars.discourse-cdn.com/v4/letter/l/87869e/32.png) [@lavira](https://forum.genieacs.com/u/lavira)\
**Post date:** [June 18, 2020, 8:02am UTC](https://forum.genieacs.com/t/filter-in-more-than-one-parameter/843/2 "2020-06-18T08:02:49Z")

</div>

Hi, in order to get the IP Address of a host with MAC aa:bb:cc:01:02:03, you can use something like this:  
declare(‘InternetGatewayDevice.LANDevice.1.Hosts.Host.[MACAddress:“aa:bb:cc:01:02:03”].IPAddress’, {value: Date.now() }).value

---

<div class="post-metadata">

**Author:** ![rogerioalves](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/rogerioalves/32/613_2.png) [@rogerioalves](https://forum.genieacs.com/u/rogerioalves)\
**Post date:** [June 18, 2020, 12:09pm UTC](https://forum.genieacs.com/t/filter-in-more-than-one-parameter/843/3 "2020-06-18T12:09:26Z")

</div>

this is in filter

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

---

<div class="post-metadata">

**Author:** ![lavira](https://avatars.discourse-cdn.com/v4/letter/l/87869e/32.png) [@lavira](https://forum.genieacs.com/u/lavira)\
**Post date:** [June 18, 2020, 1:10pm UTC](https://forum.genieacs.com/t/filter-in-more-than-one-parameter/843/4 "2020-06-18T13:10:49Z")

</div>

I tried to make sense of what you asked and I came up with the above answer … If you want to filter devices in the UI based on the MAC address of the hosts connected, this can be done with virtual parameters.

Just add a virtual parameter with the name “hostsmacs” with this code:

```
let macs=[];
let d=declare("InternetGatewayDevice.LANDevice.1.Hosts.Host.*", {path: Date.now()});
for (let i of d) {
    macs.push(declare(i.path+'.MACAddress', {value: Date.now()}).value[0]);
}
return {writable: false, value: [macs.join(), "xsd:string"]};

```

And add the following filter:

```
- label: "'Hosts MAC'"
  parameter: VirtualParameters.hostsmacs
  type: "'string'"

```

After reload you will be able to search devices by “Hosts MAC: %aa:bb:cc:01:02%” … BUT, for this to work as expected you must refresh this virtual parameter first (and also periodically).

---

<div class="post-metadata">

**Author:** ![rogerioalves](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/rogerioalves/32/613_2.png) [@rogerioalves](https://forum.genieacs.com/u/rogerioalves)\
**Post date:** [June 18, 2020, 1:50pm UTC](https://forum.genieacs.com/t/filter-in-more-than-one-parameter/843/5 "2020-06-18T13:50:53Z")

</div>

first thanks for the help, it worked but the value is repeating the first mac.

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

---

<div class="post-metadata">

**Author:** ![lavira](https://avatars.discourse-cdn.com/v4/letter/l/87869e/32.png) [@lavira](https://forum.genieacs.com/u/lavira)\
**Post date:** [June 18, 2020, 1:54pm UTC](https://forum.genieacs.com/t/filter-in-more-than-one-parameter/843/6 "2020-06-18T13:54:41Z")

</div>

please replace d.path with i.path … I fixed my answer now

---

<div class="post-metadata">

**Author:** ![ebelotto](https://avatars.discourse-cdn.com/v4/letter/e/4af34b/32.png) [@ebelotto](https://forum.genieacs.com/u/ebelotto)\
**Post date:** [June 10, 2021, 5:17am UTC](https://forum.genieacs.com/t/filter-in-more-than-one-parameter/843/7 "2021-06-10T05:17:13Z")

</div>

When there is more than one manufacturer, the variable must change so that I can find the PPPoE in more than one parameter. I used the example but it returns an error →   
name:TypeError  
message: Cannot read property ‘0’ of undefined  
stack: |-  
TypeError: Cannot read property ‘0’ of undefined  
until PPPoE: 5:89

I’m using the following filter:

let pppoe=[];  
let d=declare(“InternetGatewayDevice.WANDevice.1.WANConnectionDevice.\*”, {path: Date.now()});  
for (let i of d) {  
pppoe.push(declare(i.path+’.WANPPPConnection.1.Username’, {value: Date.now()}).value[0]);  
}  
return {writable: false, value: [pppoe.join(), “xsd:string”]};

---

<div class="post-metadata">

**Author:** ![lavira](https://avatars.discourse-cdn.com/v4/letter/l/87869e/32.png) [@lavira](https://forum.genieacs.com/u/lavira)\
**Post date:** [June 10, 2021, 7:58am UTC](https://forum.genieacs.com/t/filter-in-more-than-one-parameter/843/8 "2021-06-10T07:58:23Z")

</div>

Yes, you will receive this error if there is no WANPPPConnection on the WANConnectionDevice.\* or if the WANPPPConnection instance is different from 1. Try this instead:

```auto
let pppoe=[];
let d=declare(“InternetGatewayDevice.WANDevice.1.WANConnectionDevice.*.WANPPPConnection.*”, {path: Date.now()});
for (let i of d) {
   pppoe.push(declare(i.path+".Username", {value: Date.now()}).value[0]);
}
return {writable: false, value: [pppoe.join(), “xsd:string”]};
```

---

<div class="post-metadata">

**Author:** ![ghiem007](https://avatars.discourse-cdn.com/v4/letter/g/4bbf92/32.png) [@ghiem007](https://forum.genieacs.com/u/ghiem007)\
**Post date:** [November 21, 2023, 8:11am UTC](https://forum.genieacs.com/t/filter-in-more-than-one-parameter/843/9 "2023-11-21T08:11:30Z")

</div>

Hi Guys,

I have added the below code and add the virtual parameter under filter but when I search for a mac nothing returns, is there any issue with the code I am using or is there another step missing in this process? Thank you

let m = “00:00:00:00:00:00”;  
let d = declare(  
“Device.WANDevice._.WANConnectionDevice._.WANIPConnection._.MACAddress",  
{ value: Date.now() }  
);  
let igd = declare(  
"InternetGatewayDevice.WANDevice._.WANConnectionDevice._.WANPPPConnection._.MACAddress”,  
{ value: Date.now() }  
);

let wanIP = declare(  
“InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress”,  
{ value: Date.now() }  
);

let lanHost = declare(  
“InternetGatewayDevice.LANDevice.1.Hosts.Host.1.MACAddress”,  
{ 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;  
}  
}  
} else if (wanIP.size) {  
for (let p of wanIP) {  
if (p.value[0]) {  
m = p.value[0];  
break;  
}  
}  
} else if (lanHost.size) {  
for (let p of lanHost) {  
if (p.value[0]) {  
m = p.value[0];  
break;  
}  
}  
}

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