Skip to content
This repository was archived by the owner on Jan 27, 2020. It is now read-only.

Commit b1b457f

Browse files
committed
v0.6.2-RC Release Candidate
1 parent 6a62a9b commit b1b457f

2 files changed

Lines changed: 23 additions & 48 deletions

File tree

DSMRlogger2HTTP.ino

Lines changed: 23 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -474,33 +474,16 @@ void processData(MyData DSMRdata) {
474474
lastStartup = "lastStartup: <b>" + buildDateTimeString(pTimestamp) + "</b>, Restart Reason: <b>" + lastReset + "</b> ";
475475
}
476476

477-
// if (PowerDelivered == 0.0) {
478-
// PowerDelivered = PowerDelivered_l1 + PowerDelivered_l2 + PowerDelivered_l3;
479-
// }
480-
// if (PowerReturned == 0.0) {
481-
// PowerReturned = PowerReturned_l1 + PowerReturned_l2 + PowerReturned_l3;
482-
// }
483-
484477
//================= handle Hour change ======================================================
485478
if (thisHour != HourFromTimestamp(pTimestamp)) {
486479
thisHour = HourFromTimestamp(pTimestamp);
487-
if ( (EnergyDelivered == 0.0)
488-
|| (EnergyReturned == 0.0)
489-
|| (GasDelivered == 0.0)) {
490-
TelnetStream.println("Last Read hourData is zero (skip)");
491-
writeLogFile("Last Read hourData is zero (skip)");
492-
thisHour = -2;
493-
} else {
494-
hourToSlot(thisHour, slot, nextSlot, prevSlot);
495-
// slot = thisHour;
496-
// if (slot < 0) slot = 23;
497-
TelnetStream.printf("Saving data for thisHour[%02d] in slot[%02d] (nextSlot[%02d])\n", thisHour, slot, nextSlot);
498-
Serial.printf("Saving data for thisHour[%02d] in slot[%02d] (nextSlot[%02d])\n", thisHour, slot, nextSlot);
499-
hoursDat[slot].EnergyDelivered = EnergyDelivered;
500-
hoursDat[slot].EnergyReturned = EnergyReturned;
501-
hoursDat[slot].GasDelivered = GasDelivered;
502-
saveHourData(slot);
503-
}
480+
hourToSlot(thisHour, slot, nextSlot, prevSlot);
481+
TelnetStream.printf("Saving data for thisHour[%02d] in slot[%02d] (nextSlot[%02d])\n", thisHour, slot, nextSlot);
482+
Serial.printf("Saving data for thisHour[%02d] in slot[%02d] (nextSlot[%02d])\n", thisHour, slot, nextSlot);
483+
hoursDat[slot].EnergyDelivered = EnergyDelivered;
484+
hoursDat[slot].EnergyReturned = EnergyReturned;
485+
hoursDat[slot].GasDelivered = GasDelivered;
486+
saveHourData(slot);
504487

505488
} // if (thisHour != HourFromTimestamp(pTimestamp))
506489

@@ -542,17 +525,10 @@ void processData(MyData DSMRdata) {
542525
thisYear = YearFromTimestamp(pTimestamp);
543526
if (Verbose) TelnetStream.printf("processData(): thisYear[20%02d] => thisMonth[%02d]\r\n", thisYear, thisMonth);
544527
TelnetStream.flush();
545-
if ( (EnergyDelivered == 0.0)
546-
|| (EnergyReturned == 0.0)
547-
|| (GasDelivered == 0.0)) {
548-
TelnetStream.println("Last Read monthData is zero (skip)");
549-
writeLogFile("Last Read monthData is zero (skip)");
550-
thisMonth = -2;
551-
} else {
552-
lastMonth = getLastMonth();
553-
TelnetStream.printf("processData(): lastMonth[%02d] - thisYear[20%02d] => thisMonth[%02d]\r\n"
554-
, lastMonth, thisYear, thisMonth);
555-
if (lastMonth != thisMonth) {
528+
lastMonth = getLastMonth();
529+
TelnetStream.printf("processData(): lastMonth[%02d] - thisYear[20%02d] => thisMonth[%02d]\r\n"
530+
, lastMonth, thisYear, thisMonth);
531+
if (lastMonth != thisMonth) {
556532
if (Verbose) TelnetStream.printf("processData(): lastMonth[%02d]; thisYear[%02d] => thisMonth[%02d]\r\n"
557533
,lastMonth, thisYear, thisMonth);
558534
TelnetStream.println("processData(): Move thisMonth one slot up");
@@ -562,19 +538,18 @@ void processData(MyData DSMRdata) {
562538
shiftDownMonthData(thisYear, thisMonth);
563539
if (Verbose) TelnetStream.println("processData(): months shifted down!");
564540
TelnetStream.flush();
565-
}
566-
TelnetStream.printf("processData(): Saving data for thisMonth[20%02d-%02d] in slot[01]\n", thisYear, thisMonth);
567-
TelnetStream.flush();
568-
Serial.printf("processData(): Saving data for thisMonth[20%02d-%02d] in slot[01]\n", thisYear, thisMonth);
569-
sprintf(cMsg, "%02d%02d", thisYear, thisMonth);
570-
monthsDat[1].Label = String(cMsg).toInt();
571-
monthsDat[1].EnergyDelivered = EnergyDelivered;
572-
monthsDat[1].EnergyReturned = EnergyReturned;
573-
monthsDat[1].GasDelivered = GasDelivered;
574-
saveThisMonth(thisYear, thisMonth, false);
575-
if (Verbose) TelnetStream.printf("processData(): monthsDat[1] for [20%04d] saved!\r\n", String(cMsg).toInt());
576-
TelnetStream.flush();
577541
}
542+
TelnetStream.printf("processData(): Saving data for thisMonth[20%02d-%02d] in slot[01]\n", thisYear, thisMonth);
543+
TelnetStream.flush();
544+
Serial.printf("processData(): Saving data for thisMonth[20%02d-%02d] in slot[01]\n", thisYear, thisMonth);
545+
sprintf(cMsg, "%02d%02d", thisYear, thisMonth);
546+
monthsDat[1].Label = String(cMsg).toInt();
547+
monthsDat[1].EnergyDelivered = EnergyDelivered;
548+
monthsDat[1].EnergyReturned = EnergyReturned;
549+
monthsDat[1].GasDelivered = GasDelivered;
550+
saveThisMonth(thisYear, thisMonth, false);
551+
if (Verbose) TelnetStream.printf("processData(): monthsDat[1] for [20%04d] saved!\r\n", String(cMsg).toInt());
552+
TelnetStream.flush();
578553

579554
} // if (thisMonth != MonthFromTimestamp(pTimestamp))
580555

@@ -677,7 +652,7 @@ void setup() {
677652
thisMonth = getLastMonth();
678653

679654
telegramCount = 0;
680-
telegramErrors = 0;
655+
telegramErrors = 0;
681656

682657
server.on("/getDeviceInfo.json", sendDataDeviceInfo);
683658
server.on("/getActual.json", sendDataActual);

bin/DSMRlogger2HTTP_v6.ino.bin

-256 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)