GithubHelp home page GithubHelp logo

samwelnella / unifi-events Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oznu/unifi-events

0.0 0.0 0.0 29 KB

A Node.js module to listen for events from a UniFi Controller.

JavaScript 100.00%

unifi-events's Introduction

UniFi Events

UniFi Events is a Node.js module that allows you to listen for events generated by a UniFi Controller.

Requirements

Installation

unifi-events can be installed using the following npm command:

npm install unifi-events

or yarn:

yarn add unifi-events

Example

const UnifiEvents = require('unifi-events')

let unifi = new UnifiEvents({
  controller: 'https://demo.ubnt.com',  // Required. The url of the UniFi Controller
  username: 'superadmin',               // Required.
  password: 'password',                 // Required.
  site: 'default',                      // Optional. The UniFi site to connect to, if not set will use the default site.
  rejectUnauthorized: true,             // Optional. Set to false if you don't have a valid SSL
  listen: true                          // Optional. Set to false if you don't want to listen for events
})

// Listen for users and guests connecting to the network
unifi.on('connected', (data) => {
  console.log(data)
})

// Listen for users and guests disconnecting from the network
unifi.on('disconnected', (data) => {
  console.log(data)
})

// Listen for any event
unifi.on('event', (data) => {
  console.log(data)
})

Events

In addition to the connect, disconnect and event event types, other UniFi event types are emitted using the UniFi Event Key ID.

This JSON file shows all possible events: https://demo.ubnt.com/manage/locales/en/eventStrings.json?v=5.4.11.2

Some events such as EVT_AD_LOGIN (Admin Login) are not emitted by the UniFi Controller.

Wireless User Events:

  • EVT_WU_Connected - Wireless User connected
  • EVT_WU_Disconnected - Wireless User disconnected
  • EVT_WU_ROAM - Wireless User roamed from one AP to another
  • EVT_WU_ROAM_RADIO - Wireless User changed channel on the same AP

Wireless Guest Events:

  • EVT_WG_Connected - Wireless Guest connected
  • EVT_WG_Disconnected - Wireless Guest disconnected
  • EVT_WG_ROAM - Wireless Guest roamed from one AP to another
  • EVT_WG_ROAM_RADIO - Wireless Guest changed channel on the same AP
  • EVT_WG_AUTHORIZATION_ENDED - Wireless Guest became unauthorised

LAN User Events:

  • EVT_LU_CONNECTED - LAN User connected to the network
  • EVT_LU_DISCONNECTED - LAN User disconnected from the network

LAN Guest Events:

  • EVT_LG_CONNECTED - LAN Guest connected to the network
  • EVT_LG_DISCONNECTED - LAN Guest disconnected from the network

Example listing for connections made to Guest Wireless networks only:

unifi.on('EVT_WG_Connected', (data) => {
  console.log(data)
})

unifi-events's People

Contributors

hobbyquaker avatar jmara avatar oznu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.