Filter in more than one parameter

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.

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

1 Like

this is in filter

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).

2 Likes

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

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

1 Like

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”]};

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:

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”]};

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”] };