Welcome to node-tripp-lite
node-tripp-liteallows you to minitor and controls Tripp-Lite UPSs via USB. It uses thenode-hidlibrary 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
UPSTypedefs
DeviceDescriptor :Object
HID Descriptor for the device.
UPSState :Object
State of a Tripp-Lite UPS
UPS
Kind: global class
- UPS
- instance
- .getStatus() ⇒
Promise.<UPSState> - .writeSettings(flags)
- .resetVoltageRange()
- .powerCycleRelay(relay, delayTime)
- .powerCycleMasterRelay(delayTime)
- .selfTest()
- .reboot()
- .writeUnitId(unitId)
- .writePreDelay(delayTime)
- .relayOn(relay)
- .relayOff(relay)
- .masterRelayOn()
- .masterRelayOff()
- .disableWatchdog()
- .enableWatchdog(delay)
- "change"
- "initialized"
- "connected"
- "disconnected"
- .getStatus() ⇒
- static
- instance
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
| Param | Type | Description |
|---|---|---|
| flags | object |
An object containing the settings to write. |
| flags.autostartAfterShutdown | boolean |
Automatically restart the system after a shutdown |
| flags.autostartAfterDelayedWakeup | boolean |
Automatically restart the system after a delayed wakeup |
| flags.autostartAfterDelayedWakeup | boolean |
Automatically restart the system after low voltage cutoff. |
| flags.autostartAfterOverload | boolean |
Automatically restart the system after overload. |
| flags.autostartAfterOverTemp | boolean |
Automatically restart the system after an over temp situation. |
| flags.enableBiweeklyAutoSelfTest | boolean |
Enable 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
| Param | Type | Description |
|---|---|---|
| relay | number |
Relay index (0=master) |
| delayTime | number |
Delay 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
| Param | Type | Description |
|---|---|---|
| delayTime | number |
Delay 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
| Param | Type | Description |
|---|---|---|
| unitId | number |
16bit 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
| Param | Type | Description |
|---|---|---|
| delayTime | number |
delay 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
| Param | Type | Description |
|---|---|---|
| relay | number |
relay index (0=master) |
Example
// Turn load 2 relay on
ups.relayOn(2);
ups.relayOff(relay)
Turns a relay off
Kind: instance method of UPS
| Param | Type | Description |
|---|---|---|
| relay | number |
relay 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
| Param | Type | Description |
|---|---|---|
| delay | number |
Delay 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
| Name | Type | Description |
|---|---|---|
| property | string |
Name of the property that has changed |
| value | boolean | string | number | array |
The new value of the property |
| oldValue | boolean | string | number | array |
The old value of the property |
| state | object |
The 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
| Name | Type | Description |
|---|---|---|
| vendorId | number |
Device vendor Id |
| productId | number |
Used to select a specicific device in the constructor |
| path | string |
HID path for the device |
| product | string |
Product name |
| manufacturer | string |
Device manufacturor |
| interface | number |
|
| usagePage | number |
|
| usage | number |
UPSState : Object
State of a Tripp-Lite UPS
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| autostartAfterDelayedWakeup | boolean |
|
| autostartAfterLowVoltageCutoff | boolean |
|
| autostartAfterOverload | boolean |
|
| autostartAfterOverTemp | boolean |
|
| autostartAfterShutdown | boolean |
|
| batteryCapacityPercentage | number |
Battery capacity in percentage |
| batteryCharge | number |
|
| batteryLow | boolean |
|
| deviceName | string |
Device model name |
| enableBiweeklyAutoSelfTest | boolean |
|
| faults: | string |
'noFault', |
| firmware | string |
Firmware version |
| frequency | number |
AC Power frequencey |
| frequencyMode | number |
AC Frequencey mode |
| idle | boolean |
|
| inverterOn | boolean |
|
| loadLevel | number |
Output load level in percentage |
| loadRelaysPowered | array |
Array of boolean values indicating the state of the load relays. The number of relays included is determinted by the value of switchableLoads. |
| masterRelayPowered | boolean |
|
| nominalVac | number |
Nominal battery Voltage of the device |
| nominalVdc | number |
Nominal battery voltage of the device |
| powerRating | number |
Power rating in VA. |
| selfTestRunning | boolean |
|
| selfTestState | string |
Self test state |
| standby | boolean |
|
| switchableLoads | number |
number of relays that can be switched, excluding the master. |
| temperature | number |
not currently working correctly |
| transformerTap | string |
Transformer tap state |
| unitId | number |
|
| usbFirmware | string |
USB firmware version |
| voltageAc | number |
Current input AC voltage |
| voltageAcMax | number |
Hightest detected AC voltage |
| voltageAcMin | number |
Lowest detected AC voltage |
| voltageDc | number |
Current DC voltage |
| watchdogDelay | number |
|
| watchdogEnabled | boolean |
Author
Ruby Rubenstahl
- Github: @rubyrubenstahl
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