0.3.0 • Published 6 years ago

node-tripp-lite v0.3.0

Weekly downloads
9
License
MIT
Repository
github
Last release
6 years ago

node-tripp-lite allows you to minitor and controls Tripp-Lite UPSs via USB. It uses the node-hid library for communications and is compatible with both Windows and Linux nodejs versions.

Install

npm install node-tripp-lite

Linux installation

This library uses node-hid for USB communication. In order to install on linux, you'll need to install libusb and libudev

sudo apt-get update
sudo npm install libusb-1.0.0 libusb-dev libuv-dev

Usage

const UPS = require('node-tripp-lite');
const ups = new UPS();

// Turn on master relay
ups.masterRelayOn()

// Turn off the load on relay 2
ups.relayOff(2)

// Power cycle relay 1 with a 60 second wait time
ups.powerCycleRelay(1, 60000)

ups.getStatus().then(status => console.log(status))
// Example output (abberviated):
// {
// batteryLow: false,
// deviceName: 'TRIPP LITE SMART1000RM1',
// inverterOn: false,
// loadRelaysPowered: [ true, true ],
// masterRelayPowered: true,
// nominalVac: 120,
// nominalVdc: 24,
// powerRating: 1000,
// switchableLoads: 2,
// voltageAc: 115,
// voltageAcMax: 117,
// voltageAcMin: 113,
// voltageDc: 13.6,
// ...
// }

API

Classes

Typedefs

UPS

Kind: global class

ups.getStatus() ⇒ Promise.<UPSState>

Returns a promise that will resolve to a UPSState Object

Kind: instance method of UPS
Returns: Promise.<UPSState> - - Object containing the state of the UPS
Example

ups.getStatus().then(
  state=>console.log(state)
);

ups.writeSettings(flags)

Write system settings to the UPS. Any settings not included to will be left the same.

Kind: instance method of UPS

ParamTypeDescription
flagsobjectAn object containing the settings to write.
flags.autostartAfterShutdownbooleanAutomatically restart the system after a shutdown
flags.autostartAfterDelayedWakeupbooleanAutomatically restart the system after a delayed wakeup
flags.autostartAfterDelayedWakeupbooleanAutomatically restart the system after low voltage cutoff.
flags.autostartAfterOverloadbooleanAutomatically restart the system after overload.
flags.autostartAfterOverTempbooleanAutomatically restart the system after an over temp situation.
flags.enableBiweeklyAutoSelfTestbooleanEnable 14 day self tests.

Example

ups.writeSettings({
    autostartAfterShutdown: true
})

ups.resetVoltageRange()

Resets the min and max voltage registers

Kind: instance method of UPS
Example

ups.resetVoltageRange();

ups.powerCycleRelay(relay, delayTime)

Power cycle a specific relay on the ups

Kind: instance method of UPS

ParamTypeDescription
relaynumberRelay index (0=master)
delayTimenumberDelay time in ms before turning power back on

Example

// Power cycle load 1 relay, waiting 20 seconds before restarting
ups.powerCycleRelay(1, 20000)

ups.powerCycleMasterRelay(delayTime)

Power cycle the master relay

Kind: instance method of UPS

ParamTypeDescription
delayTimenumberDelay time in ms before turning power back on

Example

// Power cycle master relay, waiting 60 seconds before restarting
ups.powerCycleMasterRelay(60000)

ups.selfTest()

Trigger a self-test

Kind: instance method of UPS
Example

ups.selfTest();

ups.reboot()

Reboot the UPS

Kind: instance method of UPS
Example

ups.reboot();

ups.writeUnitId(unitId)

Write the unit ID to the UPS

Kind: instance method of UPS

ParamTypeDescription
unitIdnumber16bit unit number

Example

// Set the unit id to 42
ups.writeUnitId(42);

ups.writePreDelay(delayTime)

Write the pre-delay (used before shutdown and relay control functions)

Kind: instance method of UPS

ParamTypeDescription
delayTimenumberdelay time in seconds

Example

// Set the preDelaytime to 60 seconds
ups.writePreDelay(60)

ups.relayOn(relay)

Turns a relay on

Kind: instance method of UPS

ParamTypeDescription
relaynumberrelay index (0=master)

Example

// Turn load 2 relay on
ups.relayOn(2);

ups.relayOff(relay)

Turns a relay off

Kind: instance method of UPS

ParamTypeDescription
relaynumberrelay index (0=master)

Example

// Turn load 1 relay off
ups.relayOn(1);

ups.masterRelayOn()

Turns master relay on

Kind: instance method of UPS
Example

ups.masterRelayOn();

ups.masterRelayOff()

Turns master relay off

Kind: instance method of UPS
Example

ups.masterRelayOff();

ups.disableWatchdog()

Disables the watchdog feature

Kind: instance method of UPS
Example

ups.disableWatchdog();

ups.enableWatchdog(delay)

Enables the watchdog feature

Kind: instance method of UPS

ParamTypeDescription
delaynumberDelay time in seconds (must be >1);

Example

// Turn on the watchdog feature, setting the delay to 30 seconds
ups.enableWatchdog(30)

"change"

Emitted when any device property changes

Kind: event emitted by UPS
Properties

NameTypeDescription
propertystringName of the property that has changed
valueboolean | string | number | arrayThe new value of the property
oldValueboolean | string | number | arrayThe old value of the property
stateobjectThe complete state

Example

ups.on('change', ({ property, value }) =>
  console.log(`The ${property} value has changed to ${value}`)
)

"initialized"

Emitted when data for all properties has been received after a device is connected.

Kind: event emitted by UPS
Example

ups.on('initialized', state =>
  console.log(state)
)

"connected"

A device has been connected

Kind: event emitted by UPS
Example

ups.on('connected', deviceDescriptor =>
  console.log(`Connected to Tripp-lite UPS ${deviceDescriptor.productId}`)
)

"disconnected"

A device has been disconnected

Kind: event emitted by UPS
Example

ups.on('disconnected', deviceDescriptor =>
  console.log(`${deviceDescriptor.productId} has been disconnected`)
)

UPS.list() ⇒ Array.<DeviceDescriptor>

Get a list of tripp-lite UPSs connected. The product ID can be used in the constructor function to connect to a specific device

Kind: static method of UPS
Returns: Array.<DeviceDescriptor> - - Array of available devices
Example

console.log( UPS.list() );
//Example return value
// {
//   vendorId: 2478,
//   productId: 1,
//   path: '\\\\?\\hid#vid_09ae&pid_0001#6&1e92950d&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}',
//   manufacturer: 'TRIPP LITE',
//   product: 'TRIPP LITE SMART1000RM1U    ',
//   release: 1,
//   interface: -1,
//   usagePage: 65440,
//   usage: 1
// }

DeviceDescriptor : Object

HID Descriptor for the device.

Kind: global typedef
Properties

NameTypeDescription
vendorIdnumberDevice vendor Id
productIdnumberUsed to select a specicific device in the constructor
pathstringHID path for the device
productstringProduct name
manufacturerstringDevice manufacturor
interfacenumber
usagePagenumber
usagenumber

UPSState : Object

State of a Tripp-Lite UPS

Kind: global typedef
Properties

NameTypeDescription
autostartAfterDelayedWakeupboolean
autostartAfterLowVoltageCutoffboolean
autostartAfterOverloadboolean
autostartAfterOverTempboolean
autostartAfterShutdownboolean
batteryCapacityPercentagenumberBattery capacity in percentage
batteryChargenumber
batteryLowboolean
deviceNamestringDevice model name
enableBiweeklyAutoSelfTestboolean
faults:string'noFault',
firmwarestringFirmware version
frequencynumberAC Power frequencey
frequencyModenumberAC Frequencey mode
idleboolean
inverterOnboolean
loadLevelnumberOutput load level in percentage
loadRelaysPoweredarrayArray of boolean values indicating the state of the load relays. The number of relays included is determinted by the value of switchableLoads.
masterRelayPoweredboolean
nominalVacnumberNominal battery Voltage of the device
nominalVdcnumberNominal battery voltage of the device
powerRatingnumberPower rating in VA.
selfTestRunningboolean
selfTestStatestringSelf test state
standbyboolean
switchableLoadsnumbernumber of relays that can be switched, excluding the master.
temperaturenumbernot currently working correctly
transformerTapstringTransformer tap state
unitIdnumber
usbFirmwarestringUSB firmware version
voltageAcnumberCurrent input AC voltage
voltageAcMaxnumberHightest detected AC voltage
voltageAcMinnumberLowest detected AC voltage
voltageDcnumberCurrent DC voltage
watchdogDelaynumber
watchdogEnabledboolean

Author

👤 Ruby Rubenstahl

🤝 Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator

0.3.0

6 years ago

0.2.0

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago