0.4.3 • Published 7 years ago
jarvis_node v0.4.3
Jarvis Node
NodeJS Package to interacting with the Jarvis Server.
Usage
Jarvis
const Jarvis = require('jarvis_node');
Jarvis.URL // the URL to the jarvis server, either JARVIS_URL env var or http://localhost:3000
Device
Load in the default /etc/device.json
const Device = require('jarvis_node').Device;
const device = new Device();
// Register an action with the device
device.registerAction('BREW', () => {
return 'Brewing Coffee';
});
// Register a Measurement with the device
device.registerMeasurement(
'COFFEE_LEVEL',
'http://localhost:3000',
500,
() => {
return {
value: 6,
device_label: device.label,
input_label: 'COFFEE_LEVEL',
received: new Date()
}
}
);
Server
Start the Jarvis server
const Device = require('jarvis_node').Device;
const device = new Device();
// Action and measurement registrations
const Server = require('jarvis_node').Server(device);