Hierarchy (View Summary)

Constructors

Accessors

Methods

  • Parameters

    • OptionalminVersion: string

      the minimal semver version for this object

    • OptionalunifiOs: boolean

      need to be unifiOs ? or Unifi Controller ? if no need, pass undefined

    • parameterName: string = ''

      a name for the parameter

    Returns void

  • Fetch client devices that connected to the site within given timeframe

    NOTES:

    • is only used to select clients that were online within that period, the returned stats per client are all-time totals, irrespective of the value of

    Parameters

    • type: string = 'all'

      unknown need documentation (open PR)

    • conn: string = 'all'

      unknown need documentation (open PR)

    • within: number = 8760

      optional, hours to go back (default is 8760 hours or 1 year)

    Returns Promise<
        {
            _id: string;
            blocked?: boolean;
            confidence: number;
            dev_cat: number;
            dev_family: number;
            dev_id: number;
            dev_id_override: number;
            dev_vendor: number;
            device_name: string;
            fingerprint_engine_version: string;
            fingerprint_override: boolean;
            fingerprint_source: number;
            first_seen: number;
            fixed_ip: string;
            fw_version: string;
            hostname: string;
            is_guest: boolean;
            is_wired: boolean;
            last_seen: number;
            mac: string;
            name: string;
            network_id: string;
            note: string;
            noted: boolean;
            os_name: number;
            oui: string;
            score?: number;
            site_id: string;
            use_fixedip: boolean;
            usergroup_id: string;
        }[],
    >

  • Fetch APs stats

    returns an array stats objects for the current Aps (or AP with mac)

    FIVE_MINUTES need version gte 5.5.*

    Parameters

    • OptionalAPMac: string
    • period: EStatsPeriod = EStatsPeriod.DAILY
    • OptionalpStart: dateInput
    • OptionalpEnd: dateInput
    • attribs: ("time" | "bytes" | "num_sta")[] = ...

    Returns Promise<IStats[]>

  • Fetch gateway stats

    NOTES:

    • requires a USG

    Parameters

    • period: EStatsPeriod = EStatsPeriod.DAILY
    • OptionalpStart: dateInput
    • OptionalpEnd: dateInput
    • attribs: (
          | "time"
          | "mem"
          | "cpu"
          | "loadavg_5"
          | "lan-rx_errors"
          | "lan-tx_errors"
          | "lan-rx_bytes"
          | "lan-tx_bytes"
          | "lan-rx_packets"
          | "lan-tx_packets"
          | "lan-rx_dropped"
          | "lan-tx_dropped"
      )[] = ...

    Returns Promise<
        {
            gw: string;
            o: "gw";
            oid: string;
            rx_bytes?: number;
            rx_packets?: number;
            rx_retries?: number;
            signal?: unknown;
            time?: number;
            tx_bytes?: number;
            tx_packets?: number;
            tx_retries?: number;
        }[],
    >

  • Fetch IPS/IDS events

    NOTES:

    • defaults to the past 24 hours
    • requires a USG
    • supported in UniFi controller versions 5.9.X and higher

    Parameters

    Returns Promise<unknown[]>

  • Fetch login sessions

    NOTES:

    • defaults to the past 7*24 hours
    // get all session between date
    getSession({
    start: '2021-08-03T00:00:00.000Z',
    end: '2021-01-03T00:00:00.000Z',
    type: 'all'
    });
    // get 5 last sessions for mac address
    getSession({
    mac: '00:0a:95:9d:68:16',
    _limit: 5,
    _sort: '-assoc_time'
    });

    Parameters

    Returns Promise<unknown[]>

  • Fetch site stats

    returns an array stats objects for the current site

    FIVE_MINUTES need version gte 5.5.*

    Parameters

    • period: EStatsPeriod = EStatsPeriod.DAILY
    • OptionalpStart: dateInput
    • OptionalpEnd: dateInput
    • attribs: (
          | "time"
          | "bytes"
          | "num_sta"
          | "wlan-num_sta"
          | "lan-num_sta"
          | "wan-tx_bytes"
          | "wan-rx_bytes"
          | "wan2-tx_bytes"
          | "wan2-rx_bytes"
          | "wlan_bytes"
      )[] = ...

    Returns Promise<IStats[]>

  • Fetch Users stats

    returns an array stats objects for the current Aps (or AP with mac)

    • only supported with UniFi controller versions 5.8.X and higher
    • make sure that the retention policy for 5 minutes stats is set to the correct value in the controller settings
    • make sure that "Clients Historical Data" has been enabled in the UniFi controller settings in the Maintenance section

    Parameters

    • OptionaluserMac: string | string[]
    • period: EStatsPeriod = EStatsPeriod.DAILY
    • OptionalpStart: dateInput
    • OptionalpEnd: dateInput
    • attribs: (
          | "signal"
          | "time"
          | "tx_bytes"
          | "rx_bytes"
          | "tx_packets"
          | "tx_retries"
          | "rx_packets"
          | "tx_rate"
          | "rx_rate"
          | "rx_retries"
      )[] = ...

    Returns Promise<
        {
            o: "user";
            oid: string;
            rx_bytes?: number;
            rx_packets?: number;
            rx_retries?: number;
            signal?: unknown;
            time?: number;
            tx_bytes?: number;
            tx_packets?: number;
            tx_retries?: number;
            user: string;
        }[],
    >

  • Type Parameters

    • T

    Parameters

    • key: keyof Stats

      the key object that need to be only supported on some versions

    • Optionalvalue: T

      the value store in this object

    • OptionalminVersion: string

      the minimal semver version for this object

    • OptionalunifiOs: boolean

      need to be unifiOs ? or Unifi Controller ? if no need, pass undefined

    • allowUndefined: boolean = false

      to undefined check ?

    Returns boolean