Skip to content

Commit

Permalink
Autobal state in Restapi (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
shining-man committed Sep 17, 2024
1 parent 9038585 commit 858b140
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/inverter/Inverter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Inverter {

uint16_t getAktualChargeCurrentSoll();

uint8_t getAutobalState();

private:
static const char *TAG;
Expand Down
10 changes: 10 additions & 0 deletions src/inverter/Inverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,13 @@ void Inverter::sendMqttMsg()
mqttPublish(MQTT_TOPIC_INVERTER, -1, MQTT_TOPIC2_TEMPERATURE, -1, (float)(i16_lBattTemp));
}
}


uint8_t Inverter::getAutobalState()
{
xSemaphoreTake(mInverterDataMutex, portMAX_DELAY);
uint8_t stateAutobalance = inverterData.mStateAutobalance;
xSemaphoreGive(mInverterDataMutex);

return stateAutobalance;
}
4 changes: 3 additions & 1 deletion src/restapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ void buildJsonRest(Inverter &inverter, WebServer &server, WebSettings &ws)
genJsonEntryArray(entrySingleNumber, F("cc_cellDrift"), calcChargeCurrentCelldrift, str_htmlOut, false);
genJsonEntryArray(entrySingleNumber, F("cc_cutOff"), calcChargeCurrentCutOff, str_htmlOut, false);

genJsonEntryArray(entrySingleNumber, F("dcc_cellVoltage"), calcDischargeCurrentCellVoltage, str_htmlOut, true);
genJsonEntryArray(entrySingleNumber, F("dcc_cellVoltage"), calcDischargeCurrentCellVoltage, str_htmlOut, false);

genJsonEntryArray(entrySingleNumber, F("autobal_state"), inverter.getAutobalState(), str_htmlOut, true);

genJsonEntryArray(arrEnd, "", "", str_htmlOut, false);
server.sendContent(str_htmlOut);
Expand Down

0 comments on commit 858b140

Please sign in to comment.