Browse Source

Show energy couont from date on web UI (#784)

rfm69
Xose Pérez 6 years ago
parent
commit
072dd04aaf
4 changed files with 725 additions and 703 deletions
  1. BIN
      code/espurna/data/index.html.gz
  2. +20
    -1
      code/espurna/sensor.ino
  3. +702
    -701
      code/espurna/static/index.html.gz.h
  4. +3
    -1
      code/html/custom.js

BIN
code/espurna/data/index.html.gz View File


+ 20
- 1
code/espurna/sensor.ino View File

@ -40,6 +40,8 @@ unsigned char _sensor_temperature_units = SENSOR_TEMPERATURE_UNITS;
double _sensor_temperature_correction = SENSOR_TEMPERATURE_CORRECTION; double _sensor_temperature_correction = SENSOR_TEMPERATURE_CORRECTION;
double _sensor_humidity_correction = SENSOR_HUMIDITY_CORRECTION; double _sensor_humidity_correction = SENSOR_HUMIDITY_CORRECTION;
String _sensor_energy_reset_ts = String();
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Private // Private
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -120,9 +122,15 @@ void _sensorWebSocketSendData(JsonObject& root) {
element["type"] = int(magnitude.type); element["type"] = int(magnitude.type);
element["value"] = String(buffer); element["value"] = String(buffer);
element["units"] = magnitudeUnits(magnitude.type); element["units"] = magnitudeUnits(magnitude.type);
element["description"] = magnitude.sensor->slot(magnitude.local);
element["error"] = magnitude.sensor->error(); element["error"] = magnitude.sensor->error();
if (magnitude.type == MAGNITUDE_ENERGY) {
if (_sensor_energy_reset_ts.length() == 0) _sensorReset();
element["description"] = magnitude.sensor->slot(magnitude.local) + _sensor_energy_reset_ts;
} else {
element["description"] = magnitude.sensor->slot(magnitude.local);
}
if (magnitude.type == MAGNITUDE_TEMPERATURE) hasTemperature = true; if (magnitude.type == MAGNITUDE_TEMPERATURE) hasTemperature = true;
if (magnitude.type == MAGNITUDE_HUMIDITY) hasHumidity = true; if (magnitude.type == MAGNITUDE_HUMIDITY) hasHumidity = true;
@ -277,6 +285,12 @@ void _sensorPost() {
} }
} }
void _sensorReset() {
if (ntpSynced()) {
_sensor_energy_reset_ts = String(" (since ") + ntpDateTime() + String(")");
}
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Sensor initialization // Sensor initialization
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -677,6 +691,7 @@ void _sensorConfigure() {
if (getSetting("pwrResetE", 0).toInt() == 1) { if (getSetting("pwrResetE", 0).toInt() == 1) {
sensor->resetEnergy(); sensor->resetEnergy();
_sensorReset();
} }
sensor->setVoltage(getSetting("pwrVoltage", EMON_MAINS_VOLTAGE).toInt()); sensor->setVoltage(getSetting("pwrVoltage", EMON_MAINS_VOLTAGE).toInt());
@ -690,6 +705,7 @@ void _sensorConfigure() {
EmonADC121Sensor * sensor = (EmonADC121Sensor *) _sensors[i]; EmonADC121Sensor * sensor = (EmonADC121Sensor *) _sensors[i];
if (getSetting("pwrResetE", 0).toInt() == 1) { if (getSetting("pwrResetE", 0).toInt() == 1) {
sensor->resetEnergy(); sensor->resetEnergy();
_sensorReset();
} }
} }
#endif #endif
@ -699,6 +715,7 @@ void _sensorConfigure() {
EmonADS1X15Sensor * sensor = (EmonADS1X15Sensor *) _sensors[i]; EmonADS1X15Sensor * sensor = (EmonADS1X15Sensor *) _sensors[i];
if (getSetting("pwrResetE", 0).toInt() == 1) { if (getSetting("pwrResetE", 0).toInt() == 1) {
sensor->resetEnergy(); sensor->resetEnergy();
_sensorReset();
} }
} }
#endif #endif
@ -728,6 +745,7 @@ void _sensorConfigure() {
if (getSetting("pwrResetE", 0).toInt() == 1) { if (getSetting("pwrResetE", 0).toInt() == 1) {
sensor->resetEnergy(); sensor->resetEnergy();
_sensorReset();
} }
if (getSetting("pwrResetCalibration", 0).toInt() == 1) { if (getSetting("pwrResetCalibration", 0).toInt() == 1) {
@ -765,6 +783,7 @@ void _sensorConfigure() {
if (getSetting("pwrResetE", 0).toInt() == 1) { if (getSetting("pwrResetE", 0).toInt() == 1) {
sensor->resetEnergy(); sensor->resetEnergy();
_sensorReset();
} }
if (getSetting("pwrResetCalibration", 0).toInt() == 1) { if (getSetting("pwrResetCalibration", 0).toInt() == 1) {


+ 702
- 701
code/espurna/static/index.html.gz.h
File diff suppressed because it is too large
View File


+ 3
- 1
code/html/custom.js View File

@ -1032,7 +1032,9 @@ function processData(data) {
var text = (0 === error) ? var text = (0 === error) ?
magnitude.value + magnitude.units : magnitude.value + magnitude.units :
magnitudeError(error); magnitudeError(error);
$("input[name='magnitude'][data='" + i + "']").val(text);
var element = $("input[name='magnitude'][data='" + i + "']");
element.val(text);
$("div.hint", element.parent().parent()).html(magnitude.description);
} }
return; return;
} }


Loading…
Cancel
Save