Skip to content

Commit

Permalink
Merge pull request #580 from KipK/master
Browse files Browse the repository at this point in the history
add missing energyMeter data to emoncmss_publish()
  • Loading branch information
jeremypoulter authored Mar 29, 2023
2 parents cffa32e + 90be2d1 commit 2d34a3a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/energy_meter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "app_config.h"
#include "event.h"


EnergyMeterData::EnergyMeterData()
{
total = 0;
Expand Down
6 changes: 6 additions & 0 deletions src/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ void create_rapi_json(JsonDocument &doc)
doc["srssi"] = WiFi.RSSI();

timeManager.serialise(doc);
// get EnergyMeter data
evse.createEnergyMeterJsonDoc(doc);
// Deprecated properties, will be removed soon
doc["elapsed"] = evse.getSessionElapsed();
doc["wattsec"] = evse.getSessionEnergy() * SESSION_ENERGY_SCALE_FACTOR;
doc["watthour"] = evse.getTotalEnergy() * TOTAL_ENERGY_SCALE_FACTOR;
}

void
Expand Down
3 changes: 2 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ loop() {
if(emoncms_updated)
{
// Send the current state to check the config
DynamicJsonDocument data(4096);
const size_t capacity = JSON_OBJECT_SIZE(33) + 1024;
DynamicJsonDocument data(capacity);
create_rapi_json(data);
emoncms_publish(data);
emoncms_updated = false;
Expand Down
9 changes: 2 additions & 7 deletions src/web_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ void buildStatus(DynamicJsonDocument &doc) {
doc["evse_connected"] = (int)evse.isConnected();

create_rapi_json(doc);
evse.createEnergyMeterJsonDoc(doc);

doc["gfcicount"] = evse.getFaultCountGFCI();
doc["nogndcount"] = evse.getFaultCountNoGround();
Expand Down Expand Up @@ -280,10 +279,6 @@ void buildStatus(DynamicJsonDocument &doc) {
doc["time_to_full_charge"] = evse.getVehicleEta();
}
}
// Deprecated properties, will be removed soon
doc["elapsed"] = evse.getSessionElapsed();
doc["wattsec"] = evse.getSessionEnergy() * SESSION_ENERGY_SCALE_FACTOR;
doc["watthour"] = evse.getTotalEnergy() * TOTAL_ENERGY_SCALE_FACTOR;

DBUGF("/status ArduinoJson size: %dbytes", doc.size());
}
Expand Down Expand Up @@ -434,7 +429,7 @@ void handleStatusPost(MongooseHttpServerRequest *request, MongooseHttpServerResp
{
String body = request->body().toString();
// Deserialize the JSON document
const size_t capacity = JSON_OBJECT_SIZE(128) + 1024;
const size_t capacity = JSON_OBJECT_SIZE(32) + 1024;
DynamicJsonDocument doc(capacity);
DeserializationError error = deserializeJson(doc, body);
if(!error)
Expand Down Expand Up @@ -515,7 +510,7 @@ handleStatus(MongooseHttpServerRequest *request)

if(HTTP_GET == request->method()) {

const size_t capacity = JSON_OBJECT_SIZE(80) + 1280;
const size_t capacity = JSON_OBJECT_SIZE(128) + 2048;
DynamicJsonDocument doc(capacity);
buildStatus(doc);
response->setCode(200);
Expand Down

0 comments on commit 2d34a3a

Please sign in to comment.