Skip to content

Commit e89daaf

Browse files
committed
API client class v1.1.82
- allow filtering by multiple MAC addresses in list_devices(), contributed by @sgrodzicki, #189
1 parent d66c3dd commit e89daaf

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/Client.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* @package UniFi_Controller_API_Client_Class
1515
* @author Art of WiFi <info@artofwifi.net>
16-
* @version Release: 1.1.81
16+
* @version Release: 1.1.82
1717
* @license This class is subject to the MIT license that is bundled with this package in the file LICENSE.md
1818
* @example This directory in the package repository contains a collection of examples:
1919
* https://github.com/Art-of-WiFi/UniFi-API-client/tree/master/examples
@@ -25,7 +25,7 @@ class Client
2525
*
2626
* NOTE: do **not** modify the values here, instead use the constructor or the getter and setter functions/methods
2727
*/
28-
const CLASS_VERSION = '1.1.81';
28+
const CLASS_VERSION = '1.1.82';
2929
protected $baseurl = 'https://127.0.0.1:8443';
3030
protected $user = '';
3131
protected $password = '';
@@ -1408,17 +1408,16 @@ public function list_devices_basic()
14081408
/**
14091409
* Fetch UniFi devices
14101410
*
1411-
* @param array|string $device_mac optional, the MAC address of a single UniFi device for which the call must be made
1412-
* @return array|false an array containing known UniFi device objects (or a single device when using the <device_mac>
1411+
* @param array|string $device_macs optional, array containing the MAC addresses (lowercase strings) of the devices
1412+
* to filter by, may also be a (lowercase) string containing a single MAC address
1413+
* @return array|false an array containing known UniFi device objects (optionally filtered by the <device_macs>
14131414
* parameter), false upon error
14141415
*/
1415-
public function list_devices($device_mac = null)
1416+
public function list_devices($device_macs = [])
14161417
{
1417-
if (is_string($device_mac)) {
1418-
$device_mac = strtolower(trim($device_mac));
1419-
}
1418+
$payload = ['macs' => (array) $device_macs];
14201419

1421-
return $this->fetch_results('/api/s/' . $this->site . '/stat/device/' . $device_mac);
1420+
return $this->fetch_results('/api/s/' . $this->site . '/stat/device', $payload);
14221421
}
14231422

14241423
/**

0 commit comments

Comments
 (0)