thing-it-device-helbio
Version:
[thing-it-node] Device Plugin for Helbio © products.
99 lines (85 loc) • 2.01 kB
JavaScript
module.exports = {
metadata: {
family: "fuelCellCoGen",
plugin: "fuelCellCoGen",
label: "Helbio © Fuel Cell CHP",
tangible: true,
discoverable: true,
state: [{
id: "temperature",
label: "Temperature",
type: {
id: "number"
}
}],
events: [{id: "alarm", label: "Alarm"}],
actorTypes: [],
sensorTypes: [],
services: [],
configuration: []
},
create: function () {
return new FuelCellChp();
},
discovery: function (options) {
var discovery = new FuelCellChpDiscovery();
discovery.options = options;
return discovery;
}
};
var q = require('q');
function FuelCellChpDiscovery() {
/**
*
* @param options
*/
FuelCellChpDiscovery.prototype.start = function () {
if (this.node.isSimulated()) {
} else {
}
};
/**
*
* @param options
*/
FuelCellChpDiscovery.prototype.stop = function () {
};
}
/**
*
*/
function FuelCellChp() {
/**
*
*/
FuelCellChp.prototype.start = function () {
var deferred = q.defer();
this.state = {consumption: 0};
if (this.isSimulated()) {
setInterval(function () {
this.state.temperature = 100 - 20 * Math.floor((Math.random() * 6));
this.publishStateChange();
}.bind(this), 10000);
setInterval(function () {
this.publishEvent("alarm");
}.bind(this), 20000);
deferred.resolve();
} else {
deferred.resolve();
}
return deferred.promise;
};
/**
*
*/
FuelCellChp.prototype.setState = function (state) {
this.state = state;
this.publishStateChange();
};
/**
*
*/
FuelCellChp.prototype.getState = function () {
return this.state;
};
}