biodome-client

0.2.0 • Public • Published

biodome-client Build Status

JavaScript client for biodome

The biodome-client is how any services wishing to utilise the biodome server do so. Services include device scheduling, environment compensation, logging, UI client / control panel, emergency notification system, etc.

var biodomeClient = require('biodome-client');
 
var conf = {
  'host' : 'localhost:8888'
};
 
var client = biodomeClient(conf);
 
// sending commands to biodome server
// Will attempt to fetch and store a JWT token if it doesn't already have a valid one
 
client.read('outside_temp')
  .then(function(data) {
    // data is JSON data for endpoint with ID of "temperature"
  }).catch(function(err) {
    // oh. that's unfortunate.
  });
 
// write HIGH to endpoint with an ID of "light"
client.write('light', 1)
  .then(function(data) { ... });
 
// ...or you can use more complex selectors as first param
client.read({ 'type' : 'temperature' })
  .then(function(data) {
    // data is all JSON of matching endpoints
  });
 
// ...or call with your own command object
client.command({
  'selector' : {'type' : 'lights', 'value' : 1 },
  'instruction' : {'type' : 'write', 'value' : 0 }
}).then(function(endpoints){
  // endpoints is JSON data of affected endpoints
});

Readme

Keywords

Package Sidebar

Install

npm i biodome-client

Weekly Downloads

0

Version

0.2.0

License

MIT

Last publish

Collaborators

  • andrewk