npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-asuswrt

v1.0.33

Published

API wrapper/client for Asus WRT routers/access points

Downloads

44

Readme

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
}