Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
unifi-events
Advanced tools
Readme
unifi-events is a Node.js module that allows you to listen for events from and call methods on the UniFi API (UniFi is Ubiquiti Networks wifi controller software).
$ npm install unifi-events
const Unifi = require('unifi-events')
const unifi = new Unifi({
host: 'unifi', // The hostname or ip address of the unifi controller (default: 'unifi')
port: 8443, // Port of the unifi controller (default: 8443)
username: 'admin', // Username (default: 'admin').
password: 'ubnt', // Password (default: 'ubnt').
site: 'default', // The UniFi site to connect to (default: 'default').
insecure: true, // Allow connections if SSL certificate check fails (default: false).
unifios: false // For devices with UnifiOS turn this on
});
// Listen for any event
unifi.on('**', function (data) {
console.log(this.event, data);
});
unifi-events uses EventEmitter2 and namespaced events.
ctrl
These events indicate the status of the connection to the UniFi controller
ctrl.connect
- emitted when the connection to the controller is establishedctrl.disconnect
- emitted when the connection to the controller is lostctrl.error
-ctrl.reconnect
-wu
, wg
, lu
, ...This JSON file shows all possible events: https://demo.ubnt.com/manage/locales/en/eventStrings.json?v=5.4.11.2
The prefix EVT_
gets stripped, the first underscore is replaced by the namespace separating dot, everything is
converted to lower case. Some events such as EVT_AD_LOGIN
(Admin Login) are not emitted by the UniFi Controller.
wu.connected
- Wireless User connectedwu.disconnected
- Wireless User disconnectedwu.roam
- Wireless User roamed from one AP to anotherwu.roam_radio
- Wireless User changed channel on the same APwg.connected
- Wireless Guest connectedwg.disconnected
- Wireless Guest disconnectedwg.roam
- Wireless Guest roamed from one AP to anotherwg.roam_radio
- Wireless Guest changed channel on the same APwg.authorization_ended
- Wireless Guest became unauthorisedExample listing for events on Guest Wireless networks only:
unifi.on('wg.*', function (data) {
console.log(this.event, data);
})
Example listening for connected events on all network types:
unifi.on('*.connected', function (data) {
console.log(this.event, data);
});
Connect to the UniFi controller. Is called in the constructor, so normally you don't need to call it (except if you want to re-establish a connection that was closed before).
Closes the connection to the UniFi controller
Following methods operate on the configured site. The path gets prefixed with
https://<host>:<port>/api/s/<site>/
if it does not start with a slash, otherwise it gets prefixed with
https://<host>:<port>
. To explore available API endpoints you can use the
UniFi-API-browser.
These methods are returning a promise.
Do a HTTP GET on the API.
Examples:
unifi.get('stat/sta').then(console.log);
unifi.get('stat/user/<mac>').then(console.log);
unifi.get('list/alarm').then(console.log);
unifi.get('rest/wlanconf').then(res => {
res.data.forEach(wlan => {
console.log(wlan.name, wlan._id);
});
});
unifi.get('stat/device').then(res => {
res.data.forEach(dev => {
console.log(dev.name, dev._id);
});
});
Do a HTTP DELETE on the API.
Do a HTTP POST on the API.
Examples:
unifi.post('set/setting/mgmt', {led_enabled: true}).then(console.log);
unifi.post('upd/wlanconf/<wlan_id>', {enabled: false}).then(console.log);
Do a HTTP PUT on the API.
Examples:
unifi.put('rest/device/<device_id>', {led_override: 'on'}).then(console.log);
FAQs
listen for events from and call methods on the UniFi API (Ubiquiti Wifi).
The npm package unifi-events receives a total of 21 weekly downloads. As such, unifi-events popularity was classified as not popular.
We found that unifi-events demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.