mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-02-06 16:46:13 +00:00
Merge remote-tracking branch 'upstream/dev-v1.1.0' into dev-v1.1.0
This commit is contained in:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user