Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing energyMeter data to emoncmss_publish() #580

Merged
merged 1 commit into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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