Skip to content

Commit

Permalink
WebApi update to include power values
Browse files Browse the repository at this point in the history
  • Loading branch information
MalteSchm authored and helgeerbe committed Apr 23, 2023
1 parent 75a59f5 commit 3861ab8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/WebApi_ws_live.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "MessageOutput.h"
#include "WebApi.h"
#include "Battery.h"
#include "Huawei_can.h"
#include "PowerMeter.h"
#include "VeDirectFrameHandler.h"
#include "defaults.h"
#include <AsyncJson.h>
Expand Down Expand Up @@ -197,10 +199,17 @@ void WebApiWsLiveClass::generateJsonResponse(JsonVariant& root)

JsonObject huaweiObj = root.createNestedObject("huawei");
huaweiObj[F("enabled")] = Configuration.get().Huawei_Enabled;

const RectifierParameters_t * rp = HuaweiCan.get();
addTotalField(huaweiObj, "Power", rp->output_power, "W", 2);

JsonObject batteryObj = root.createNestedObject("battery");
batteryObj[F("enabled")] = Configuration.get().Battery_Enabled;
addTotalField(batteryObj, "soc", Battery.stateOfCharge, "%", 0);

JsonObject powerMeterObj = root.createNestedObject("power_meter");
powerMeterObj[F("enabled")] = Configuration.get().PowerMeter_Enabled;
addTotalField(powerMeterObj, "Power", PowerMeter.getPowerTotal(), "W", 1);

}

void WebApiWsLiveClass::addField(JsonObject& root, uint8_t idx, std::shared_ptr<InverterAbstract> inv, ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId, String topic)
Expand Down

0 comments on commit 3861ab8

Please sign in to comment.