@trusthab/composable-resources
Version:
migrating https://github.com/knetikmedia/hab-api/tree/integration/app/resources/composable
31 lines (22 loc) • 559 B
JavaScript
const composer = require('../../mixin_loader');
module.exports = (App) => {
const { underscore } = require('inflected');
const LOW_BATTERY_THRESHOLD = 15;
class DevicesLowBatteryResource {
static mixins() {
return ['Kpi'];
}
getMetricId() {
return `devices_low_battery`;
}
getMetricType() {
return 'gauge';
}
getValue() {
const { value } = this.get('diff');
if (value < LOW_BATTERY_THRESHOLD) { return 1; }
return 0;
}
}
return composer(DevicesLowBatteryResource, App);
};