Skip to content

Commit

Permalink
keep imported flag when resetting counter
Browse files Browse the repository at this point in the history
  • Loading branch information
KipK committed Mar 1, 2023
1 parent 740e344 commit 57aec58
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ debug_flags =
#-D ENABLE_PROFILE
#-D ENABLE_NOISY_PROFILE
#-D ENABLE_DEBUG_MICROTASKS
-D ENABLE_DEBUG_ENERGY_METER
#-D ENABLE_DEBUG_ENERGY_METER
src_build_flags =
# -D ARDUINOJSON_USE_LONG_LONG
# -D ENABLE_ASYNC_WIFI_SCAN
Expand Down
7 changes: 5 additions & 2 deletions src/energy_meter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ void EnergyMeterData::init()
date.day = 0;
date.month = 0;
date.year = 0;
imported = false;
}

void EnergyMeterData::serialize(StaticJsonDocument<capacity> &doc)
Expand Down Expand Up @@ -111,7 +110,7 @@ EnergyMeter::~EnergyMeter()

void EnergyMeter::begin(EvseMonitor *monitor)
{
createEnergyMeterStorage();
// createEnergyMeterStorage();
this -> _monitor = monitor;
_data.init();
if (load())
Expand Down Expand Up @@ -359,6 +358,10 @@ bool EnergyMeter::write(EnergyMeterData &data)
}
StaticJsonDocument<capacity> doc;
_data.serialize(doc);
// Keep previous "imported" property
if (_data.imported) {
doc["imported"] = _data.imported;
}
String json;
if (serializeJson(doc, json))
{
Expand Down

0 comments on commit 57aec58

Please sign in to comment.