device matching via mac instead of ip address

This commit is contained in:
Luca Haid
2026-01-26 12:20:52 +01:00
parent 4b206f0696
commit 5ca7fa29c6
4 changed files with 113 additions and 13 deletions

View File

@@ -106,6 +106,24 @@ class GenieACS {
return $this->_request('GET', '/api/devices');
}
public function getDeviceByMac($mac) {
$mac = strtolower(preg_replace('/[^A-Fa-f0-9]/', '', $mac));
$mac = implode(':', str_split($mac, 2));
$paths = [
'InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress',
'InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.2.MACAddress',
];
foreach ($paths as $path) {
$filter = urlencode($path . ' = "' . $mac . '"');
$result = $this->_request('GET', '/api/devices/?filter=' . $filter . '&limit=1');
if ($result && is_array($result) && count($result) > 0) return $result[0];
}
return null;
}
public function getDevice($deviceId) {
return $this->_request('GET', '/api/devices/' . rawurlencode($deviceId));
}