Correct PowerConsumed SI Units in Overview (#14425)

* Correct PowerConsumed SI Units in Overview

Workaround to convert PowerConsumed SI Display Units from kkWh to MWh. Better way would be to directly save the data in Wh instead of kWh. But we don't know the impact jet.

* Fix style
This commit is contained in:
Kevin Zink
2023-04-15 00:34:03 +02:00
committed by GitHub
parent 0cdda100e7
commit 5d7b0e8dc8

View File

@@ -1100,10 +1100,14 @@ function get_sensor_label_color($sensor, $type = 'sensors')
return "<span class='label $label_style'>" . trim($sensor['sensor_current']) . '</span>';
}
if ($sensor['sensor_class'] == 'frequency' && $sensor['sensor_type'] == 'openwrt') {
return "<span class='label $label_style'>" . trim($sensor['sensor_current']) . ' ' . $unit . '</span>';
}
if ($sensor['sensor_class'] == 'power_consumed') {
return "<span class='label $label_style'>" . trim(Number::formatSi($sensor['sensor_current'] * 1000, 5, 5, 'Wh')) . '</span>';
}
if (in_array($sensor['rrd_type'], ['COUNTER', 'DERIVE', 'DCOUNTER', 'DDERIVE'])) {
//compute and display an approx rate for this sensor
return "<span class='label $label_style'>" . trim(Number::formatSi(max(0, $sensor['sensor_current'] - $sensor['sensor_prev']) / Config::get('rrd.step', 300), 2, 3, $unit)) . '</span>';