Browse Source

fix #397 MQTT reports zero values

fix #397 remove "not producing" if not yet available for MQTT and HTML
pull/421/head
lumapu 2 years ago
parent
commit
11da974772
  1. 54
      tools/esp8266/app.cpp
  2. 12
      tools/esp8266/html/index.html

54
tools/esp8266/app.cpp

@ -612,10 +612,10 @@ void app::sendMqtt(void) {
} }
snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/available_text", iv->name); snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/available_text", iv->name);
snprintf(val, 32, "%s%s%s%s", snprintf(val, 32, "%s%s%s%s",
(MQTT_STATUS_NOT_AVAIL_NOT_PROD) ? "not " : "", (MQTT_STATUS_NOT_AVAIL_NOT_PROD) ? "not yet " : "",
"available and ", "available and ",
(MQTT_STATUS_NOT_AVAIL_NOT_PROD || MQTT_STATUS_AVAIL_NOT_PROD) ? "not " : "", (MQTT_STATUS_AVAIL_NOT_PROD) ? "not " : "",
"producing" (MQTT_STATUS_NOT_AVAIL_NOT_PROD) ? "" : "producing"
); );
mMqtt.sendMsg(topic, val); mMqtt.sendMsg(topic, val);
@ -629,32 +629,34 @@ void app::sendMqtt(void) {
} }
// data // data
for (uint8_t i = 0; i < rec->length; i++) { if(iv->isAvailable(mUtcTimestamp, rec)) {
snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/ch%d/%s", iv->name, rec->assign[i].ch, fields[rec->assign[i].fieldId]); for (uint8_t i = 0; i < rec->length; i++) {
snprintf(val, 10, "%.3f", iv->getValue(i, rec)); snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/ch%d/%s", iv->name, rec->assign[i].ch, fields[rec->assign[i].fieldId]);
mMqtt.sendMsg(topic, val); snprintf(val, 10, "%.3f", iv->getValue(i, rec));
mMqtt.sendMsg(topic, val);
// calculate total values for RealTimeRunData_Debug
if (mMqttSendList.front() == RealTimeRunData_Debug) { // calculate total values for RealTimeRunData_Debug
if (CH0 == rec->assign[i].ch) { if (mMqttSendList.front() == RealTimeRunData_Debug) {
switch (rec->assign[i].fieldId) { if (CH0 == rec->assign[i].ch) {
case FLD_PAC: switch (rec->assign[i].fieldId) {
total[0] += iv->getValue(i, rec); case FLD_PAC:
break; total[0] += iv->getValue(i, rec);
case FLD_YT: break;
total[1] += iv->getValue(i, rec); case FLD_YT:
break; total[1] += iv->getValue(i, rec);
case FLD_YD: break;
total[2] += iv->getValue(i, rec); case FLD_YD:
break; total[2] += iv->getValue(i, rec);
case FLD_PDC: break;
total[3] += iv->getValue(i, rec); case FLD_PDC:
break; total[3] += iv->getValue(i, rec);
break;
}
} }
sendTotal = true;
} }
sendTotal = true; yield();
} }
yield();
} }
} }

12
tools/esp8266/html/index.html

@ -153,11 +153,13 @@
for(var i of obj) { for(var i of obj) {
html += "Inverter #" + i["id"] + ": " + i["name"] + " (v" + i["version"] + ") is "; html += "Inverter #" + i["id"] + ": " + i["name"] + " (v" + i["version"] + ") is ";
if(false == i["is_avail"]) if(false == i["is_avail"])
html += "not "; html += "not yet available";
html += "available and is "; else {
if(false == i["is_producing"]) html += "available and is ";
html += "not "; if(false == i["is_producing"])
html += "producing\n"; html += "not ";
html += "producing\n";
}
if(false == i["is_avail"]) { if(false == i["is_avail"]) {
if(i["ts_last_success"] > 0) { if(i["ts_last_success"] > 0) {

Loading…
Cancel
Save