luci-app-statistics: Generate graphs for humidity sensors

This fixes graph generation for sensors that provide humidity data.

Suggested-by: Jo-Philipp Wich <jo@mein.io>
Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
This commit is contained in:
Uwe Kleine-König 2022-12-16 23:22:04 +01:00
parent 41991f8d2a
commit 9f321b831f
2 changed files with 38 additions and 13 deletions

View file

@ -7,20 +7,44 @@ return baseclass.extend({
title: _('Sensors'), title: _('Sensors'),
rrdargs: function(graph, host, plugin, plugin_instance, dtype) { rrdargs: function(graph, host, plugin, plugin_instance, dtype) {
return { var rv = [];
per_instance: true, var types = graph.dataTypes(host, plugin, plugin_instance);
title: "%H: %pi - %di",
vlabel: "\xb0C", if (types.indexOf('temperature') > -1) {
number_format: "%4.1lf\xb0C", rv.push({
data: { per_instance: true,
types: [ "temperature" ], title: "%H: %pi - %di",
options: { vlabel: "\xb0C",
temperature__value: { number_format: "%4.1lf\xb0C",
color: "ff0000", data: {
title: "Temperature" types: [ "temperature" ],
options: {
temperature__value: {
color: "ff0000",
title: "Temperature"
}
} }
} }
} });
}; }
if (types.indexOf('humidity') > -1) {
rv.push({
per_instance: true,
title: "%H: %pi - %di",
vlabel: "%RH",
number_format: "%4.1lf %%RH",
data: {
types: [ "humidity" ],
options: {
humidity__value: {
color: "0000ff",
title: "Humidity"
}
}
}
});
}
return rv;
} }
}); });

View file

@ -8,6 +8,7 @@ var sensorTypes = [
/^(?:ain|in|vccp|vdd|vid|vin|volt|voltbatt|vrm)[0-9]*$/, 'voltage', /^(?:ain|in|vccp|vdd|vid|vin|volt|voltbatt|vrm)[0-9]*$/, 'voltage',
/^(?:cpu_temp|remote_temp|temp)[0-9]*$/, 'temperature', /^(?:cpu_temp|remote_temp|temp)[0-9]*$/, 'temperature',
/^(?:fan)[0-9]*$/, 'fanspeed', /^(?:fan)[0-9]*$/, 'fanspeed',
/^(?:humidity)[0-9]*$/, 'humidity',
/^(?:power)[0-9]*$/, 'power' /^(?:power)[0-9]*$/, 'power'
]; ];