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
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).
please replace d.path with i.path ⌠I fixed my answer now
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â] };