Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.
/ webrelay Public archive

http wrapper for operating a controlbyweb relay device

License

Notifications You must be signed in to change notification settings

io-digital/webrelay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);
});

About

http wrapper for operating a controlbyweb relay device

Resources

License

Stars

Watchers

Forks

Packages

No packages published