UNPKG

telldus2graphite

Version:

Fetches sensor values from Telldus Live and forwards it to Graphite

27 lines (26 loc) 815 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function default_1(formatString) { const formatArray = (formatString || 'client.sensor.type').split('.'); function create(sensorInfo, data) { const translation = { client: sensorInfo.clientName, sensor: sensorInfo.name, type: data.name }; const properties = formatArray.slice(0); let metric = {}; metric[translation[properties.pop() || 'undefined']] = Number(data.value); while (properties.length > 0) { let temp = {}; temp[translation[properties.pop() || 'undefined']] = metric; metric = temp; } return metric; } return { create: create }; } exports.default = default_1; ;