mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-03-12 21:44:21 +00:00
Compare commits
1 Commits
main
...
fix/tariff
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e81ef7a93b |
@@ -7,8 +7,7 @@
|
|||||||
#ifndef _AMSDATA_H
|
#ifndef _AMSDATA_H
|
||||||
#define _AMSDATA_H
|
#define _AMSDATA_H
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include <WString.h>
|
||||||
#include <Timezone.h>
|
|
||||||
#include "OBIScodes.h"
|
#include "OBIScodes.h"
|
||||||
|
|
||||||
enum AmsType {
|
enum AmsType {
|
||||||
@@ -28,7 +27,7 @@ public:
|
|||||||
AmsData();
|
AmsData();
|
||||||
|
|
||||||
void apply(AmsData& other);
|
void apply(AmsData& other);
|
||||||
void apply(const OBIS_code_t obis, double value);
|
void apply(const OBIS_code_t obis, double value, uint64_t millis64);
|
||||||
|
|
||||||
uint64_t getLastUpdateMillis();
|
uint64_t getLastUpdateMillis();
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AmsData.h"
|
#include "AmsData.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
AmsData::AmsData() {}
|
AmsData::AmsData() {}
|
||||||
|
|
||||||
@@ -17,7 +18,6 @@ void AmsData::apply(AmsData& other) {
|
|||||||
uint32_t power = (activeImportPower + other.getActiveImportPower()) / 2;
|
uint32_t power = (activeImportPower + other.getActiveImportPower()) / 2;
|
||||||
float add = power * (((float) ms) / 3600000.0);
|
float add = power * (((float) ms) / 3600000.0);
|
||||||
activeImportCounter += add / 1000.0;
|
activeImportCounter += add / 1000.0;
|
||||||
//Serial.printf("%dW, %dms, %.6fkWh added\n", other.getActiveImportPower(), ms, add);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(other.getListType() > 1) {
|
if(other.getListType() > 1) {
|
||||||
@@ -112,7 +112,7 @@ void AmsData::apply(AmsData& other) {
|
|||||||
this->activeExportPower = other.getActiveExportPower();
|
this->activeExportPower = other.getActiveExportPower();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AmsData::apply(OBIS_code_t obis, double value) {
|
void AmsData::apply(OBIS_code_t obis, double value, uint64_t millis64) {
|
||||||
if(obis.sensor == 0 && obis.gr == 0 && obis.tariff == 0) {
|
if(obis.sensor == 0 && obis.gr == 0 && obis.tariff == 0) {
|
||||||
meterType = value;
|
meterType = value;
|
||||||
}
|
}
|
||||||
@@ -127,138 +127,137 @@ void AmsData::apply(OBIS_code_t obis, double value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(obis.tariff != 0) {
|
if(obis.tariff != 0) {
|
||||||
Serial.println("Tariff not implemented");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(obis.gr == 7) { // Instant values
|
if(obis.gr == 7) { // Instant values
|
||||||
switch(obis.sensor) {
|
switch(obis.sensor) {
|
||||||
case 1:
|
case 1:
|
||||||
activeImportPower = value;
|
activeImportPower = value;
|
||||||
listType = max(listType, (uint8_t) 2);
|
listType = std::max(listType, (uint8_t) 2);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
activeExportPower = value;
|
activeExportPower = value;
|
||||||
listType = max(listType, (uint8_t) 2);
|
listType = std::max(listType, (uint8_t) 2);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
reactiveImportPower = value;
|
reactiveImportPower = value;
|
||||||
listType = max(listType, (uint8_t) 2);
|
listType = std::max(listType, (uint8_t) 2);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
reactiveExportPower = value;
|
reactiveExportPower = value;
|
||||||
listType = max(listType, (uint8_t) 2);
|
listType = std::max(listType, (uint8_t) 2);
|
||||||
break;
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
powerFactor = value;
|
powerFactor = value;
|
||||||
listType = max(listType, (uint8_t) 4);
|
listType = std::max(listType, (uint8_t) 4);
|
||||||
break;
|
break;
|
||||||
case 21:
|
case 21:
|
||||||
l1activeImportPower = value;
|
l1activeImportPower = value;
|
||||||
listType = max(listType, (uint8_t) 4);
|
listType = std::max(listType, (uint8_t) 4);
|
||||||
break;
|
break;
|
||||||
case 22:
|
case 22:
|
||||||
l1activeExportPower = value;
|
l1activeExportPower = value;
|
||||||
listType = max(listType, (uint8_t) 4);
|
listType = std::max(listType, (uint8_t) 4);
|
||||||
break;
|
break;
|
||||||
case 31:
|
case 31:
|
||||||
l1current = value;
|
l1current = value;
|
||||||
listType = max(listType, (uint8_t) 2);
|
listType = std::max(listType, (uint8_t) 2);
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
l1voltage = value;
|
l1voltage = value;
|
||||||
listType = max(listType, (uint8_t) 2);
|
listType = std::max(listType, (uint8_t) 2);
|
||||||
break;
|
break;
|
||||||
case 33:
|
case 33:
|
||||||
l1PowerFactor = value;
|
l1PowerFactor = value;
|
||||||
listType = max(listType, (uint8_t) 4);
|
listType = std::max(listType, (uint8_t) 4);
|
||||||
break;
|
break;
|
||||||
case 41:
|
case 41:
|
||||||
l2activeImportPower = value;
|
l2activeImportPower = value;
|
||||||
listType = max(listType, (uint8_t) 4);
|
listType = std::max(listType, (uint8_t) 4);
|
||||||
break;
|
break;
|
||||||
case 42:
|
case 42:
|
||||||
l2activeExportPower = value;
|
l2activeExportPower = value;
|
||||||
listType = max(listType, (uint8_t) 4);
|
listType = std::max(listType, (uint8_t) 4);
|
||||||
break;
|
break;
|
||||||
case 51:
|
case 51:
|
||||||
l2current = value;
|
l2current = value;
|
||||||
listType = max(listType, (uint8_t) 2);
|
listType = std::max(listType, (uint8_t) 2);
|
||||||
break;
|
break;
|
||||||
case 52:
|
case 52:
|
||||||
l2voltage = value;
|
l2voltage = value;
|
||||||
listType = max(listType, (uint8_t) 2);
|
listType = std::max(listType, (uint8_t) 2);
|
||||||
break;
|
break;
|
||||||
case 53:
|
case 53:
|
||||||
l2PowerFactor = value;
|
l2PowerFactor = value;
|
||||||
listType = max(listType, (uint8_t) 4);
|
listType = std::max(listType, (uint8_t) 4);
|
||||||
break;
|
break;
|
||||||
case 61:
|
case 61:
|
||||||
l3activeImportPower = value;
|
l3activeImportPower = value;
|
||||||
listType = max(listType, (uint8_t) 4);
|
listType = std::max(listType, (uint8_t) 4);
|
||||||
break;
|
break;
|
||||||
case 62:
|
case 62:
|
||||||
l3activeExportPower = value;
|
l3activeExportPower = value;
|
||||||
listType = max(listType, (uint8_t) 4);
|
listType = std::max(listType, (uint8_t) 4);
|
||||||
break;
|
break;
|
||||||
case 71:
|
case 71:
|
||||||
l3current = value;
|
l3current = value;
|
||||||
listType = max(listType, (uint8_t) 2);
|
listType = std::max(listType, (uint8_t) 2);
|
||||||
break;
|
break;
|
||||||
case 72:
|
case 72:
|
||||||
l3voltage = value;
|
l3voltage = value;
|
||||||
listType = max(listType, (uint8_t) 2);
|
listType = std::max(listType, (uint8_t) 2);
|
||||||
break;
|
break;
|
||||||
case 73:
|
case 73:
|
||||||
l3PowerFactor = value;
|
l3PowerFactor = value;
|
||||||
listType = max(listType, (uint8_t) 4);
|
listType = std::max(listType, (uint8_t) 4);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if(obis.gr == 8) { // Accumulated values
|
} else if(obis.gr == 8) { // Accumulated values
|
||||||
switch(obis.sensor) {
|
switch(obis.sensor) {
|
||||||
case 1:
|
case 1:
|
||||||
activeImportCounter = value;
|
activeImportCounter = value;
|
||||||
listType = max(listType, (uint8_t) 3);
|
listType = std::max(listType, (uint8_t) 3);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
activeExportCounter = value;
|
activeExportCounter = value;
|
||||||
listType = max(listType, (uint8_t) 3);
|
listType = std::max(listType, (uint8_t) 3);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
reactiveImportCounter = value;
|
reactiveImportCounter = value;
|
||||||
listType = max(listType, (uint8_t) 3);
|
listType = std::max(listType, (uint8_t) 3);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
reactiveExportCounter = value;
|
reactiveExportCounter = value;
|
||||||
listType = max(listType, (uint8_t) 3);
|
listType = std::max(listType, (uint8_t) 3);
|
||||||
break;
|
break;
|
||||||
case 21:
|
case 21:
|
||||||
l1activeImportCounter = value;
|
l1activeImportCounter = value;
|
||||||
listType = max(listType, (uint8_t) 4);
|
listType = std::max(listType, (uint8_t) 4);
|
||||||
break;
|
break;
|
||||||
case 22:
|
case 22:
|
||||||
l1activeExportCounter = value;
|
l1activeExportCounter = value;
|
||||||
listType = max(listType, (uint8_t) 4);
|
listType = std::max(listType, (uint8_t) 4);
|
||||||
break;
|
break;
|
||||||
case 41:
|
case 41:
|
||||||
l2activeImportCounter = value;
|
l2activeImportCounter = value;
|
||||||
listType = max(listType, (uint8_t) 4);
|
listType = std::max(listType, (uint8_t) 4);
|
||||||
break;
|
break;
|
||||||
case 42:
|
case 42:
|
||||||
l2activeExportCounter = value;
|
l2activeExportCounter = value;
|
||||||
listType = max(listType, (uint8_t) 4);
|
listType = std::max(listType, (uint8_t) 4);
|
||||||
break;
|
break;
|
||||||
case 61:
|
case 61:
|
||||||
l3activeImportCounter = value;
|
l3activeImportCounter = value;
|
||||||
listType = max(listType, (uint8_t) 4);
|
listType = std::max(listType, (uint8_t) 4);
|
||||||
break;
|
break;
|
||||||
case 62:
|
case 62:
|
||||||
l3activeExportCounter = value;
|
l3activeExportCounter = value;
|
||||||
listType = max(listType, (uint8_t) 4);
|
listType = std::max(listType, (uint8_t) 4);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(listType > 0)
|
if(listType > 0)
|
||||||
lastUpdateMillis = millis();
|
lastUpdateMillis = millis64;
|
||||||
|
|
||||||
threePhase = l1voltage > 0 && l2voltage > 0 && l3voltage > 0;
|
threePhase = l1voltage > 0 && l2voltage > 0 && l3voltage > 0;
|
||||||
if(!threePhase)
|
if(!threePhase)
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
#ifndef _ENERGYACCOUNTING_H
|
#ifndef _ENERGYACCOUNTING_H
|
||||||
#define _ENERGYACCOUNTING_H
|
#define _ENERGYACCOUNTING_H
|
||||||
|
|
||||||
#include "Arduino.h"
|
|
||||||
#include "AmsData.h"
|
|
||||||
#include "AmsDataStorage.h"
|
#include "AmsDataStorage.h"
|
||||||
#include "PriceService.h"
|
#include "PriceService.h"
|
||||||
|
|
||||||
@@ -83,7 +81,7 @@ public:
|
|||||||
void setPriceService(PriceService *ps);
|
void setPriceService(PriceService *ps);
|
||||||
void setTimezone(Timezone*);
|
void setTimezone(Timezone*);
|
||||||
EnergyAccountingConfig* getConfig();
|
EnergyAccountingConfig* getConfig();
|
||||||
bool update(AmsData* amsData);
|
bool update(time_t now, uint64_t lastUpdatedMillis, uint8_t listType, uint32_t activeImportPower, uint32_t activeExportPower);
|
||||||
bool load();
|
bool load();
|
||||||
bool save();
|
bool save();
|
||||||
bool isInitialized();
|
bool isInitialized();
|
||||||
|
|||||||
@@ -54,9 +54,8 @@ bool EnergyAccounting::isInitialized() {
|
|||||||
return this->init;
|
return this->init;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EnergyAccounting::update(AmsData* amsData) {
|
bool EnergyAccounting::update(time_t now, uint64_t lastUpdatedMillis, uint8_t listType, uint32_t activeImportPower, uint32_t activeExportPower) {
|
||||||
if(config == NULL) return false;
|
if(config == NULL) return false;
|
||||||
time_t now = time(nullptr);
|
|
||||||
if(now < FirmwareVersion::BuildEpoch) return false;
|
if(now < FirmwareVersion::BuildEpoch) return false;
|
||||||
if(tz == NULL) {
|
if(tz == NULL) {
|
||||||
return false;
|
return false;
|
||||||
@@ -90,7 +89,7 @@ bool EnergyAccounting::update(AmsData* amsData) {
|
|||||||
calcDayCost();
|
calcDayCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(local.Hour != realtimeData->currentHour && (amsData->getListType() >= 3 || local.Minute == 1)) {
|
if(local.Hour != realtimeData->currentHour && (listType >= 3 || local.Minute == 1)) {
|
||||||
tmElements_t oneHrAgo, oneHrAgoLocal;
|
tmElements_t oneHrAgo, oneHrAgoLocal;
|
||||||
breakTime(now-3600, oneHrAgo);
|
breakTime(now-3600, oneHrAgo);
|
||||||
uint16_t val = round(ds->getHourImport(oneHrAgo.Hour) / 10.0);
|
uint16_t val = round(ds->getHourImport(oneHrAgo.Hour) / 10.0);
|
||||||
@@ -156,9 +155,9 @@ bool EnergyAccounting::update(AmsData* amsData) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(realtimeData->lastImportUpdateMillis < amsData->getLastUpdateMillis()) {
|
if(realtimeData->lastImportUpdateMillis < lastUpdatedMillis) {
|
||||||
unsigned long ms = amsData->getLastUpdateMillis() - realtimeData->lastImportUpdateMillis;
|
unsigned long ms = lastUpdatedMillis - realtimeData->lastImportUpdateMillis;
|
||||||
float kwhi = (amsData->getActiveImportPower() * (((float) ms) / 3600000.0)) / 1000.0;
|
float kwhi = (activeImportPower * (((float) ms) / 3600000.0)) / 1000.0;
|
||||||
if(kwhi > 0) {
|
if(kwhi > 0) {
|
||||||
realtimeData->use += kwhi;
|
realtimeData->use += kwhi;
|
||||||
float importPrice = ps == NULL ? PRICE_NO_VALUE : ps->getCurrentPrice(PRICE_DIRECTION_IMPORT);
|
float importPrice = ps == NULL ? PRICE_NO_VALUE : ps->getCurrentPrice(PRICE_DIRECTION_IMPORT);
|
||||||
@@ -168,12 +167,12 @@ bool EnergyAccounting::update(AmsData* amsData) {
|
|||||||
realtimeData->costDay += cost;
|
realtimeData->costDay += cost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
realtimeData->lastImportUpdateMillis = amsData->getLastUpdateMillis();
|
realtimeData->lastImportUpdateMillis = lastUpdatedMillis;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(amsData->getListType() > 1 && realtimeData->lastExportUpdateMillis < amsData->getLastUpdateMillis()) {
|
if(listType > 1 && realtimeData->lastExportUpdateMillis < lastUpdatedMillis) {
|
||||||
unsigned long ms = amsData->getLastUpdateMillis() - realtimeData->lastExportUpdateMillis;
|
unsigned long ms = lastUpdatedMillis - realtimeData->lastExportUpdateMillis;
|
||||||
float kwhe = (amsData->getActiveExportPower() * (((float) ms) / 3600000.0)) / 1000.0;
|
float kwhe = (activeExportPower * (((float) ms) / 3600000.0)) / 1000.0;
|
||||||
if(kwhe > 0) {
|
if(kwhe > 0) {
|
||||||
realtimeData->produce += kwhe;
|
realtimeData->produce += kwhe;
|
||||||
float exportPrice = ps == NULL ? PRICE_NO_VALUE : ps->getCurrentPrice(PRICE_DIRECTION_EXPORT);
|
float exportPrice = ps == NULL ? PRICE_NO_VALUE : ps->getCurrentPrice(PRICE_DIRECTION_EXPORT);
|
||||||
@@ -183,7 +182,7 @@ bool EnergyAccounting::update(AmsData* amsData) {
|
|||||||
realtimeData->incomeDay += income;
|
realtimeData->incomeDay += income;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
realtimeData->lastExportUpdateMillis = amsData->getLastUpdateMillis();
|
realtimeData->lastExportUpdateMillis = lastUpdatedMillis;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config != NULL) {
|
if(config != NULL) {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "AmsConfiguration.h"
|
#include "AmsConfiguration.h"
|
||||||
#include "DataParser.h"
|
#include "DataParser.h"
|
||||||
#include "Cosem.h"
|
#include "Cosem.h"
|
||||||
|
#include "Timezone.h"
|
||||||
#if defined(AMS_REMOTE_DEBUG)
|
#if defined(AMS_REMOTE_DEBUG)
|
||||||
#include "RemoteDebug.h"
|
#include "RemoteDebug.h"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -24,8 +24,6 @@ void KmpCommunicator::configure(MeterConfig& meterConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool KmpCommunicator::loop() {
|
bool KmpCommunicator::loop() {
|
||||||
uint64_t now = millis64();
|
|
||||||
|
|
||||||
bool ret = talker->loop();
|
bool ret = talker->loop();
|
||||||
int lastError = getLastError();
|
int lastError = getLastError();
|
||||||
if(ret) {
|
if(ret) {
|
||||||
@@ -58,35 +56,36 @@ AmsData* KmpCommunicator::getData(AmsData& meterState) {
|
|||||||
if(talker == NULL) return NULL;
|
if(talker == NULL) return NULL;
|
||||||
KmpDataHolder kmpData;
|
KmpDataHolder kmpData;
|
||||||
talker->getData(kmpData);
|
talker->getData(kmpData);
|
||||||
|
uint64_t now = millis64();
|
||||||
AmsData* data = new AmsData();
|
AmsData* data = new AmsData();
|
||||||
data->apply(OBIS_ACTIVE_IMPORT_COUNT, kmpData.activeImportCounter);
|
data->apply(OBIS_ACTIVE_IMPORT_COUNT, kmpData.activeImportCounter, now);
|
||||||
data->apply(OBIS_ACTIVE_EXPORT_COUNT, kmpData.activeExportCounter);
|
data->apply(OBIS_ACTIVE_EXPORT_COUNT, kmpData.activeExportCounter, now);
|
||||||
data->apply(OBIS_REACTIVE_IMPORT_COUNT, kmpData.reactiveImportCounter);
|
data->apply(OBIS_REACTIVE_IMPORT_COUNT, kmpData.reactiveImportCounter, now);
|
||||||
data->apply(OBIS_REACTIVE_EXPORT_COUNT, kmpData.reactiveExportCounter);
|
data->apply(OBIS_REACTIVE_EXPORT_COUNT, kmpData.reactiveExportCounter, now);
|
||||||
data->apply(OBIS_ACTIVE_IMPORT, kmpData.activeImportPower);
|
data->apply(OBIS_ACTIVE_IMPORT, kmpData.activeImportPower, now);
|
||||||
data->apply(OBIS_ACTIVE_EXPORT, kmpData.activeExportPower);
|
data->apply(OBIS_ACTIVE_EXPORT, kmpData.activeExportPower, now);
|
||||||
data->apply(OBIS_REACTIVE_IMPORT, kmpData.reactiveImportPower);
|
data->apply(OBIS_REACTIVE_IMPORT, kmpData.reactiveImportPower, now);
|
||||||
data->apply(OBIS_REACTIVE_EXPORT, kmpData.reactiveExportPower);
|
data->apply(OBIS_REACTIVE_EXPORT, kmpData.reactiveExportPower, now);
|
||||||
data->apply(OBIS_VOLTAGE_L1, kmpData.l1voltage);
|
data->apply(OBIS_VOLTAGE_L1, kmpData.l1voltage, now);
|
||||||
data->apply(OBIS_VOLTAGE_L2, kmpData.l2voltage);
|
data->apply(OBIS_VOLTAGE_L2, kmpData.l2voltage, now);
|
||||||
data->apply(OBIS_VOLTAGE_L3, kmpData.l3voltage);
|
data->apply(OBIS_VOLTAGE_L3, kmpData.l3voltage, now);
|
||||||
data->apply(OBIS_CURRENT_L1, kmpData.l1current);
|
data->apply(OBIS_CURRENT_L1, kmpData.l1current, now);
|
||||||
data->apply(OBIS_CURRENT_L2, kmpData.l2current);
|
data->apply(OBIS_CURRENT_L2, kmpData.l2current, now);
|
||||||
data->apply(OBIS_CURRENT_L3, kmpData.l3current);
|
data->apply(OBIS_CURRENT_L3, kmpData.l3current, now);
|
||||||
data->apply(OBIS_POWER_FACTOR_L1, kmpData.l1PowerFactor);
|
data->apply(OBIS_POWER_FACTOR_L1, kmpData.l1PowerFactor, now);
|
||||||
data->apply(OBIS_POWER_FACTOR_L2, kmpData.l2PowerFactor);
|
data->apply(OBIS_POWER_FACTOR_L2, kmpData.l2PowerFactor, now);
|
||||||
data->apply(OBIS_POWER_FACTOR_L3, kmpData.l3PowerFactor);
|
data->apply(OBIS_POWER_FACTOR_L3, kmpData.l3PowerFactor, now);
|
||||||
data->apply(OBIS_POWER_FACTOR, kmpData.powerFactor);
|
data->apply(OBIS_POWER_FACTOR, kmpData.powerFactor, now);
|
||||||
data->apply(OBIS_ACTIVE_IMPORT_L1, kmpData.l1activeImportPower);
|
data->apply(OBIS_ACTIVE_IMPORT_L1, kmpData.l1activeImportPower, now);
|
||||||
data->apply(OBIS_ACTIVE_IMPORT_L2, kmpData.l2activeImportPower);
|
data->apply(OBIS_ACTIVE_IMPORT_L2, kmpData.l2activeImportPower, now);
|
||||||
data->apply(OBIS_ACTIVE_IMPORT_L3, kmpData.l3activeImportPower);
|
data->apply(OBIS_ACTIVE_IMPORT_L3, kmpData.l3activeImportPower, now);
|
||||||
data->apply(OBIS_ACTIVE_EXPORT_L1, kmpData.l1activeExportPower);
|
data->apply(OBIS_ACTIVE_EXPORT_L1, kmpData.l1activeExportPower, now);
|
||||||
data->apply(OBIS_ACTIVE_EXPORT_L2, kmpData.l2activeExportPower);
|
data->apply(OBIS_ACTIVE_EXPORT_L2, kmpData.l2activeExportPower, now);
|
||||||
data->apply(OBIS_ACTIVE_EXPORT_L3, kmpData.l3activeExportPower);
|
data->apply(OBIS_ACTIVE_EXPORT_L3, kmpData.l3activeExportPower, now);
|
||||||
data->apply(OBIS_ACTIVE_IMPORT_COUNT_L1, kmpData.l1activeImportCounter);
|
data->apply(OBIS_ACTIVE_IMPORT_COUNT_L1, kmpData.l1activeImportCounter, now);
|
||||||
data->apply(OBIS_ACTIVE_IMPORT_COUNT_L2, kmpData.l2activeImportCounter);
|
data->apply(OBIS_ACTIVE_IMPORT_COUNT_L2, kmpData.l2activeImportCounter, now);
|
||||||
data->apply(OBIS_ACTIVE_IMPORT_COUNT_L3, kmpData.l3activeImportCounter);
|
data->apply(OBIS_ACTIVE_IMPORT_COUNT_L3, kmpData.l3activeImportCounter, now);
|
||||||
data->apply(OBIS_METER_ID, kmpData.meterId);
|
data->apply(OBIS_METER_ID, kmpData.meterId, now);
|
||||||
data->apply(OBIS_NULL, AmsTypeKamstrup);
|
data->apply(OBIS_NULL, AmsTypeKamstrup, now);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
#ifndef _REALTIMEPLOT_H
|
#ifndef _REALTIMEPLOT_H
|
||||||
#define _REALTIMEPLOT_H
|
#define _REALTIMEPLOT_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "AmsData.h"
|
#include "AmsData.h"
|
||||||
|
|
||||||
#define REALTIME_SAMPLE 10000
|
#define REALTIME_SAMPLE 10000
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Arduino.h"
|
||||||
#include "RealtimePlot.h"
|
#include "RealtimePlot.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|||||||
56
lib/SvelteUi/app/package-lock.json
generated
56
lib/SvelteUi/app/package-lock.json
generated
@@ -613,6 +613,14 @@
|
|||||||
"tailwindcss": ">=3.0.0 || >= 3.0.0-alpha.1 || >= 4.0.0-alpha.20 || >= 4.0.0-beta.1"
|
"tailwindcss": ">=3.0.0 || >= 3.0.0-alpha.1 || >= 4.0.0-alpha.20 || >= 4.0.0-beta.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@trysound/sax": {
|
||||||
|
"version": "0.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@trysound/sax/-/sax-0.2.0.tgz",
|
||||||
|
"integrity": "sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.13.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/estree": {
|
"node_modules/@types/estree": {
|
||||||
"version": "1.0.6",
|
"version": "1.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz",
|
||||||
@@ -1812,11 +1820,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/minimatch": {
|
"node_modules/minimatch": {
|
||||||
"version": "3.1.5",
|
"version": "3.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||||
"integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==",
|
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
},
|
},
|
||||||
@@ -2711,11 +2718,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/rollup": {
|
"node_modules/rollup": {
|
||||||
"version": "3.30.0",
|
"version": "3.29.5",
|
||||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-3.30.0.tgz",
|
"resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.5.tgz",
|
||||||
"integrity": "sha512-kQvGasUgN+AlWGliFn2POSajRQEsULVYFGTvOZmK06d7vCD+YhZztt70kGk3qaeAXeWYL5eO7zx+rAubBc55eA==",
|
"integrity": "sha512-GVsDdsbJzzy4S/v3dqWPJ7EfvZJfCHiDqe80IyrF59LYuP+e6U1LJoUqeuqRbwAWoMNoXivMNeNAOf5E22VA1w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
|
||||||
"bin": {
|
"bin": {
|
||||||
"rollup": "dist/bin/rollup"
|
"rollup": "dist/bin/rollup"
|
||||||
},
|
},
|
||||||
@@ -2762,15 +2768,6 @@
|
|||||||
"rimraf": "^2.5.2"
|
"rimraf": "^2.5.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/sax": {
|
|
||||||
"version": "1.5.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/sax/-/sax-1.5.0.tgz",
|
|
||||||
"integrity": "sha512-21IYA3Q5cQf089Z6tgaUTr7lDAyzoTPx5HRtbhsME8Udispad8dC/+sziTNugOEx54ilvatQ9YCzl4KQLPcRHA==",
|
|
||||||
"license": "BlueOak-1.0.0",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=11.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/shebang-command": {
|
"node_modules/shebang-command": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
|
||||||
@@ -2987,11 +2984,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/sucrase/node_modules/brace-expansion": {
|
"node_modules/sucrase/node_modules/brace-expansion": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
|
||||||
"integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==",
|
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"balanced-match": "^1.0.0"
|
"balanced-match": "^1.0.0"
|
||||||
}
|
}
|
||||||
@@ -3026,13 +3022,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/sucrase/node_modules/minimatch": {
|
"node_modules/sucrase/node_modules/minimatch": {
|
||||||
"version": "9.0.9",
|
"version": "9.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
|
||||||
"integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==",
|
"integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"brace-expansion": "^2.0.2"
|
"brace-expansion": "^2.0.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16 || 14 >=14.17"
|
"node": ">=16 || 14 >=14.17"
|
||||||
@@ -3189,17 +3184,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/svgo": {
|
"node_modules/svgo": {
|
||||||
"version": "2.8.2",
|
"version": "2.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/svgo/-/svgo-2.8.2.tgz",
|
"resolved": "https://registry.npmjs.org/svgo/-/svgo-2.8.0.tgz",
|
||||||
"integrity": "sha512-TyzE4NVGLUFy+H/Uy4N6c3G0HEeprsVfge6Lmq+0FdQQ/zqoVYB62IsBZORsiL+o96s6ff/V6/3UQo/C0cgCAA==",
|
"integrity": "sha512-+N/Q9kV1+F+UeWYoSiULYo4xYSDQlTgb+ayMobAXPwMnLvop7oxKMo9OzIrX5x3eS4L4f2UHhc9axXwY8DpChg==",
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@trysound/sax": "0.2.0",
|
||||||
"commander": "^7.2.0",
|
"commander": "^7.2.0",
|
||||||
"css-select": "^4.1.3",
|
"css-select": "^4.1.3",
|
||||||
"css-tree": "^1.1.3",
|
"css-tree": "^1.1.3",
|
||||||
"csso": "^4.2.0",
|
"csso": "^4.2.0",
|
||||||
"picocolors": "^1.0.0",
|
"picocolors": "^1.0.0",
|
||||||
"sax": "^1.5.0",
|
|
||||||
"stable": "^0.1.8"
|
"stable": "^0.1.8"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -378,10 +378,6 @@ void setup() {
|
|||||||
|
|
||||||
delay(1);
|
delay(1);
|
||||||
hw.setup(&sysConfig, &gpioConfig);
|
hw.setup(&sysConfig, &gpioConfig);
|
||||||
hw.ledOff(LED_INTERNAL);
|
|
||||||
hw.ledOff(LED_RED);
|
|
||||||
hw.ledOff(LED_GREEN);
|
|
||||||
hw.ledOff(LED_BLUE);
|
|
||||||
|
|
||||||
if(gpioConfig.apPin >= 0) {
|
if(gpioConfig.apPin >= 0) {
|
||||||
pinMode(gpioConfig.apPin, INPUT_PULLUP);
|
pinMode(gpioConfig.apPin, INPUT_PULLUP);
|
||||||
@@ -1611,7 +1607,7 @@ void handleDataSuccess(AmsData* data) {
|
|||||||
debugD_P(PSTR("NOT Ready to update (internal clock %02d:%02d:%02d UTC, meter clock: %02d:%02d:%02d, list type %d, est: %d)"), tm.Hour, tm.Minute, tm.Second, mtm.Hour, mtm.Minute, mtm.Second, data->getListType(), wasCounterEstimated);
|
debugD_P(PSTR("NOT Ready to update (internal clock %02d:%02d:%02d UTC, meter clock: %02d:%02d:%02d, list type %d, est: %d)"), tm.Hour, tm.Minute, tm.Second, mtm.Hour, mtm.Minute, mtm.Second, data->getListType(), wasCounterEstimated);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ea.update(data)) {
|
if(ea.update(dataUpdateTime, data->getLastUpdateMillis(), data->getListType(), data->getActiveImportPower(), data->getActiveExportPower())) {
|
||||||
debugI_P(PSTR("Saving energy accounting"));
|
debugI_P(PSTR("Saving energy accounting"));
|
||||||
if(!ea.save()) {
|
if(!ea.save()) {
|
||||||
debugW_P(PSTR("Unable to save energy accounting"));
|
debugW_P(PSTR("Unable to save energy accounting"));
|
||||||
|
|||||||
Reference in New Issue
Block a user