0.6.0 • Published 7 years ago
hive_node v0.6.0
Hive Node
NodeJS Package to interacting with the Hive Server from a device.
Usage
Hive
const Hive = require('hive_node');
Hive.URL // the URL to the hive server, either HIVE_URL env var or http://localhost:3000
Device
Load in the default /etc/device.json
const Device = require('hive_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 Hive server
const Device = require('hive_node').Device;
const device = new Device();
// Action and measurement registrations
const Server = require('hive_node').Server(device);