NodeJS Package to interacting with the Jarvis Server.
const Jarvis = require('jarvis_node');
Jarvis.URL // the URL to the jarvis server, either JARVIS_URL env var or http://localhost:3000
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()
}
}
);
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);