Skip to content

Commit

Permalink
Merge pull request #416 from KipK/fix#411
Browse files Browse the repository at this point in the history
Fix#411
  • Loading branch information
jeremypoulter authored Aug 22, 2022
2 parents fb11345 + 9ec7d4b commit 7e234b8
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 18 deletions.
18 changes: 1 addition & 17 deletions src/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class InputTask : public MicroTasks::Task
event["colour"] = evse.getStateColour();
event["pilot"] = evse.getPilotState();
event["manual_override"] = manual.isActive() ? 1 : 0; //TODO: remove this
event["override"] = getOverride();
event["session_energy"] = evse.getSessionEnergy();
event_send(event);
}
Expand Down Expand Up @@ -133,27 +132,12 @@ void create_rapi_json(JsonDocument &doc)
doc["flags"] = evse.getFlags();
doc["vehicle"] = evse.isVehicleConnected() ? 1 : 0;
doc["colour"] = evse.getStateColour();
doc["manual_override"] = manual.isActive() ? 1 : 0; //TODO: remove this
//replace "manual_override", should be either 0 or json override claim.
doc["override"] = getOverride();
doc["manual_override"] = manual.isActive() ? 1 : 0;
doc["freeram"] = ESPAL.getFreeHeap();
doc["divertmode"] = divertmode;
doc["srssi"] = WiFi.RSSI();
}

String getOverride() {
String override = "";
const size_t capacity = JSON_OBJECT_SIZE(10) + 1024;
DynamicJsonDocument doc(capacity);
if(manual.isActive()) {
evse.serializeClaim(doc, EvseClient_OpenEVSE_Manual);
} else {
doc["state"] = "null";
}
serializeJson(doc, override);
return override;
}

void
handleRapiRead()
{
Expand Down
1 change: 0 additions & 1 deletion src/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ extern String url;
extern String data;
extern String ohm_hour;

extern String getOverride();
extern void handleRapiRead();
extern void create_rapi_json(JsonDocument &data);

Expand Down
1 change: 1 addition & 0 deletions src/web_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ void handleOverridePost(MongooseHttpServerRequest *request, MongooseHttpServerRe
if(manual.claim(props)) {
response->setCode(201);
response->print("{\"msg\":\"Created\"}");
mqtt_publish_override(); // update override state to mqtt
} else {
response->setCode(500);
response->print("{\"msg\":\"Failed to claim manual overide\"}");
Expand Down

0 comments on commit 7e234b8

Please sign in to comment.