node-unifiapi
node-unifiapi copied to clipboard
UnifiAPI.stat_session function not allowing single mac filtering
Comparing the stat_session
function (show login sessions for clients), with the PHP version of the Unifi API class, I noticed that the PHP version lets you perform a search of sessions between a data range for a specific MAC. The NodeJS version doesn't accept a MAC as a parameter.
Node implementation
https://github.com/delian/node-unifiapi/blob/34662c589f2a9b0e8aa2069a2fd202e9be55476b/index.js#L246
PHP Implementation
https://github.com/Art-of-WiFi/UniFi-API-client/blob/master/src/Client.php#L669
An example of using this function call using the netsite
function in NodeJS:
const moment = require('moment');
let conf = {
mac: "<mac address>",
'type': 'all',
'start': moment().subtract(7, 'days').unix(),
'end': moment().unix()
};
r.netsite('/stat/session', conf, {}, undefined, <sitecode>)
.then((data) => {
console.log(data.data);
}).catch(err => console.log('Error',err));
Again will be issuing a pull-request soon, but documenting this here.