UNPKG

@trusthab/composable-resources

Version:

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

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