@cryptotaxi247 / netdata-1 / commits / 6b8ebc909

Improvements to dashboard

BrainDoctor committed Jul 8, 2017 at 14:02 UTC 6b8ebc909a2c69946b237247e8f785cd0034d15b
2 files changed +40 -38
node.d/stiebeleltron.node.js
+39 -37
@@ -1,6 +1,6 @@
1 'use strict';
2
3 -// This program will connect to one Stiebel Eltron ISG for heatpump heating.
3 +// This program will connect to one Stiebel Eltron ISG for heatpump heating
4 // to get the heat pump metrics.
5
6 // example configuration in netdata/conf.d/node.d/stiebeleltron.conf.md
@@ -40,13 +40,13 @@ var stiebeleltron = {
40 var categories = page.categories;
41 var categoriesCount = categories.length;
42 while (categoriesCount--) {
43 - var category = categories[categoriesCount];
43 var context = {
44 html: html,
45 service: service,
47 - category: category,
46 + category: categories[categoriesCount],
47 page: page,
49 - chartDefinition: null
48 + chartDefinition: null,
49 + dimension: null
50 };
51 stiebeleltron.processCategory(context);
52
@@ -57,26 +57,38 @@ var stiebeleltron = {
57 var charts = context.category.charts;
58 var chartCount = charts.length;
59 while (chartCount--) {
60 - var chart = charts[chartCount];
61 - context.chartDefinition = chart;
60 + context.chartDefinition = charts[chartCount];
61 stiebeleltron.processChart(context);
62 }
63 },
64
66 -
65 processChart: function (context) {
66 var dimensions = context.chartDefinition.dimensions;
67 var dimensionCount = dimensions.length;
70 - context.service.begin(stiebeleltron.getChartUsing(context));
68 + context.service.begin(stiebeleltron.getChartFromContext(context));
69
72 - while(dimensionCount--) {
73 - var dimension = dimensions[dimensionCount];
74 - stiebeleltron.processDimension(dimension, context);
70 + while (dimensionCount--) {
71 + context.dimension = dimensions[dimensionCount];
72 + stiebeleltron.processDimension(context);
73 }
74 context.service.end();
75 },
76
79 - getChartUsing: function (context) {
77 + processDimension: function (context) {
78 + var dimension = context.dimension;
79 + var match = new RegExp(dimension.regex).exec(context.html);
80 + if (match === null) return;
81 + var value = match[1].replace(",", ".");
82 + // most values have a single digit by default, which requires the values to be multiplied. can be overridden.
83 + if (stiebeleltron.isDefined(dimension.digits)) {
84 + value *= Math.pow(10, dimension.digits);
85 + } else {
86 + value *= 10;
87 + }
88 + context.service.set(stiebeleltron.getDimensionId(context), value);
89 + },
90 +
91 + getChartFromContext: function (context) {
92 var chartId = this.getChartId(context);
93 var chart = stiebeleltron.charts[chartId];
94 if (stiebeleltron.isDefined(chart)) return chart;
@@ -89,10 +101,12 @@ var stiebeleltron = {
101 while (dimCount--) {
102 var dim = chartDefinition.dimensions[dimCount];
103 var multiplier = 1;
92 - var divisor = 1;
104 + var divisor = 10;
105 + if (stiebeleltron.isDefined(dim.digits)) divisor = Math.pow(10, Math.max(0, dim.digits));
106 if (stiebeleltron.isDefined(dim.multiplier)) multiplier = dim.multiplier;
107 if (stiebeleltron.isDefined(dim.divisor)) divisor = dim.divisor;
95 - var dimId = this.getDimensionId(context, dim);
108 + context.dimension = dim;
109 + var dimId = this.getDimensionId(context);
110 dimensions[dimId] = this.createBasicDimension(dimId, dim.name, multiplier, divisor);
111 }
112
@@ -102,7 +116,7 @@ var stiebeleltron = {
116 title: chartDefinition.title,
117 units: chartDefinition.unit,
118 family: context.category.name,
105 - context: 'stiebeleltron.' + context.category.id,
119 + context: 'stiebeleltron.' + context.page.id + "." + context.category.id,
120 type: chartDefinition.type,
121 priority: stiebeleltron.base_priority + chartDefinition.prio,// the priority relative to others in the same family
122 update_every: service.update_every, // the expected update frequency of the chart
@@ -114,27 +128,6 @@ var stiebeleltron = {
128 return chart;
129 },
130
117 - getChartId: function (context) {
118 - return "stiebeleltron_" + context.page.id +
119 - "." + context.category.id +
120 - "." + context.chartDefinition.id;
121 - },
122 -
123 - getDimensionId: function (context, dimension) {
124 - return this.getChartId(context) + "." + dimension.id;
125 - },
126 -
127 - processDimension: function (dimension, context) {
128 - var value = stiebeleltron.parseRegex(dimension.regex, context.html);
129 - netdata.debug(dimension.name + " : " + value);
130 - context.service.set(stiebeleltron.getDimensionId(context, dimension), value);
131 - },
132 -
133 - parseRegex: function (regex, html) {
134 - var match = new RegExp(regex).exec(html);
135 - return match[1].replace(",", ".");
136 - },
137 -
131 // module.serviceExecute()
132 // this function is called only from this module
133 // its purpose is to prepare the request and call
@@ -148,7 +141,6 @@ var stiebeleltron = {
141 update_every: update_every,
142 module: this
143 });
151 - service.request.method = 'GET';
144 service.execute(this.processResponse);
145 },
146
@@ -182,6 +174,16 @@ var stiebeleltron = {
174 });
175 },
176
177 + getChartId: function (context) {
178 + return "stiebeleltron_" + context.page.id +
179 + "." + context.category.id +
180 + "." + context.chartDefinition.id;
181 + },
182 +
183 + getDimensionId: function (context) {
184 + return this.getChartId(context) + "." + context.dimension.id;
185 + },
186 +
187 isUndefined: function (value) {
188 return typeof value === 'undefined';
189 },
web/dashboard_info.js
+1 -1
@@ -1367,7 +1367,7 @@ netdataDashboard.context = {
1367 'stiebeleltron.system.roomtemp': {
1368 commonMin: true,
1369 commonMax: true,
1370 - valueRange: "[0, 50]"
1370 + valueRange: "[0, null]"
1371 },
1372
1373 };