mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-01 19:26:20 +02:00
fix #397 MQTT reports zero values
fix #397 remove "not producing" if not yet available for MQTT and HTML
This commit is contained in:
parent
64fb587cf3
commit
11da974772
2 changed files with 34 additions and 30 deletions
|
@ -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,6 +629,7 @@ void app::sendMqtt(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// data
|
// data
|
||||||
|
if(iv->isAvailable(mUtcTimestamp, rec)) {
|
||||||
for (uint8_t i = 0; i < rec->length; i++) {
|
for (uint8_t i = 0; i < rec->length; i++) {
|
||||||
snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/ch%d/%s", iv->name, rec->assign[i].ch, fields[rec->assign[i].fieldId]);
|
snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/ch%d/%s", iv->name, rec->assign[i].ch, fields[rec->assign[i].fieldId]);
|
||||||
snprintf(val, 10, "%.3f", iv->getValue(i, rec));
|
snprintf(val, 10, "%.3f", iv->getValue(i, rec));
|
||||||
|
@ -657,6 +658,7 @@ void app::sendMqtt(void) {
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mMqttSendList.pop(); // remove from list once all inverters were processed
|
mMqttSendList.pop(); // remove from list once all inverters were processed
|
||||||
|
|
||||||
|
|
|
@ -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";
|
||||||
|
else {
|
||||||
html += "available and is ";
|
html += "available and is ";
|
||||||
if(false == i["is_producing"])
|
if(false == i["is_producing"])
|
||||||
html += "not ";
|
html += "not ";
|
||||||
html += "producing\n";
|
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…
Add table
Reference in a new issue