UNPKG

@trusthab/composable-resources

Version:

migrating https://github.com/knetikmedia/hab-api/tree/integration/app/resources/composable

54 lines (42 loc) 1.07 kB
const _ = require('lodash'); const composer = require('../../mixin_loader'); module.exports = (App) => { class CoolSetPointResource { static mixins() { return ['Kpi']; } getMetricId() { return 'cool_set_point'; } getMetricType() { return 'gauge'; } getValue() { const { device_type, cool_target } = this.get('obj'); if (device_type !== 'thermostat') { return null; } return cool_target; } isDeletable() { if (this.get('obj').climate_mode === 'heat') { return true; } return false; } 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(CoolSetPointResource, App); };