node-asuswrt
TypeScript icon, indicating that this package has built-in type declarations

1.0.33 • Public • Published

node-asuswrt

API wrapper/client for Asus WRT routers/access points

All async methods return promise based types and can be awaited.

Example

import { AsusWRT } from "node-asuswrt";

const config = {
    Username: 'admin',
    Password: 'password',
    BaseUrl: 'http://192.168.1.1',
    ErrorLogCallback: (logDescription, logData) => { // optional property
        if (logData) {
            console.log(logDescription, logData);
        } else {
            console.log(logDescription);
        }
    },
    InfoLogCallback: (logDescription, logData) => { // optional property
        if (logData) {
            console.log(logDescription, logData);
        } else {
            console.log(logDescription);
        }
    }
}

const asus = new AsusWRT.AsusWRT(config);

asus.getWANStatus().then(result => {
    console.log(result);
});

asus.getTotalTrafficData().then(result => {
    console.log('traffic', result);
})

asus.getRouters().then(result => {
    result.forEach(router => {
        asus.getCPUMemoryLoad(router.mac).then(result => {
            console.log('load', result);
        });
        asus.getUptime(router.mac).then(result => {
            console.log('uptime', result);
        });
        asus.setLedsEnabled(router.mac, true).then(success => {
            console.log(success);
        });
        asus.getWirelessClients(router.mac, "2G").then(wiredClients => {
            console.log(router.alias, wiredClients);
        });
    })
});

Methods

Import the wrapper

import { AsusWRT } from "node-asuswrt";

Create a new instance of the wrapper

const config = {
    Username: 'admin',
    Password: 'password',
    BaseUrl: 'http://192.168.1.1',
    ErrorLogCallback: (logDescription, logData) => { // optional
        if (logData) {
            console.log(logDescription, logData);
        } else {
            console.log(logDescription);
        }
    },
    InfoLogCallback: (logDescription, logData) => { // optional
        if (logData) {
            console.log(logDescription, logData);
        } else {
            console.log(logDescription);
        }
    }
}

const asus = new AsusWRT.AsusWRT(config);

Get all routers in the network (async)

asus.getRouters()

Get wireless clients connected to router (async)

asus.getWirelessClients(router.mac, "2G") // 2.4ghz devices
asus.getWirelessClients(router.mac, "5G") // 5ghz devices

Get wired clients connected to router (async)

asus.getWiredClients(router.mac)

Set LED value for router (async)

asus.setLedsEnabled(router.mac, true) // turns leds on
asus.setLedsEnabled(router.mac, false) // turns leds off

Reboot network (all access points) (async)

asus.rebootNetwork()

Reboot router (async)

asus.rebootDevice(router.mac);

Get CPU and Memory Load (async)

asus.getCPUMemoryLoad(router.mac) // requires mac of router / access point

Get uptime in seconds (async)

asus.getUptime(router.mac) // requires mac of router / access point

Get total traffic data (async)

asus.getTotalTrafficData()
// poll this function to get realtime data usage for example 2 seconds interval and calculate difference

Get WAN Status (async)

asus.getWANStatus()

Get Wake On Lan Devices (async)

asus.getWakeOnLanList()

Run Wake On Lan command (async)

asus.wakeOnLan(wakeOnLanDeviceMac)

Objects

AsusWRTConnectedDevice

{
    ip: string,
    mac: string,
    name: string,
    nickName: string,
    dpiDevice: string,
    vendor: string,
    ipMethod: string,
    rssi: number
}

AsusWRTLoad

{
    CPUUsagePercentage: number,
    MemoryUsagePercentage: number
}

AsusWRTOperationMode

{
    Router: 0,
    AccessPoint: 1
}

AsusWRTRouter

{
    alias: string,
    modelName: string,
    uiModelName: string,
    productId: string,
    firmwareVersion: string,
    newFirmwareVersion: string,
    ip: string,
    mac: string,
    online: boolean,
    operationMode: AsusWRTOperationMode
}

AsusWRTTrafficData

{
    trafficReceived: number;
    trafficSent: number;
}

AsusWRTWANStatus

{
    status?: number;
    statusstr?: string;
    type?: string;
    ipaddr?: string;
    netmask?: string;
    gateway?: string;
    dns?: string;
    lease?: number;
    expires?: number;
    xtype?: string;
    xipaddr?: string;
    xnetmask?: string;
    xgateway?: string;
    xdns?: string;
    xlease?: number;
    xexpires?: number;
}

AsusWRTWakeOnLanDevice

{
    name: string,
    mac: string
}

Readme

Keywords

none

Package Sidebar

Install

npm i node-asuswrt

Weekly Downloads

0

Version

1.0.33

License

GNU GENERAL PUBLIC LICENSE

Unpacked Size

77.3 kB

Total Files

29

Last publish

Collaborators

  • stefanindustries