webrelay

0.1.2 • Public • Published

webrelay

NPM

Build Status devDependency Status

Coverage Status Dependency Status

http wrapper for operating a ControlByWeb relay device

api
  • #setup.run(host, mac, callback) add an arp entry for host and test with ping
  • #setup.arp(host, mac, callback) add an arp entry for host
  • #setup.ping(host, callback) ping the given host
  • #switch(host, breaker, state, callback) change the state of breaker to state and return the state of the relay (xml)
  • #state(host, callback) return the state of the relay (xml)
usage

the module is programmed to spy at environment variables and runtime arguments for configuration data. runtime arguments take precedence over environment variables and default values.

var webrelay = require('webrelay'),
    host = webrelay.config.RELAY_HOST,
    mac = webrelay.config.RELAY_MAC;
 
// initial set up
webrelay.setup.run(host, mac, function(err, res) {
  if (err) throw err;
  // relay is now accessible via config.RELAY_HOST
});
 
// toggle a breaker
webrelay.switch(host, 1, 1, function(err, res) {
  if (err) throw err;
  // breaker number 1's state is now 1
});
 
// get the state back (in xml)
webrelay.state(host, function(err, res) {
  if (err) throw err;
  console.log(res);
});

Readme

Keywords

none

Package Sidebar

Install

npm i webrelay

Weekly Downloads

0

Version

0.1.2

License

MIT

Last publish

Collaborators

  • skibz