delian / node-unifiapi

UniFi API ported to Node.JS

Repository from Github https://github.comdelian/node-unifiapiRepository from Github https://github.comdelian/node-unifiapi

Bug in implementation of UnifiAPI.stat_sta_sessions_latest

shankscoder opened this issue · comments

So looks like there're some typos in this function, here:

UnifiAPI.prototype.stat_sta_sessions_latest = function(mac = '', limit = 5, sort = '-asoc-time', site = undefined) {

The current code looks like so:

UnifiAPI.prototype.stat_sta_sessions_latest = function(mac = '', limit = 5, sort = '-asoc-time', site = undefined) {   
    return this.netsite('/stat/sessions', {   
        mac: mac.toLowerCase(),   
        '_limit': limit,   
        '_sort': sort   
    }, {}, undefined, site);   
};

This returns an empty dataset, for 2 reasons:

  1. The API to call is going to /stat/sessions not /stat/session.
  2. The sorting parameter should be -assoc_time not -asoc-time

Putting this here right now as I'm still working through other calls to try and debug if there are any issues. If I aggregate a few more I'll create a pull request to consolidate these changes.