UNPKG

@trusthab/composable-resources

Version:

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

34 lines (25 loc) 691 B
const composer = require('../../mixin_loader'); module.exports = (App) => { const { underscore } = require('inflected'); const PROPERTY_VALUE = 'heating'; class ThermostatsHeatingResource { static mixins() { return ['Kpi']; } getMetricId() { return `thermostats_${PROPERTY_VALUE}`; } getMetricType() { return 'gauge'; } getValue() { if (this.get('obj').device_type !== 'thermostat') { return 0; } const { value, oldValue } = this.get('diff'); if (oldValue !== PROPERTY_VALUE && value === PROPERTY_VALUE) { return 1; } return 0; } } return composer(ThermostatsHeatingResource, App); };