Changes after testing

This commit is contained in:
Gunnar Skjold 2023-05-05 18:12:26 +02:00
parent 90ebe3803d
commit 48eb640838
7 changed files with 40 additions and 17 deletions

View File

@ -125,13 +125,15 @@ bool EnergyAccounting::update(AmsData* amsData) {
totalImport += ds->getDayImport(i);
totalExport += ds->getDayExport(i);
}
uint8_t accuracy;
uint8_t accuracy = 0;
uint64_t importUpdate = totalImport, exportUpdate = totalExport;
while(totalImport > UINT32_MAX || totalExport > UINT32_MAX) {
while(importUpdate > UINT32_MAX || exportUpdate > UINT32_MAX) {
accuracy++;
importUpdate = totalImport / pow(10, accuracy);
exportUpdate = totalExport / pow(10, accuracy);
}
data.lastMonthImport = importUpdate;
data.lastMonthExport = exportUpdate;
data.lastMonthAccuracy = accuracy;
data.month = local.Month;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -8,7 +8,8 @@
}
.cnt {
@apply bg-white m-2 p-2 rounded shadow-lg
@apply bg-white m-2 p-2 rounded shadow-lg;
min-height: 268px;
}
.gwf {

View File

@ -31,7 +31,7 @@
<div>Month</div>
<div class="text-right">{fmtnum(data.m.u)} kWh</div>
{#if hasCost}<div class="text-right">{fmtnum(data.m.c)} {currency}</div>{/if}
<div>Last month</div>
<div>Last mo.</div>
<div class="text-right">{fmtnum(sysinfo.last_month.u)} kWh</div>
{#if hasCost}<div class="text-right">{fmtnum(sysinfo.last_month.c)} {currency}</div>{/if}
</div>
@ -46,7 +46,7 @@
<div>Month</div>
<div class="text-right">{fmtnum(data.m.p)} kWh</div>
{#if hasCost}<div class="text-right">{fmtnum(data.m.i)} {currency}</div>{/if}
<div>Last month</div>
<div>Last mo.</div>
<div class="text-right">{fmtnum(sysinfo.last_month.p)} kWh</div>
{#if hasCost}<div class="text-right">{fmtnum(sysinfo.last_month.i)} {currency}</div>{/if}
</div>

View File

@ -2190,15 +2190,15 @@ void AmsWebServer::configFileDownload() {
EnergyAccountingConfig eac;
config->getEnergyAccountingConfig(eac);
EnergyAccountingData ead = ea->getData();
server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("energyaccounting %d %d %.2f %d %d %.2f %d %d %d %.2f %d %.2f %d %.2f %d %.2f %d %.2f"),
server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("energyaccounting %d %d %.2f %d %d %.2f %d %d %d %.2f %d %.2f %d %.2f %d %.2f %d %.2f %.2f %.2f"),
ead.version,
ead.month,
ead.costYesterday / 10.0,
ead.costThisMonth,
ead.costLastMonth,
ead.incomeYesterday / 10.0,
ead.incomeThisMonth,
ead.incomeLastMonth,
ea->getCostYesterday(),
ea->getCostThisMonth(),
ea->getCostLastMonth(),
ea->getIncomeYesterday(),
ea->getIncomeThisMonth(),
ea->getIncomeLastMonth(),
ead.peaks[0].day,
ead.peaks[0].value / 100.0,
ead.peaks[1].day,
@ -2208,7 +2208,9 @@ void AmsWebServer::configFileDownload() {
ead.peaks[3].day,
ead.peaks[3].value / 100.0,
ead.peaks[4].day,
ead.peaks[4].value / 100.0
ead.peaks[4].value / 100.0,
ea->getUseLastMonth(),
ea->getProducedLastMonth()
));
server.sendContent_P(PSTR("\n"));
}

View File

@ -2104,6 +2104,7 @@ void configFileParse() {
EnergyAccountingData ead = { 0, 0,
0, 0, 0, // Cost
0, 0, 0, // Income
0, 0, 0, // Last month import, export and accuracy
0, 0, // Peak 1
0, 0, // Peak 2
0, 0, // Peak 3
@ -2111,6 +2112,7 @@ void configFileParse() {
0, 0 // Peak 5
};
uint8_t peak = 0;
uint64_t totalImport = 0, totalExport = 0;
char * pch = strtok (buf+17," ");
while (pch != NULL) {
if(ead.version < 5) {
@ -2170,7 +2172,7 @@ void configFileParse() {
} else if(i == 7) {
float val = String(pch).toFloat();
ead.incomeLastMonth = val;
} else if(i >= 8 && i < 20) {
} else if(i >= 8 && i < 18) {
uint8_t hour = i-8;
{
long val = String(pch).toInt();
@ -2183,12 +2185,28 @@ void configFileParse() {
ead.peaks[peak].value = val * 100;
}
peak++;
} else if(i == 18) {
float val = String(pch).toFloat();
totalImport = val * 1000;
} else if(i == 19) {
float val = String(pch).toFloat();
totalExport = val * 1000;
}
}
pch = strtok (NULL, " ");
i++;
}
ead.version = 5;
uint8_t accuracy = 0;
uint64_t importUpdate = totalImport, exportUpdate = totalExport;
while(importUpdate > UINT32_MAX || exportUpdate > UINT32_MAX) {
accuracy++;
importUpdate = totalImport / pow(10, accuracy);
exportUpdate = totalExport / pow(10, accuracy);
}
ead.lastMonthImport = importUpdate;
ead.lastMonthExport = exportUpdate;
ead.version = 6;
ea.setData(ead);
sEa = true;
}