diff --git a/lib/JsonMqttHandler/src/JsonMqttHandler.cpp b/lib/JsonMqttHandler/src/JsonMqttHandler.cpp index 1ba9c96b..7154856b 100644 --- a/lib/JsonMqttHandler/src/JsonMqttHandler.cpp +++ b/lib/JsonMqttHandler/src/JsonMqttHandler.cpp @@ -79,14 +79,24 @@ uint16_t JsonMqttHandler::appendJsonFooter(EnergyAccounting* ea, uint16_t pos) { } else { memset(pf, 0, 4); } + + String peaks = ""; + uint8_t peakCount = ea->getConfig()->hours; + if(peakCount > 5) peakCount = 5; + for(uint8_t i = 1; i <= peakCount; i++) { + if(!peaks.isEmpty()) peaks += ","; + peaks += String(ea->getPeak(i).value / 100.0, 2); + } - return snprintf_P(json+pos, BufferSize-pos, PSTR("%s\"%sh\":%.2f,\"%sd\":%.1f,\"%st\":%d,\"%sx\":%.2f,\"%she\":%.2f,\"%sde\":%.1f%s"), + return snprintf_P(json+pos, BufferSize-pos, PSTR("%s\"%sh\":%.3f,\"%sd\":%.2f,\"%sm\":%.1f,\"%st\":%d,\"%sx\":%.2f,\"%she\":%.3f,\"%sde\":%.2f,\"%sme\":%.1f,\"peaks\":[%s]%s"), strlen(pf) == 0 ? "},\"realtime\":{" : ",", pf, ea->getUseThisHour(), pf, ea->getUseToday(), pf, + ea->getUseThisMonth(), + pf, ea->getCurrentThreshold(), pf, ea->getMonthMax(), @@ -94,6 +104,9 @@ uint16_t JsonMqttHandler::appendJsonFooter(EnergyAccounting* ea, uint16_t pos) { ea->getProducedThisHour(), pf, ea->getProducedToday(), + pf, + ea->getProducedThisMonth(), + peaks.c_str(), strlen(pf) == 0 ? "}" : "" ); }