mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-17 00:52:12 +00:00
Merge remote-tracking branch 'upstream/dev-v1.1.0' into dev-v1.1.0
This commit is contained in:
commit
9b6a6af6ec
@ -4,10 +4,10 @@ extra_configs = platformio-user.ini
|
||||
|
||||
[common]
|
||||
framework = arduino
|
||||
lib_deps = HanReader@1.0.0, ArduinoJson@6.14.1, MQTT@^2.4.7, DallasTemperature@3.8.1, EspSoftwareSerial@6.7.1, Base64@^1.0.0
|
||||
lib_deps = HanReader@1.0.0, ArduinoJson@6.14.1, MQTT@2.4.7, DallasTemperature@3.8.1, EspSoftwareSerial@6.7.1, Base64@1.0.0
|
||||
|
||||
[env:hw1esp12e]
|
||||
platform = espressif8266
|
||||
platform = espressif8266@2.3.3
|
||||
board = esp12e
|
||||
framework = ${common.framework}
|
||||
lib_deps = ${common.lib_deps}
|
||||
@ -18,7 +18,7 @@ extra_scripts =
|
||||
scripts/makeweb.py
|
||||
|
||||
[env:esp12e]
|
||||
platform = espressif8266
|
||||
platform = espressif8266@2.3.3
|
||||
board = esp12e
|
||||
framework = ${common.framework}
|
||||
lib_deps = ${common.lib_deps}
|
||||
@ -27,7 +27,7 @@ extra_scripts =
|
||||
scripts/makeweb.py
|
||||
|
||||
[env:d1mini]
|
||||
platform = espressif8266
|
||||
platform = espressif8266@2.3.3
|
||||
board = d1_mini
|
||||
framework = ${common.framework}
|
||||
lib_deps = ${common.lib_deps}
|
||||
@ -36,7 +36,7 @@ extra_scripts =
|
||||
scripts/makeweb.py
|
||||
|
||||
[env:esp32]
|
||||
platform = espressif32
|
||||
platform = espressif32@1.11.2
|
||||
board = esp32dev
|
||||
framework = ${common.framework}
|
||||
lib_deps = ${common.lib_deps}
|
||||
@ -45,7 +45,7 @@ extra_scripts =
|
||||
scripts/makeweb.py
|
||||
|
||||
[env:lolind32]
|
||||
platform = espressif32
|
||||
platform = espressif32@1.11.2
|
||||
board = lolin_d32
|
||||
framework = ${common.framework}
|
||||
lib_deps = ${common.lib_deps}
|
||||
@ -54,7 +54,7 @@ extra_scripts =
|
||||
scripts/makeweb.py
|
||||
|
||||
[env:featheresp32]
|
||||
platform = espressif32
|
||||
platform = espressif32@1.11.2
|
||||
board = featheresp32
|
||||
framework = ${common.framework}
|
||||
lib_deps = ${common.lib_deps}
|
||||
|
||||
@ -234,7 +234,7 @@ void loop() {
|
||||
else led_off();
|
||||
|
||||
}
|
||||
if(now - lastRead > 150) {
|
||||
if(now - lastRead > 100) {
|
||||
yield();
|
||||
readHanPort();
|
||||
lastRead = now;
|
||||
@ -332,6 +332,11 @@ void mqttMessageReceived(String &topic, String &payload)
|
||||
|
||||
void readHanPort() {
|
||||
if (hanReader.read()) {
|
||||
// Empty serial buffer. For some reason this seems to make a difference. Some garbage on the wire after package?
|
||||
while(hanSerial->available()) {
|
||||
hanSerial->read();
|
||||
}
|
||||
|
||||
lastSuccessfulRead = millis();
|
||||
|
||||
if(config.getMeterType() > 0) {
|
||||
@ -538,7 +543,11 @@ void rgb_led(int color, int mode) {
|
||||
// If no RGB LED present (HAS_RGB_LED=0 or not defined), all output goes to ESP onboard LED
|
||||
// color: 1=red, 2=green, 3=yellow
|
||||
// mode: 0=OFF, 1=ON, >=2 -> Short blink(s), number of blinks: (mode - 1)
|
||||
#ifndef HAS_RGB_LED
|
||||
<<<<<<< HEAD
|
||||
#ifndef HAS_RGB_LED
|
||||
=======
|
||||
#ifndef HAS_RGB_LED
|
||||
>>>>>>> upstream/dev-v1.1.0
|
||||
#define LEDPIN_RGB_RED LED_PIN
|
||||
#define LEDPIN_RGB_GREEN LED_PIN
|
||||
#endif
|
||||
|
||||
@ -104,7 +104,8 @@ void AmsWebServer::indexHtml() {
|
||||
|
||||
html.replace("${data.P}", String(data.getActiveImportPower()));
|
||||
html.replace("${data.PO}", String(data.getActiveExportPower()));
|
||||
html.replace("${display.production}", config->getProductionCapacity() > 0 ? "" : "none");
|
||||
html.replace("${display.export}", config->getProductionCapacity() > 0 ? "" : "none");
|
||||
html.replace("${text.import}", config->getProductionCapacity() > 0 ? "Import" : "Consumption");
|
||||
|
||||
html.replace("${data.U1}", u1 > 0 ? String(u1, 1) : "");
|
||||
html.replace("${data.I1}", u1 > 0 ? String(i1, 1) : "");
|
||||
@ -292,7 +293,7 @@ void AmsWebServer::dataJson() {
|
||||
StaticJsonDocument<768> json;
|
||||
|
||||
String jsonStr;
|
||||
if(data.getActiveImportPower() > 0) {
|
||||
if(data.getLastUpdateMillis() > 0) {
|
||||
int maxPwr = this->maxPwr;
|
||||
if(maxPwr == 0) {
|
||||
if(data.isThreePhase()) {
|
||||
@ -356,10 +357,10 @@ void AmsWebServer::dataJson() {
|
||||
json["meterType"] = config->getMeterType();
|
||||
json["currentMillis"] = now;
|
||||
double vcc = hw.getVcc();
|
||||
json["vcc"] = vcc > 0 ? vcc : 0;
|
||||
json["vcc"] = serialized(String(vcc, 3));
|
||||
|
||||
double temp = hw.getTemperature();
|
||||
json["temp"] = temp;
|
||||
json["temp"] = serialized(String(temp, 2));
|
||||
|
||||
json.createNestedObject("wifi");
|
||||
float rssi = WiFi.RSSI();
|
||||
@ -382,13 +383,12 @@ void AmsWebServer::dataJson() {
|
||||
}
|
||||
json["status"]["esp"] = espStatus;
|
||||
|
||||
unsigned long lastHan = json.isNull() ? 0 : json["up"].as<unsigned long>();
|
||||
String hanStatus;
|
||||
if(config->getMeterType() == 0) {
|
||||
hanStatus = "secondary";
|
||||
} else if(now - lastHan < 15000) {
|
||||
} else if(now - data.getLastUpdateMillis() < 15000) {
|
||||
hanStatus = "success";
|
||||
} else if(now - lastHan < 30000) {
|
||||
} else if(now - data.getLastUpdateMillis() < 30000) {
|
||||
hanStatus = "warning";
|
||||
} else {
|
||||
hanStatus = "danger";
|
||||
|
||||
@ -92,7 +92,7 @@
|
||||
<div id="P" class="SimpleMeter" style="display: inline;">
|
||||
${data.P} W
|
||||
</div>
|
||||
<div id="consumptionMeter" class="GaugeMeter rounded"
|
||||
<div id="importMeter" class="GaugeMeter rounded"
|
||||
style="display: none;"
|
||||
data-size="200px"
|
||||
data-text_size="0.11"
|
||||
@ -100,7 +100,7 @@
|
||||
data-style="Arch"
|
||||
data-theme="Green-Gold-Red"
|
||||
data-animationstep="0"
|
||||
data-label="Consumption"
|
||||
data-label="${text.import}"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
@ -139,11 +139,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="text-center" style="display: ${display.production};">
|
||||
<div class="text-center" style="display: ${display.export};">
|
||||
<div id="P" class="SimpleMeter" style="display: inline;">
|
||||
${data.PO} W
|
||||
</div>
|
||||
<div id="productionMeter" class="GaugeMeter rounded"
|
||||
<div id="exportMeter" class="GaugeMeter rounded"
|
||||
style="display: none;"
|
||||
data-size="200px"
|
||||
data-text_size="0.11"
|
||||
@ -151,7 +151,7 @@
|
||||
data-style="Arch"
|
||||
data-theme="DarkGreen-LightGreen"
|
||||
data-animationstep="0"
|
||||
data-label="Production"
|
||||
data-label="Export"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
@ -194,15 +194,15 @@
|
||||
</div>
|
||||
</main>
|
||||
<script>
|
||||
var cm = $("#consumptionMeter")
|
||||
cm.gaugeMeter({
|
||||
var im = $("#importMeter")
|
||||
im.gaugeMeter({
|
||||
percent: 0,
|
||||
text: "-",
|
||||
append: "W"
|
||||
});
|
||||
|
||||
var pm = $("#productionMeter")
|
||||
pm.gaugeMeter({
|
||||
var em = $("#exportMeter")
|
||||
em.gaugeMeter({
|
||||
percent: 0,
|
||||
text: "-",
|
||||
append: "W"
|
||||
@ -225,8 +225,8 @@ var fetch = function() {
|
||||
dataType: 'json',
|
||||
}).done(function(json) {
|
||||
$(".SimpleMeter").hide();
|
||||
cm.show();
|
||||
pm.show();
|
||||
im.show();
|
||||
em.show();
|
||||
|
||||
for(var id in json) {
|
||||
var str = json[id];
|
||||
@ -282,7 +282,7 @@ var fetch = function() {
|
||||
p_append = "kW";
|
||||
}
|
||||
}
|
||||
cm.gaugeMeter({
|
||||
im.gaugeMeter({
|
||||
percent: p_pct,
|
||||
text: p,
|
||||
append: p_append
|
||||
@ -298,7 +298,7 @@ var fetch = function() {
|
||||
po_append = "kW";
|
||||
}
|
||||
}
|
||||
pm.gaugeMeter({
|
||||
em.gaugeMeter({
|
||||
percent: po_pct,
|
||||
text: po,
|
||||
append: po_append
|
||||
@ -315,13 +315,13 @@ var fetch = function() {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cm.gaugeMeter({
|
||||
im.gaugeMeter({
|
||||
percent: 0,
|
||||
text: "-",
|
||||
append: "W"
|
||||
});
|
||||
|
||||
pm.gaugeMeter({
|
||||
em.gaugeMeter({
|
||||
percent: 0,
|
||||
text: "-",
|
||||
append: "W"
|
||||
@ -331,13 +331,13 @@ var fetch = function() {
|
||||
}).fail(function() {
|
||||
setTimeout(fetch, interval*4);
|
||||
|
||||
cm.gaugeMeter({
|
||||
im.gaugeMeter({
|
||||
percent: 0,
|
||||
text: "-",
|
||||
append: "W"
|
||||
});
|
||||
|
||||
pm.gaugeMeter({
|
||||
em.gaugeMeter({
|
||||
percent: 0,
|
||||
text: "-",
|
||||
append: "W"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user