Hierarchy (view full)

Constructors

Accessors

Methods

  • Parameters

    • Optional minVersion: string

      the minimal semver version for this object

    • Optional unifiOs: boolean

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

    • parameterName: string = ''

      a name for the parameter

    Returns void

  • Fetch APs stats

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

    FIVE_MINUTES need version gte 5.5.*

    Parameters

    • Optional APMac: string
    • period: EStatsPeriod = EStatsPeriod.DAILY
    • Optional pStart: dateInput
    • Optional pEnd: dateInput
    • attribs: ("time" | "bytes" | "num_sta")[] = ...

    Returns Promise<IStats[]>

  • 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 authorizations

    NOTES:

    • defaults to the past 7*24 hours

    Parameters

    Returns Promise<unknown[]>

  • Return default number of hours returned when getting stats :

    • 5 minutes stats = 12 hours ~90 results
    • hourly stats = 7 * 24 hours ~170 results
    • daily / monthly = 52 * 7 * 24 ~365/12 results

    number results always depends of the results stored on the controller

    Parameters

    Returns number

  • Fetch gateway stats

    NOTES:

    • requires a USG

    Parameters

    • period: EStatsPeriod = EStatsPeriod.DAILY
    • Optional pStart: dateInput
    • Optional pEnd: 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;
    }[]>

  • Return a range of hours, default to the last 12 hours, or 12h before end

    Parameters

    • Optional pStart: dateInput

      the start date

    • Optional pEnd: dateInput

      the end date

    • hours: number = 12

      number of hours

    Returns {
        end: Date;
        start: Date;
    }

    • end: Date
    • start: Date
  • 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
    • Optional pStart: dateInput
    • Optional pEnd: 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

    • Optional userMac: string | string[]
    • period: EStatsPeriod = EStatsPeriod.DAILY
    • Optional pStart: dateInput
    • Optional pEnd: 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

    • Optional value: T

      the value store in this object

    • Optional minVersion: string

      the minimal semver version for this object

    • Optional unifiOs: boolean

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

    • allowUndefined: boolean = false

      to undefined check ?

    Returns boolean

Generated using TypeDoc