@trusthab/composable-resources
Version:
migrating https://github.com/knetikmedia/hab-api/tree/integration/app/resources/composable
46 lines (37 loc) • 921 B
JavaScript
const _ = require('lodash');
const composer = require('../../mixin_loader');
module.exports = (App) => {
class InternalTempResource {
static mixins() {
return ['Kpi'];
}
getMetricId() {
return 'internal_temperature';
}
getMetricType() {
return 'gauge';
}
getValue() {
if (this.get('obj').device_type !== 'thermostat') { return null; }
return this.get('value');
}
customDimensions() {
return true;
}
getDimensions() {
const dimensions = _.pick(this.get('obj'), [
'id',
'location_id',
'parent_location_id',
'root_location_id'
]);
return {
device_id: dimensions.id,
unit_id: dimensions.location_id,
building_id: dimensions.parent_location_id,
property_id: dimensions.root_location_id
};
}
}
return composer(InternalTempResource, App);
};