Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29524c2123 | ||
|
|
e2fb5e2673 | ||
|
|
751a0edca7 | ||
|
|
a8e62e086c | ||
|
|
35eb69bebb | ||
|
|
5c7c0699b2 | ||
|
|
7e31a60000 | ||
|
|
793bc877fc | ||
|
|
5ab6de21dc | ||
|
|
db5e242ad8 | ||
|
|
5be921a342 |
@@ -2,7 +2,7 @@
|
|||||||
1.1.2.8.0.255 - Active- Energy
|
1.1.2.8.0.255 - Active- Energy
|
||||||
1.1.3.8.0.255 - Reactive+ Energy
|
1.1.3.8.0.255 - Reactive+ Energy
|
||||||
1.1.4.8.0.255 - Reactive- Energy
|
1.1.4.8.0.255 - Reactive- Energy
|
||||||
1.1.0.0.1.255 - Electricity ID?
|
1.1.0.0.1.255 - Meter number 1
|
||||||
1.1.1.7.0.255 - Active+ Instantaneous value
|
1.1.1.7.0.255 - Active+ Instantaneous value
|
||||||
1.1.2.7.0.255 - Active- Instantaneous value
|
1.1.2.7.0.255 - Active- Instantaneous value
|
||||||
1.1.3.7.0.255 - Reactive+ Instantaneous value
|
1.1.3.7.0.255 - Reactive+ Instantaneous value
|
||||||
|
|||||||
BIN
doc/Germany/Anleitung_M-Bus_Protokoll_V1.0.pdf
Normal file
BIN
doc/M-Bus_DOC48.PDF
Normal file
BIN
doc/omnipower.technical.description.pdf
Normal file
51
frames/Kamstrup-1p.raw
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
7E A0 BA 2B 21 13 ED AA E6 E7 00 0F 00 00 00 00
|
||||||
|
0C 07 E6 02 05 06 0D 00 0A FF 80 00 00
|
||||||
|
02 19
|
||||||
|
0A 0E 4B 61 6D 73 74 72 75 70 5F 56 30 30 30 31
|
||||||
|
09 06 01 01 00 00 05 FF 0A 10 35 37 30 36 35 36 37 32 37 31 35 33 33 32 30 37
|
||||||
|
09 06 01 01 60 01 01 FF 0A 12 36 38 36 31 31 31 31 42 4E 32 34 32 31 30 31 30 34 30
|
||||||
|
09 06 01 01 01 07 00 FF 06 00 00 02 68
|
||||||
|
09 06 01 01 02 07 00 FF 06 00 00 00 00
|
||||||
|
09 06 01 01 03 07 00 FF 06 00 00 00 53
|
||||||
|
09 06 01 01 04 07 00 FF 06 00 00 00 00
|
||||||
|
09 06 01 01 1F 07 00 FF 06 00 00 01 22
|
||||||
|
00 00 00 00
|
||||||
|
09 06 01 01 20 07 00 FF 12 00 E2
|
||||||
|
00 00 00 00
|
||||||
|
05 D8 7E
|
||||||
|
|
||||||
|
7E A0 BA 2B 21 13 ED AA E6 E7 00 0F 00 00 00 00
|
||||||
|
0C 07 E6 02 05 06 0D 00 14 FF 80 00 00
|
||||||
|
02 19
|
||||||
|
0A 0E 4B 61 6D 73 74 72 75 70 5F 56 30 30 30 31
|
||||||
|
09 06 01 01 00 00 05 FF 0A 10 35 37 30 36 35 36 37 32 37 31 35 33 33 32 30 37
|
||||||
|
09 06 01 01 60 01 01 FF 0A 12 36 38 36 31 31 31 31 42 4E 32 34 32 31 30 31 30 34 30
|
||||||
|
09 06 01 01 01 07 00 FF 06 00 00 02 68
|
||||||
|
09 06 01 01 02 07 00 FF 06 00 00 00 00
|
||||||
|
09 06 01 01 03 07 00 FF 06 00 00 00 53
|
||||||
|
09 06 01 01 04 07 00 FF 06 00 00 00 00
|
||||||
|
09 06 01 01 1F 07 00 FF 06 00 00 01 23
|
||||||
|
00 00 00 00
|
||||||
|
09 06 01 01 20 07 00 FF 12 00 E1
|
||||||
|
00 00 00 00
|
||||||
|
8E 5E 7E
|
||||||
|
|
||||||
|
7E A1 04 2B 21 13 77 6E E6 E7 00 0F 00 00 00 00
|
||||||
|
0C 07 E6 02 05 06 0D 00 19 FF 80 00 00
|
||||||
|
02 23 0A 0E 4B 61 6D 73 74 72 75 70 5F 56 30 30 30 31
|
||||||
|
09 06 01 01 00 00 05 FF 0A 10 35 37 30 36 35 36 37 32 37 31 35 33 33 32 30 37
|
||||||
|
09 06 01 01 60 01 01 FF 0A 12 36 38 36 31 31 31 31 42 4E 32 34 32 31 30 31 30 34 30
|
||||||
|
09 06 01 01 01 07 00 FF 06 00 00 02 6B
|
||||||
|
09 06 01 01 02 07 00 FF 06 00 00 00 00
|
||||||
|
09 06 01 01 03 07 00 FF 06 00 00 00 54
|
||||||
|
09 06 01 01 04 07 00 FF 06 00 00 00 00
|
||||||
|
09 06 01 01 1F 07 00 FF 06 00 00 01 25
|
||||||
|
00 00 00 00
|
||||||
|
09 06 01 01 20 07 00 FF 12 00 E1
|
||||||
|
00 00 00 00
|
||||||
|
09 06 00 01 01 00 00 FF 09 0C 07 E6 02 05 06 0D 00 19 FF 80 00 00
|
||||||
|
09 06 01 01 01 08 00 FF 06 00 12 CF 93
|
||||||
|
09 06 01 01 02 08 00 FF 06 00 00 00 00
|
||||||
|
09 06 01 01 03 08 00 FF 06 00 00 8C CE
|
||||||
|
09 06 01 01 04 08 00 FF 06 00 05 E5 04
|
||||||
|
7F E9 7E
|
||||||
BIN
images/dashboard.png
Normal file
|
After Width: | Height: | Size: 136 KiB |
BIN
images/dayplot.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
images/future-energy-price.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
images/main-header.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
images/monthplot.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
images/real-time-calculation.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
images/sensor-displays.png
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
images/status-bar.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
images/tempsensors.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
@@ -30,3 +30,4 @@ extra_scripts =
|
|||||||
scripts/makeweb.py
|
scripts/makeweb.py
|
||||||
build_flags =
|
build_flags =
|
||||||
-D WEBSOCKET_DISABLED=1
|
-D WEBSOCKET_DISABLED=1
|
||||||
|
board_build.f_cpu = 160000000L
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ void AmsDataStorage::setHour(uint8_t hour, int32_t val) {
|
|||||||
day.points[hour] = val / 10;
|
day.points[hour] = val / 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t AmsDataStorage::getHour(uint8_t hour) {
|
int32_t AmsDataStorage::getHour(uint8_t hour) {
|
||||||
if(hour < 0 || hour > 24) return 0;
|
if(hour < 0 || hour > 24) return 0;
|
||||||
return day.points[hour] * 10;
|
return day.points[hour] * 10;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public:
|
|||||||
AmsDataStorage(RemoteDebug*);
|
AmsDataStorage(RemoteDebug*);
|
||||||
void setTimezone(Timezone*);
|
void setTimezone(Timezone*);
|
||||||
bool update(AmsData*);
|
bool update(AmsData*);
|
||||||
int16_t getHour(uint8_t);
|
int32_t getHour(uint8_t);
|
||||||
int32_t getDay(uint8_t);
|
int32_t getDay(uint8_t);
|
||||||
bool load();
|
bool load();
|
||||||
bool save();
|
bool save();
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ ADC_MODE(ADC_VCC);
|
|||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
#include <esp_task_wdt.h>
|
#include <esp_task_wdt.h>
|
||||||
#endif
|
#endif
|
||||||
#define WDT_TIMEOUT 30
|
#define WDT_TIMEOUT 60
|
||||||
|
|
||||||
#include "AmsToMqttBridge.h"
|
#include "AmsToMqttBridge.h"
|
||||||
#include "AmsStorage.h"
|
#include "AmsStorage.h"
|
||||||
@@ -439,31 +439,35 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
if(eapi != NULL && ntpEnabled) {
|
try {
|
||||||
if(eapi->loop() && mqtt != NULL && mqttHandler != NULL && mqtt->connected()) {
|
if(eapi != NULL && ntpEnabled) {
|
||||||
mqttHandler->publishPrices(eapi);
|
if(eapi->loop() && mqtt != NULL && mqttHandler != NULL && mqtt->connected()) {
|
||||||
}
|
mqttHandler->publishPrices(eapi);
|
||||||
}
|
|
||||||
|
|
||||||
if(config.isEntsoeChanged()) {
|
|
||||||
EntsoeConfig entsoe;
|
|
||||||
if(config.getEntsoeConfig(entsoe) && strlen(entsoe.token) > 0) {
|
|
||||||
if(eapi == NULL) {
|
|
||||||
eapi = new EntsoeApi(&Debug);
|
|
||||||
ws.setEntsoeApi(eapi);
|
|
||||||
}
|
}
|
||||||
eapi->setup(entsoe);
|
|
||||||
} else if(eapi != NULL) {
|
|
||||||
delete eapi;
|
|
||||||
eapi = NULL;
|
|
||||||
ws.setEntsoeApi(NULL);
|
|
||||||
}
|
}
|
||||||
config.ackEntsoeChange();
|
|
||||||
|
if(config.isEntsoeChanged()) {
|
||||||
|
EntsoeConfig entsoe;
|
||||||
|
if(config.getEntsoeConfig(entsoe) && strlen(entsoe.token) > 0) {
|
||||||
|
if(eapi == NULL) {
|
||||||
|
eapi = new EntsoeApi(&Debug);
|
||||||
|
ws.setEntsoeApi(eapi);
|
||||||
|
}
|
||||||
|
eapi->setup(entsoe);
|
||||||
|
} else if(eapi != NULL) {
|
||||||
|
delete eapi;
|
||||||
|
eapi = NULL;
|
||||||
|
ws.setEntsoeApi(NULL);
|
||||||
|
}
|
||||||
|
config.ackEntsoeChange();
|
||||||
|
}
|
||||||
|
} catch(const std::exception& e) {
|
||||||
|
debugE("Exception in ENTSO-E loop (%s)", e.what());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
ws.loop();
|
ws.loop();
|
||||||
}
|
}
|
||||||
if(mqtt != NULL) { // Run loop regardless, to let MQTT do its work.
|
if(mqtt != NULL) {
|
||||||
mqtt->loop();
|
mqtt->loop();
|
||||||
delay(10); // Needed to preserve power. After adding this, the voltage is super smooth on a HAN powered device
|
delay(10); // Needed to preserve power. After adding this, the voltage is super smooth on a HAN powered device
|
||||||
}
|
}
|
||||||
@@ -682,11 +686,12 @@ void swapWifiMode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int len = 0;
|
int len = 0;
|
||||||
uint8_t buf[BUF_SIZE];
|
uint8_t* buf = NULL;
|
||||||
MbusAssembler* ma = NULL;
|
MbusAssembler* ma = NULL;
|
||||||
int currentMeterType = -1;
|
int currentMeterType = -1;
|
||||||
bool readHanPort() {
|
bool readHanPort() {
|
||||||
if(!hanSerial->available()) return false;
|
if(!hanSerial->available()) return false;
|
||||||
|
if(buf == NULL) buf = (uint8_t*) malloc(BUF_SIZE);
|
||||||
|
|
||||||
if(currentMeterType == -1) {
|
if(currentMeterType == -1) {
|
||||||
hanSerial->readBytes(buf, BUF_SIZE);
|
hanSerial->readBytes(buf, BUF_SIZE);
|
||||||
@@ -840,17 +845,19 @@ bool readHanPort() {
|
|||||||
hw.ledBlink(LED_INTERNAL, 1);
|
hw.ledBlink(LED_INTERNAL, 1);
|
||||||
if(mqttEnabled && mqttHandler != NULL && mqtt != NULL) {
|
if(mqttEnabled && mqttHandler != NULL && mqtt != NULL) {
|
||||||
if(mqttHandler->publish(&data, &meterState)) {
|
if(mqttHandler->publish(&data, &meterState)) {
|
||||||
|
mqtt->loop();
|
||||||
|
delay(10);
|
||||||
if(data.getListType() == 3 && eapi != NULL) {
|
if(data.getListType() == 3 && eapi != NULL) {
|
||||||
mqttHandler->publishPrices(eapi);
|
mqttHandler->publishPrices(eapi);
|
||||||
|
mqtt->loop();
|
||||||
|
delay(10);
|
||||||
}
|
}
|
||||||
if(data.getListType() >= 2) {
|
if(data.getListType() >= 2) {
|
||||||
mqttHandler->publishSystem(&hw);
|
mqttHandler->publishSystem(&hw);
|
||||||
|
mqtt->loop();
|
||||||
|
delay(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(mqtt != NULL) {
|
|
||||||
mqtt->loop();
|
|
||||||
delay(10);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t now = time(nullptr);
|
time_t now = time(nullptr);
|
||||||
@@ -1024,7 +1031,7 @@ void MQTT_connect() {
|
|||||||
mqtt->disconnect();
|
mqtt->disconnect();
|
||||||
yield();
|
yield();
|
||||||
} else {
|
} else {
|
||||||
mqtt = new MQTTClient(512);
|
mqtt = new MQTTClient(1024);
|
||||||
ws.setMqtt(mqtt);
|
ws.setMqtt(mqtt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -308,6 +308,14 @@ IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, uint8_t distribution
|
|||||||
l2PowerFactor /= 100;
|
l2PowerFactor /= 100;
|
||||||
if(l3PowerFactor != 0)
|
if(l3PowerFactor != 0)
|
||||||
l3PowerFactor /= 100;
|
l3PowerFactor /= 100;
|
||||||
|
|
||||||
|
int watt = abs((l1voltage * l1current) + (l2voltage * l2current) + (l3voltage * l3current));
|
||||||
|
if(watt / (activeImportPower + activeExportPower + reactiveImportPower + reactiveExportPower) > 2) {
|
||||||
|
l1current = l1current != 0 ? l1current / 10 : 0;
|
||||||
|
l2current = l2current != 0 ? l2current / 10 : 0;
|
||||||
|
l3current = l3current != 0 ? l3current / 10 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
} else if(meterType == AmsTypeSagemcom) {
|
} else if(meterType == AmsTypeSagemcom) {
|
||||||
CosemData* meterTs = getCosemDataAt(1, ((char *) (d)));
|
CosemData* meterTs = getCosemDataAt(1, ((char *) (d)));
|
||||||
if(meterTs != NULL) {
|
if(meterTs != NULL) {
|
||||||
@@ -380,11 +388,13 @@ CosemData* IEC6205675::getCosemDataAt(uint8_t index, const char* ptr) {
|
|||||||
pos += 5;
|
pos += 5;
|
||||||
break;
|
break;
|
||||||
case CosemTypeNull:
|
case CosemTypeNull:
|
||||||
return NULL;
|
pos += 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
pos += 2;
|
pos += 2;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
if(pos-ptr > 900) break;
|
||||||
} while(item->base.type != HDLC_FLAG);
|
} while(item->base.type != HDLC_FLAG);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -423,10 +433,12 @@ CosemData* IEC6205675::findObis(uint8_t* obis, int matchlength, const char* ptr)
|
|||||||
pos += 5;
|
pos += 5;
|
||||||
break;
|
break;
|
||||||
case CosemTypeNull:
|
case CosemTypeNull:
|
||||||
return NULL;
|
pos += 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
pos += 2;
|
pos += 2;
|
||||||
}
|
}
|
||||||
|
if(pos-ptr > 900) break;
|
||||||
} while(item->base.type != HDLC_FLAG);
|
} while(item->base.type != HDLC_FLAG);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,26 +31,12 @@ private:
|
|||||||
uint8_t AMS_OBIS_METER_ID_2[4] = { 0, 0, 5, 255 };
|
uint8_t AMS_OBIS_METER_ID_2[4] = { 0, 0, 5, 255 };
|
||||||
uint8_t AMS_OBIS_METER_TIMESTAMP[4] = { 1, 0, 0, 255 };
|
uint8_t AMS_OBIS_METER_TIMESTAMP[4] = { 1, 0, 0, 255 };
|
||||||
uint8_t AMS_OBIS_ACTIVE_IMPORT[4] = { 1, 7, 0, 255 };
|
uint8_t AMS_OBIS_ACTIVE_IMPORT[4] = { 1, 7, 0, 255 };
|
||||||
uint8_t AMS_OBIS_ACTIVE_IMPORT_L1[4] = { 21, 7, 0, 255 };
|
|
||||||
uint8_t AMS_OBIS_ACTIVE_IMPORT_L2[4] = { 41, 7, 0, 255 };
|
|
||||||
uint8_t AMS_OBIS_ACTIVE_IMPORT_L3[4] = { 61, 7, 0, 255 };
|
|
||||||
uint8_t AMS_OBIS_ACTIVE_EXPORT[4] = { 2, 7, 0, 255 };
|
uint8_t AMS_OBIS_ACTIVE_EXPORT[4] = { 2, 7, 0, 255 };
|
||||||
uint8_t AMS_OBIS_ACTIVE_EXPORT_L1[4] = { 22, 7, 0, 255 };
|
|
||||||
uint8_t AMS_OBIS_ACTIVE_EXPORT_L2[4] = { 42, 7, 0, 255 };
|
|
||||||
uint8_t AMS_OBIS_ACTIVE_EXPORT_L3[4] = { 62, 7, 0, 255 };
|
|
||||||
uint8_t AMS_OBIS_REACTIVE_IMPORT[4] = { 3, 7, 0, 255 };
|
uint8_t AMS_OBIS_REACTIVE_IMPORT[4] = { 3, 7, 0, 255 };
|
||||||
uint8_t AMS_OBIS_REACTIVE_IMPORT_L1[4] = { 23, 7, 0, 255 };
|
|
||||||
uint8_t AMS_OBIS_REACTIVE_IMPORT_L2[4] = { 43, 7, 0, 255 };
|
|
||||||
uint8_t AMS_OBIS_REACTIVE_IMPORT_L3[4] = { 63, 7, 0, 255 };
|
|
||||||
uint8_t AMS_OBIS_REACTIVE_EXPORT[4] = { 4, 7, 0, 255 };
|
uint8_t AMS_OBIS_REACTIVE_EXPORT[4] = { 4, 7, 0, 255 };
|
||||||
uint8_t AMS_OBIS_REACTIVE_EXPORT_L1[4] = { 24, 7, 0, 255 };
|
|
||||||
uint8_t AMS_OBIS_REACTIVE_EXPORT_L2[4] = { 44, 7, 0, 255 };
|
|
||||||
uint8_t AMS_OBIS_REACTIVE_EXPORT_L3[4] = { 64, 7, 0, 255 };
|
|
||||||
uint8_t AMS_OBIS_CURRENT[4] = { 11, 7, 0, 255 };
|
|
||||||
uint8_t AMS_OBIS_CURRENT_L1[4] = { 31, 7, 0, 255 };
|
uint8_t AMS_OBIS_CURRENT_L1[4] = { 31, 7, 0, 255 };
|
||||||
uint8_t AMS_OBIS_CURRENT_L2[4] = { 51, 7, 0, 255 };
|
uint8_t AMS_OBIS_CURRENT_L2[4] = { 51, 7, 0, 255 };
|
||||||
uint8_t AMS_OBIS_CURRENT_L3[4] = { 71, 7, 0, 255 };
|
uint8_t AMS_OBIS_CURRENT_L3[4] = { 71, 7, 0, 255 };
|
||||||
uint8_t AMS_OBIS_VOLTAGE[4] = { 12, 7, 0, 255 };
|
|
||||||
uint8_t AMS_OBIS_VOLTAGE_L1[4] = { 32, 7, 0, 255 };
|
uint8_t AMS_OBIS_VOLTAGE_L1[4] = { 32, 7, 0, 255 };
|
||||||
uint8_t AMS_OBIS_VOLTAGE_L2[4] = { 52, 7, 0, 255 };
|
uint8_t AMS_OBIS_VOLTAGE_L2[4] = { 52, 7, 0, 255 };
|
||||||
uint8_t AMS_OBIS_VOLTAGE_L3[4] = { 72, 7, 0, 255 };
|
uint8_t AMS_OBIS_VOLTAGE_L3[4] = { 72, 7, 0, 255 };
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ int HDLC_validate(const uint8_t* d, int length, HDLCConfig* config, CosemDateTim
|
|||||||
} else if(dateTime->base.type == CosemTypeDateTime) {
|
} else if(dateTime->base.type == CosemTypeDateTime) {
|
||||||
memcpy(timestamp, ptr, dateTime->base.length);
|
memcpy(timestamp, ptr, dateTime->base.length);
|
||||||
} else if(dateTime->base.type == 0x0C) { // Kamstrup bug...
|
} else if(dateTime->base.type == 0x0C) { // Kamstrup bug...
|
||||||
memcpy(timestamp, ptr, 0x0C);
|
memcpy(timestamp, ptr, 13);
|
||||||
ptr += 13;
|
ptr += 13;
|
||||||
} else {
|
} else {
|
||||||
return HDLC_TIMESTAMP_UNKNOWN;
|
return HDLC_TIMESTAMP_UNKNOWN;
|
||||||
|
|||||||
@@ -9,11 +9,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
EntsoeApi::EntsoeApi(RemoteDebug* Debug) {
|
EntsoeApi::EntsoeApi(RemoteDebug* Debug) {
|
||||||
|
this->buf = (char*) malloc(BufferSize);
|
||||||
|
|
||||||
debugger = Debug;
|
debugger = Debug;
|
||||||
|
|
||||||
client.setInsecure();
|
client.setInsecure();
|
||||||
https.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
https.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
||||||
https.setTimeout(20000);
|
https.setTimeout(50000);
|
||||||
|
|
||||||
// Entso-E uses CET/CEST
|
// Entso-E uses CET/CEST
|
||||||
TimeChangeRule CEST = {"CEST", Last, Sun, Mar, 2, 120};
|
TimeChangeRule CEST = {"CEST", Last, Sun, Mar, 2, 120};
|
||||||
@@ -120,8 +122,7 @@ bool EntsoeApi::loop() {
|
|||||||
breakTime(e1, d1);
|
breakTime(e1, d1);
|
||||||
breakTime(e2, d2);
|
breakTime(e2, d2);
|
||||||
|
|
||||||
char url[256];
|
snprintf(buf, BufferSize, "%s?securityToken=%s&documentType=A44&periodStart=%04d%02d%02d%02d%02d&periodEnd=%04d%02d%02d%02d%02d&in_Domain=%s&out_Domain=%s",
|
||||||
snprintf(url, sizeof(url), "%s?securityToken=%s&documentType=A44&periodStart=%04d%02d%02d%02d%02d&periodEnd=%04d%02d%02d%02d%02d&in_Domain=%s&out_Domain=%s",
|
|
||||||
"https://transparency.entsoe.eu/api", getToken(),
|
"https://transparency.entsoe.eu/api", getToken(),
|
||||||
d1.Year+1970, d1.Month, d1.Day, 23, 00,
|
d1.Year+1970, d1.Month, d1.Day, 23, 00,
|
||||||
d2.Year+1970, d2.Month, d2.Day, 23, 00,
|
d2.Year+1970, d2.Month, d2.Day, 23, 00,
|
||||||
@@ -135,9 +136,9 @@ bool EntsoeApi::loop() {
|
|||||||
|
|
||||||
|
|
||||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EntsoeApi) Fetching prices for today\n");
|
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EntsoeApi) Fetching prices for today\n");
|
||||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EntsoeApi) url: %s\n", url);
|
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EntsoeApi) url: %s\n", buf);
|
||||||
EntsoeA44Parser* a44 = new EntsoeA44Parser();
|
EntsoeA44Parser* a44 = new EntsoeA44Parser();
|
||||||
if(retrieve(url, a44) && a44->getPoint(0) != ENTSOE_NO_VALUE) {
|
if(retrieve(buf, a44) && a44->getPoint(0) != ENTSOE_NO_VALUE) {
|
||||||
today = a44;
|
today = a44;
|
||||||
return true;
|
return true;
|
||||||
} else if(a44 != NULL) {
|
} else if(a44 != NULL) {
|
||||||
@@ -160,8 +161,7 @@ bool EntsoeApi::loop() {
|
|||||||
breakTime(e1, d1);
|
breakTime(e1, d1);
|
||||||
breakTime(e2, d2);
|
breakTime(e2, d2);
|
||||||
|
|
||||||
char url[256];
|
snprintf(buf, BufferSize, "%s?securityToken=%s&documentType=A44&periodStart=%04d%02d%02d%02d%02d&periodEnd=%04d%02d%02d%02d%02d&in_Domain=%s&out_Domain=%s",
|
||||||
snprintf(url, sizeof(url), "%s?securityToken=%s&documentType=A44&periodStart=%04d%02d%02d%02d%02d&periodEnd=%04d%02d%02d%02d%02d&in_Domain=%s&out_Domain=%s",
|
|
||||||
"https://transparency.entsoe.eu/api", getToken(),
|
"https://transparency.entsoe.eu/api", getToken(),
|
||||||
d1.Year+1970, d1.Month, d1.Day, 23, 00,
|
d1.Year+1970, d1.Month, d1.Day, 23, 00,
|
||||||
d2.Year+1970, d2.Month, d2.Day, 23, 00,
|
d2.Year+1970, d2.Month, d2.Day, 23, 00,
|
||||||
@@ -174,9 +174,9 @@ bool EntsoeApi::loop() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EntsoeApi) Fetching prices for tomorrow\n");
|
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EntsoeApi) Fetching prices for tomorrow\n");
|
||||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EntsoeApi) url: %s\n", url);
|
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EntsoeApi) url: %s\n", buf);
|
||||||
EntsoeA44Parser* a44 = new EntsoeA44Parser();
|
EntsoeA44Parser* a44 = new EntsoeA44Parser();
|
||||||
if(retrieve(url, a44) && a44->getPoint(0) != ENTSOE_NO_VALUE) {
|
if(retrieve(buf, a44) && a44->getPoint(0) != ENTSOE_NO_VALUE) {
|
||||||
tomorrow = a44;
|
tomorrow = a44;
|
||||||
return true;
|
return true;
|
||||||
} else if(a44 != NULL) {
|
} else if(a44 != NULL) {
|
||||||
@@ -273,7 +273,6 @@ float EntsoeApi::getCurrencyMultiplier(const char* from, const char* to) {
|
|||||||
if(now > lastCurrencyFetch && (now - lastCurrencyFetch) < 900000) {
|
if(now > lastCurrencyFetch && (now - lastCurrencyFetch) < 900000) {
|
||||||
lastCurrencyFetch = now;
|
lastCurrencyFetch = now;
|
||||||
|
|
||||||
char url[256];
|
|
||||||
DnbCurrParser p;
|
DnbCurrParser p;
|
||||||
|
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
@@ -282,17 +281,17 @@ float EntsoeApi::getCurrencyMultiplier(const char* from, const char* to) {
|
|||||||
ESP.wdtFeed();
|
ESP.wdtFeed();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
snprintf(url, sizeof(url), "https://data.norges-bank.no/api/data/EXR/M.%s.NOK.SP?lastNObservations=1", from);
|
snprintf(buf, BufferSize, "https://data.norges-bank.no/api/data/EXR/M.%s.NOK.SP?lastNObservations=1", from);
|
||||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EntsoeApi) Retrieving %s to NOK conversion\n", from);
|
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EntsoeApi) Retrieving %s to NOK conversion\n", from);
|
||||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EntsoeApi) url: %s\n", url);
|
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EntsoeApi) url: %s\n", buf);
|
||||||
if(retrieve(url, &p)) {
|
if(retrieve(buf, &p)) {
|
||||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EntsoeApi) got exchange rate %.4f\n", p.getValue());
|
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EntsoeApi) got exchange rate %.4f\n", p.getValue());
|
||||||
currencyMultiplier = p.getValue();
|
currencyMultiplier = p.getValue();
|
||||||
if(strncmp(to, "NOK", 3) != 0) {
|
if(strncmp(to, "NOK", 3) != 0) {
|
||||||
snprintf(url, sizeof(url), "https://data.norges-bank.no/api/data/EXR/M.%s.NOK.SP?lastNObservations=1", to);
|
snprintf(buf, BufferSize, "https://data.norges-bank.no/api/data/EXR/M.%s.NOK.SP?lastNObservations=1", to);
|
||||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EntsoeApi) Retrieving %s to NOK conversion\n", to);
|
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EntsoeApi) Retrieving %s to NOK conversion\n", to);
|
||||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EntsoeApi) url: %s\n", url);
|
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EntsoeApi) url: %s\n", buf);
|
||||||
if(retrieve(url, &p)) {
|
if(retrieve(buf, &p)) {
|
||||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EntsoeApi) got exchange rate %.4f\n", p.getValue());
|
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EntsoeApi) got exchange rate %.4f\n", p.getValue());
|
||||||
currencyMultiplier /= p.getValue();
|
currencyMultiplier /= p.getValue();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ private:
|
|||||||
|
|
||||||
Timezone* tz = NULL;
|
Timezone* tz = NULL;
|
||||||
|
|
||||||
|
static const uint16_t BufferSize = 256;
|
||||||
|
char* buf;
|
||||||
|
|
||||||
float currencyMultiplier = ENTSOE_DEFAULT_MULTIPLIER;
|
float currencyMultiplier = ENTSOE_DEFAULT_MULTIPLIER;
|
||||||
|
|
||||||
bool retrieve(const char* url, Stream* doc);
|
bool retrieve(const char* url, Stream* doc);
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ bool DomoticzMqttHandler::publish(AmsData* data, AmsData* previousState) {
|
|||||||
if(energy > 0.0) {
|
if(energy > 0.0) {
|
||||||
char val[16];
|
char val[16];
|
||||||
snprintf(val, 16, "%.1f;%.1f", (data->getActiveImportPower()/1.0), energy*1000.0);
|
snprintf(val, 16, "%.1f;%.1f", (data->getActiveImportPower()/1.0), energy*1000.0);
|
||||||
char json[192];
|
snprintf_P(json, BufferSize, DOMOTICZ_JSON,
|
||||||
snprintf_P(json, sizeof(json), DOMOTICZ_JSON,
|
|
||||||
config.elidx,
|
config.elidx,
|
||||||
val
|
val
|
||||||
);
|
);
|
||||||
@@ -25,8 +24,7 @@ bool DomoticzMqttHandler::publish(AmsData* data, AmsData* previousState) {
|
|||||||
if (config.vl1idx > 0){
|
if (config.vl1idx > 0){
|
||||||
char val[16];
|
char val[16];
|
||||||
snprintf(val, 16, "%.2f", data->getL1Voltage());
|
snprintf(val, 16, "%.2f", data->getL1Voltage());
|
||||||
char json[192];
|
snprintf_P(json, BufferSize, DOMOTICZ_JSON,
|
||||||
snprintf_P(json, sizeof(json), DOMOTICZ_JSON,
|
|
||||||
config.vl1idx,
|
config.vl1idx,
|
||||||
val
|
val
|
||||||
);
|
);
|
||||||
@@ -36,8 +34,7 @@ bool DomoticzMqttHandler::publish(AmsData* data, AmsData* previousState) {
|
|||||||
if (config.vl2idx > 0){
|
if (config.vl2idx > 0){
|
||||||
char val[16];
|
char val[16];
|
||||||
snprintf(val, 16, "%.2f", data->getL2Voltage());
|
snprintf(val, 16, "%.2f", data->getL2Voltage());
|
||||||
char json[192];
|
snprintf_P(json, BufferSize, DOMOTICZ_JSON,
|
||||||
snprintf_P(json, sizeof(json), DOMOTICZ_JSON,
|
|
||||||
config.vl2idx,
|
config.vl2idx,
|
||||||
val
|
val
|
||||||
);
|
);
|
||||||
@@ -47,8 +44,7 @@ bool DomoticzMqttHandler::publish(AmsData* data, AmsData* previousState) {
|
|||||||
if (config.vl3idx > 0){
|
if (config.vl3idx > 0){
|
||||||
char val[16];
|
char val[16];
|
||||||
snprintf(val, 16, "%.2f", data->getL3Voltage());
|
snprintf(val, 16, "%.2f", data->getL3Voltage());
|
||||||
char json[192];
|
snprintf_P(json, BufferSize, DOMOTICZ_JSON,
|
||||||
snprintf_P(json, sizeof(json), DOMOTICZ_JSON,
|
|
||||||
config.vl3idx,
|
config.vl3idx,
|
||||||
val
|
val
|
||||||
);
|
);
|
||||||
@@ -58,8 +54,7 @@ bool DomoticzMqttHandler::publish(AmsData* data, AmsData* previousState) {
|
|||||||
if (config.cl1idx > 0){
|
if (config.cl1idx > 0){
|
||||||
char val[16];
|
char val[16];
|
||||||
snprintf(val, 16, "%.1f;%.1f;%.1f", data->getL1Current(), data->getL2Current(), data->getL3Current());
|
snprintf(val, 16, "%.1f;%.1f;%.1f", data->getL1Current(), data->getL2Current(), data->getL3Current());
|
||||||
char json[192];
|
snprintf_P(json, BufferSize, DOMOTICZ_JSON,
|
||||||
snprintf_P(json, sizeof(json), DOMOTICZ_JSON,
|
|
||||||
config.cl1idx,
|
config.cl1idx,
|
||||||
val
|
val
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,14 +8,19 @@ class DomoticzMqttHandler : public AmsMqttHandler {
|
|||||||
public:
|
public:
|
||||||
DomoticzMqttHandler(MQTTClient* mqtt, DomoticzConfig config) : AmsMqttHandler(mqtt) {
|
DomoticzMqttHandler(MQTTClient* mqtt, DomoticzConfig config) : AmsMqttHandler(mqtt) {
|
||||||
this->config = config;
|
this->config = config;
|
||||||
|
this->json = (char*) malloc(BufferSize);
|
||||||
};
|
};
|
||||||
bool publish(AmsData* data, AmsData* previousState);
|
bool publish(AmsData* data, AmsData* previousState);
|
||||||
bool publishTemperatures(AmsConfiguration*, HwTools*);
|
bool publishTemperatures(AmsConfiguration*, HwTools*);
|
||||||
bool publishPrices(EntsoeApi*);
|
bool publishPrices(EntsoeApi*);
|
||||||
bool publishSystem(HwTools*);
|
bool publishSystem(HwTools*);
|
||||||
|
|
||||||
|
static const uint16_t BufferSize = 192;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DomoticzConfig config;
|
DomoticzConfig config;
|
||||||
int energy = 0.0;
|
int energy = 0.0;
|
||||||
|
char* json;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ bool JsonMqttHandler::publish(AmsData* data, AmsData* previousState) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(data->getListType() == 1) {
|
if(data->getListType() == 1) {
|
||||||
char json[192];
|
snprintf_P(json, BufferSize, JSON1_JSON,
|
||||||
snprintf_P(json, sizeof(json), JSON1_JSON,
|
|
||||||
WiFi.macAddress().c_str(),
|
WiFi.macAddress().c_str(),
|
||||||
clientId.c_str(),
|
clientId.c_str(),
|
||||||
(uint32_t) (millis64()/1000),
|
(uint32_t) (millis64()/1000),
|
||||||
@@ -26,8 +25,7 @@ bool JsonMqttHandler::publish(AmsData* data, AmsData* previousState) {
|
|||||||
);
|
);
|
||||||
return mqtt->publish(topic, json);
|
return mqtt->publish(topic, json);
|
||||||
} else if(data->getListType() == 2) {
|
} else if(data->getListType() == 2) {
|
||||||
char json[384];
|
snprintf_P(json, BufferSize, JSON2_JSON,
|
||||||
snprintf_P(json, sizeof(json), JSON2_JSON,
|
|
||||||
WiFi.macAddress().c_str(),
|
WiFi.macAddress().c_str(),
|
||||||
clientId.c_str(),
|
clientId.c_str(),
|
||||||
(uint32_t) (millis64()/1000),
|
(uint32_t) (millis64()/1000),
|
||||||
@@ -52,8 +50,7 @@ bool JsonMqttHandler::publish(AmsData* data, AmsData* previousState) {
|
|||||||
return mqtt->publish(topic, json);
|
return mqtt->publish(topic, json);
|
||||||
} else if(data->getListType() == 3) {
|
} else if(data->getListType() == 3) {
|
||||||
if(data->getPowerFactor() == 0) {
|
if(data->getPowerFactor() == 0) {
|
||||||
char json[512];
|
snprintf_P(json, BufferSize, JSON3_JSON,
|
||||||
snprintf_P(json, sizeof(json), JSON3_JSON,
|
|
||||||
WiFi.macAddress().c_str(),
|
WiFi.macAddress().c_str(),
|
||||||
clientId.c_str(),
|
clientId.c_str(),
|
||||||
(uint32_t) (millis64()/1000),
|
(uint32_t) (millis64()/1000),
|
||||||
@@ -82,8 +79,7 @@ bool JsonMqttHandler::publish(AmsData* data, AmsData* previousState) {
|
|||||||
);
|
);
|
||||||
return mqtt->publish(topic, json);
|
return mqtt->publish(topic, json);
|
||||||
} else {
|
} else {
|
||||||
char json[768];
|
snprintf_P(json, BufferSize, JSON3PF_JSON,
|
||||||
snprintf_P(json, sizeof(json), JSON3PF_JSON,
|
|
||||||
WiFi.macAddress().c_str(),
|
WiFi.macAddress().c_str(),
|
||||||
clientId.c_str(),
|
clientId.c_str(),
|
||||||
(uint32_t) (millis64()/1000),
|
(uint32_t) (millis64()/1000),
|
||||||
@@ -229,8 +225,7 @@ bool JsonMqttHandler::publishPrices(EntsoeApi* eapi) {
|
|||||||
sprintf(ts6hr, "%04d-%02d-%02dT%02d:00:00Z", tm.Year+1970, tm.Month, tm.Day, tm.Hour);
|
sprintf(ts6hr, "%04d-%02d-%02dT%02d:00:00Z", tm.Year+1970, tm.Month, tm.Day, tm.Hour);
|
||||||
}
|
}
|
||||||
|
|
||||||
char json[384];
|
snprintf_P(json, BufferSize, JSONPRICES_JSON,
|
||||||
snprintf_P(json, sizeof(json), JSONPRICES_JSON,
|
|
||||||
WiFi.macAddress().c_str(),
|
WiFi.macAddress().c_str(),
|
||||||
values[0],
|
values[0],
|
||||||
values[1],
|
values[1],
|
||||||
@@ -257,8 +252,7 @@ bool JsonMqttHandler::publishSystem(HwTools* hw) {
|
|||||||
if(init || topic.isEmpty() || !mqtt->connected())
|
if(init || topic.isEmpty() || !mqtt->connected())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char json[192];
|
snprintf_P(json, BufferSize, JSONSYS_JSON,
|
||||||
snprintf_P(json, sizeof(json), JSONSYS_JSON,
|
|
||||||
WiFi.macAddress().c_str(),
|
WiFi.macAddress().c_str(),
|
||||||
clientId.c_str(),
|
clientId.c_str(),
|
||||||
(uint32_t) (millis64()/1000),
|
(uint32_t) (millis64()/1000),
|
||||||
|
|||||||
@@ -9,16 +9,20 @@ public:
|
|||||||
this->clientId = clientId;
|
this->clientId = clientId;
|
||||||
this->topic = String(topic);
|
this->topic = String(topic);
|
||||||
this->hw = hw;
|
this->hw = hw;
|
||||||
|
this->json = (char*) malloc(BufferSize);
|
||||||
};
|
};
|
||||||
bool publish(AmsData* data, AmsData* previousState);
|
bool publish(AmsData* data, AmsData* previousState);
|
||||||
bool publishTemperatures(AmsConfiguration*, HwTools*);
|
bool publishTemperatures(AmsConfiguration*, HwTools*);
|
||||||
bool publishPrices(EntsoeApi*);
|
bool publishPrices(EntsoeApi*);
|
||||||
bool publishSystem(HwTools*);
|
bool publishSystem(HwTools*);
|
||||||
|
|
||||||
|
static const uint16_t BufferSize = 768;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String clientId;
|
String clientId;
|
||||||
String topic;
|
String topic;
|
||||||
HwTools* hw;
|
HwTools* hw;
|
||||||
bool init = false;
|
bool init = false;
|
||||||
|
char* json;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ public:
|
|||||||
bool publishPrices(EntsoeApi*);
|
bool publishPrices(EntsoeApi*);
|
||||||
bool publishSystem(HwTools*);
|
bool publishSystem(HwTools*);
|
||||||
|
|
||||||
|
static const uint16_t BufferSize = 128;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String topic;
|
String topic;
|
||||||
bool full;
|
bool full;
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
AmsWebServer::AmsWebServer(RemoteDebug* Debug, HwTools* hw) {
|
AmsWebServer::AmsWebServer(RemoteDebug* Debug, HwTools* hw) {
|
||||||
this->debugger = Debug;
|
this->debugger = Debug;
|
||||||
this->hw = hw;
|
this->hw = hw;
|
||||||
|
this->json = (char*) malloc(JsonSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AmsWebServer::setup(AmsConfiguration* config, GpioConfig* gpioConfig, MeterConfig* meterConfig, AmsData* meterState, AmsDataStorage* ds) {
|
void AmsWebServer::setup(AmsConfiguration* config, GpioConfig* gpioConfig, MeterConfig* meterConfig, AmsData* meterState, AmsDataStorage* ds) {
|
||||||
@@ -754,8 +755,7 @@ void AmsWebServer::dataJson() {
|
|||||||
if(eapi != NULL && strlen(eapi->getToken()) > 0)
|
if(eapi != NULL && strlen(eapi->getToken()) > 0)
|
||||||
price = eapi->getValueForHour(0);
|
price = eapi->getValueForHour(0);
|
||||||
|
|
||||||
char json[512];
|
snprintf_P(json, JsonSize, DATA_JSON,
|
||||||
snprintf_P(json, sizeof(json), DATA_JSON,
|
|
||||||
maxPwr == 0 ? meterState->isThreePhase() ? 20000 : 10000 : maxPwr,
|
maxPwr == 0 ? meterState->isThreePhase() ? 20000 : 10000 : maxPwr,
|
||||||
meterConfig->productionCapacity,
|
meterConfig->productionCapacity,
|
||||||
meterConfig->mainFuse == 0 ? 32 : meterConfig->mainFuse,
|
meterConfig->mainFuse == 0 ? 32 : meterConfig->mainFuse,
|
||||||
@@ -806,8 +806,7 @@ void AmsWebServer::dayplotJson() {
|
|||||||
if(ds == NULL) {
|
if(ds == NULL) {
|
||||||
notFound();
|
notFound();
|
||||||
} else {
|
} else {
|
||||||
char json[384];
|
snprintf_P(json, JsonSize, DAYPLOT_JSON,
|
||||||
snprintf_P(json, sizeof(json), DAYPLOT_JSON,
|
|
||||||
ds->getHour(0) / 1000.0,
|
ds->getHour(0) / 1000.0,
|
||||||
ds->getHour(1) / 1000.0,
|
ds->getHour(1) / 1000.0,
|
||||||
ds->getHour(2) / 1000.0,
|
ds->getHour(2) / 1000.0,
|
||||||
@@ -849,8 +848,7 @@ void AmsWebServer::monthplotJson() {
|
|||||||
if(ds == NULL) {
|
if(ds == NULL) {
|
||||||
notFound();
|
notFound();
|
||||||
} else {
|
} else {
|
||||||
char json[512];
|
snprintf_P(json, JsonSize, MONTHPLOT_JSON,
|
||||||
snprintf_P(json, sizeof(json), MONTHPLOT_JSON,
|
|
||||||
ds->getDay(1) / 1000.0,
|
ds->getDay(1) / 1000.0,
|
||||||
ds->getDay(2) / 1000.0,
|
ds->getDay(2) / 1000.0,
|
||||||
ds->getDay(3) / 1000.0,
|
ds->getDay(3) / 1000.0,
|
||||||
@@ -901,8 +899,7 @@ void AmsWebServer::energyPriceJson() {
|
|||||||
prices[i] = eapi == NULL ? ENTSOE_NO_VALUE : eapi->getValueForHour(i);
|
prices[i] = eapi == NULL ? ENTSOE_NO_VALUE : eapi->getValueForHour(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
char json[768];
|
snprintf_P(json, JsonSize, ENERGYPRICE_JSON,
|
||||||
snprintf_P(json, sizeof(json), ENERGYPRICE_JSON,
|
|
||||||
eapi == NULL ? "" : eapi->getCurrency(),
|
eapi == NULL ? "" : eapi->getCurrency(),
|
||||||
prices[0] == ENTSOE_NO_VALUE ? "null" : String(prices[0], 2).c_str(),
|
prices[0] == ENTSOE_NO_VALUE ? "null" : String(prices[0], 2).c_str(),
|
||||||
prices[1] == ENTSOE_NO_VALUE ? "null" : String(prices[1], 2).c_str(),
|
prices[1] == ENTSOE_NO_VALUE ? "null" : String(prices[1], 2).c_str(),
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ private:
|
|||||||
File file;
|
File file;
|
||||||
bool performRestart = false;
|
bool performRestart = false;
|
||||||
|
|
||||||
|
static const uint16_t JsonSize = 768;
|
||||||
|
char* json;
|
||||||
|
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
ESP8266WebServer server;
|
ESP8266WebServer server;
|
||||||
#elif defined(ESP32) // ARDUINO_ARCH_ESP32
|
#elif defined(ESP32) // ARDUINO_ARCH_ESP32
|
||||||
|
|||||||
@@ -726,19 +726,19 @@ var fetch = function() {
|
|||||||
var a = 0;
|
var a = 0;
|
||||||
var r = 1;
|
var r = 1;
|
||||||
var arr = [['Phase', 'Amperage', { role: 'style' }, { role: 'annotation' }]];
|
var arr = [['Phase', 'Amperage', { role: 'style' }, { role: 'annotation' }]];
|
||||||
if(json.i1) {
|
if(json.i1 || json.u1) {
|
||||||
var i1 = parseFloat(json.i1);
|
var i1 = parseFloat(json.i1);
|
||||||
a = Math.max(a, i1);
|
a = Math.max(a, i1);
|
||||||
var pct = (parseFloat(json.i1)/parseInt(json.mf))*100;
|
var pct = (parseFloat(json.i1)/parseInt(json.mf))*100;
|
||||||
arr[r++] = ['L1', pct, "color: " + ampcol(pct) + ";opacity: 0.9;", i1 + "A"];
|
arr[r++] = ['L1', pct, "color: " + ampcol(pct) + ";opacity: 0.9;", i1 + "A"];
|
||||||
}
|
}
|
||||||
if(json.i2) {
|
if(json.i2 || json.u2) {
|
||||||
var i2 = parseFloat(json.i2);
|
var i2 = parseFloat(json.i2);
|
||||||
a = Math.max(a, i2);
|
a = Math.max(a, i2);
|
||||||
var pct = (parseFloat(json.i2)/parseInt(json.mf))*100;
|
var pct = (parseFloat(json.i2)/parseInt(json.mf))*100;
|
||||||
arr[r++] = ['L2', pct, "color: " + ampcol(pct) + ";opacity: 0.9;", i2 + "A"];
|
arr[r++] = ['L2', pct, "color: " + ampcol(pct) + ";opacity: 0.9;", i2 + "A"];
|
||||||
}
|
}
|
||||||
if(json.i3) {
|
if(json.i3 || json.u3) {
|
||||||
var i3 = parseFloat(json.i3);
|
var i3 = parseFloat(json.i3);
|
||||||
a = Math.max(a, i3);
|
a = Math.max(a, i3);
|
||||||
var pct = (parseFloat(json.i3)/parseInt(json.mf))*100;
|
var pct = (parseFloat(json.i3)/parseInt(json.mf))*100;
|
||||||
|
|||||||
@@ -44,8 +44,8 @@
|
|||||||
<div class="text-center overlay-plot">
|
<div class="text-center overlay-plot">
|
||||||
<div id="xp" class="plot1"></div>
|
<div id="xp" class="plot1"></div>
|
||||||
<span class="plot-overlay">
|
<span class="plot-overlay">
|
||||||
<span class="xpo">{PO}</span>
|
<span class="epo">{PO}</span>
|
||||||
<span class="xpoa">W</span>
|
<span class="epoa">W</span>
|
||||||
<br/>
|
<br/>
|
||||||
<span class="pol">Export</span>
|
<span class="pol">Export</span>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
BIN
webui2.png
|
Before Width: | Height: | Size: 168 KiB After Width: | Height: | Size: 136 KiB |