mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-03-13 05:51:09 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b0d540f39 | ||
|
|
33bd3da310 | ||
|
|
a239e1a63d | ||
|
|
1ef5703971 |
@@ -70,11 +70,14 @@ bool EnergyAccounting::update(AmsData* amsData) {
|
||||
if(local.Hour != currentHour && (amsData->getListType() >= 3 || local.Minute == 1)) {
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EnergyAccounting) New local hour %d\n", local.Hour);
|
||||
|
||||
tmElements_t oneHrAgo;
|
||||
tmElements_t oneHrAgo, oneHrAgoLocal;
|
||||
breakTime(now-3600, oneHrAgo);
|
||||
uint16_t val = ds->getHourImport(oneHrAgo.Hour) / 10;
|
||||
ret |= updateMax(val, local.Day);
|
||||
|
||||
breakTime(tz->toLocal(now-3600), oneHrAgoLocal);
|
||||
ret |= updateMax(val, oneHrAgoLocal.Day);
|
||||
|
||||
currentHour = local.Hour; // Need to be defined here so that day cost is correctly calculated
|
||||
if(local.Hour > 0) {
|
||||
calcDayCost();
|
||||
}
|
||||
@@ -143,9 +146,9 @@ void EnergyAccounting::calcDayCost() {
|
||||
if(eapi != NULL && eapi->getValueForHour(0) != ENTSOE_NO_VALUE) {
|
||||
if(initPrice) costDay = 0;
|
||||
for(int i = 0; i < currentHour; i++) {
|
||||
float price = eapi->getValueForHour(i - currentHour);
|
||||
float price = eapi->getValueForHour(i - local.Hour);
|
||||
if(price == ENTSOE_NO_VALUE) break;
|
||||
breakTime(now - ((currentHour - i) * 3600), utc);
|
||||
breakTime(now - ((local.Hour - i) * 3600), utc);
|
||||
int16_t wh = ds->getHourImport(utc.Hour);
|
||||
costDay += price * (wh / 1000.0);
|
||||
}
|
||||
@@ -161,9 +164,10 @@ double EnergyAccounting::getUseToday() {
|
||||
float ret = 0.0;
|
||||
time_t now = time(nullptr);
|
||||
if(now < BUILD_EPOCH) return 0;
|
||||
tmElements_t utc;
|
||||
tmElements_t utc, local;
|
||||
breakTime(tz->toLocal(now), local);
|
||||
for(int i = 0; i < currentHour; i++) {
|
||||
breakTime(now - ((currentHour - i) * 3600), utc);
|
||||
breakTime(now - ((local.Hour - i) * 3600), utc);
|
||||
ret += ds->getHourImport(utc.Hour) / 1000.0;
|
||||
}
|
||||
return ret + getUseThisHour();
|
||||
|
||||
@@ -98,8 +98,10 @@ IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, MeterConfig* meterCo
|
||||
}
|
||||
|
||||
if(listType >= 2 && memcmp(meterModel.c_str(), "MA304T3", 7) == 0) {
|
||||
l2current = (((activeImportPower - activeExportPower) * sqrt(3)) - (l1voltage * l1current) - (l3voltage * l3current)) / l2voltage;
|
||||
l2voltage = sqrt(pow(l1voltage - l3voltage * cos(60 * (PI/180)), 2) + pow(l3voltage * sin(60 * (PI/180)),2));
|
||||
if(l2voltage > 0) {
|
||||
l2current = (((activeImportPower - activeExportPower) * sqrt(3)) - (l1voltage * l1current) - (l3voltage * l3current)) / l2voltage;
|
||||
}
|
||||
}
|
||||
|
||||
if(listType == 3) {
|
||||
|
||||
@@ -347,6 +347,7 @@ void AmsWebServer::configMeterHtml() {
|
||||
html.replace(F("{mod}"), meterState->getMeterModel());
|
||||
html.replace(F("{mid}"), meterState->getMeterId());
|
||||
html.replace(F("{b}"), String(meterConfig->baud));
|
||||
html.replace(F("{b300}"), meterConfig->baud == 300 ? F("selected") : F(""));
|
||||
html.replace(F("{b2400}"), meterConfig->baud == 2400 ? F("selected") : F(""));
|
||||
html.replace(F("{b4800}"), meterConfig->baud == 4800 ? F("selected") : F(""));
|
||||
html.replace(F("{b9600}"), meterConfig->baud == 9600 ? F("selected") : F(""));
|
||||
@@ -1264,6 +1265,7 @@ void AmsWebServer::handleSave() {
|
||||
if(server.hasArg(F("h")) && !server.arg(F("h")).isEmpty()) {
|
||||
strcpy(wifi.hostname, server.arg(F("h")).c_str());
|
||||
}
|
||||
wifi.mdns = server.arg(F("m")) == F("true");
|
||||
wifi.power = server.arg(F("w")).toFloat() * 10;
|
||||
wifi.sleep = server.arg(F("z")).toInt();
|
||||
config->setWiFiConfig(wifi);
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
<span class="input-group-text">Baud rate</span>
|
||||
</div>
|
||||
<select class="form-control sd" name="b">
|
||||
<option value="300" {b300}>300</option>
|
||||
<option value="2400" {b2400}>2400</option>
|
||||
<option value="4800" {b4800}>4800</option>
|
||||
<option value="9600" {b9600}>9600</option>
|
||||
|
||||
Reference in New Issue
Block a user