1
0
Fork 0
mirror of https://github.com/lumapu/ahoy.git synced 2025-05-18 03:16:12 +02:00

* started to implement POST api

* improved web serial console
* added multi inverter total values (published through MQTT)
* fixed: after boot there were transferred wrong data because of incorrect assignment (mqtt, visualization)
  -> not tested with sun
This commit is contained in:
lumapu 2022-09-10 02:19:25 +02:00
parent 9e1b6be70e
commit 6bd7e01f1a
13 changed files with 404 additions and 379 deletions
tools/esp8266

View file

@ -381,23 +381,47 @@ void app::processPayload(bool retransmit) {
// MQTT send out
if(mMqttActive) {
char topic[30], val[10];
for (uint8_t id = 0; id < mSys->getNumInverters(); id++)
{
float total[4];
memset(total, 0, sizeof(float) * 4);
for (uint8_t id = 0; id < mSys->getNumInverters(); id++) {
Inverter<> *iv = mSys->getInverterByPos(id);
if (NULL != iv)
{
if (iv->isAvailable(mTimestamp))
{
for (uint8_t i = 0; i < iv->listLen; i++)
{
if (NULL != iv) {
if (iv->isAvailable(mTimestamp)) {
for (uint8_t i = 0; i < iv->listLen; i++) {
snprintf(topic, 30, "%s/ch%d/%s", iv->name, iv->assign[i].ch, fields[iv->assign[i].fieldId]);
snprintf(val, 10, "%.3f", iv->getValue(i));
mMqtt.sendMsg(topic, val);
if(iv->isLiveDataAssignment()) {
if(CH0 == iv->assign[i].ch) {
switch(iv->assign[i].fieldId) {
case FLD_PAC: total[0] += iv->getValue(i); break;
case FLD_YT: total[1] += iv->getValue(i); break;
case FLD_YD: total[2] += iv->getValue(i); break;
case FLD_PDC: total[3] += iv->getValue(i); break;
}
}
}
yield();
}
}
}
}
// total values (sum of all inverters)
if(mSys->getNumInverters() > 1) {
uint8_t fieldId = 0;
for (uint8_t i = 0; i < 4; i++) {
switch(i) {
case 0: fieldId = FLD_PAC; break;
case 1: fieldId = FLD_YT; break;
case 2: fieldId = FLD_YD; break;
case 3: fieldId = FLD_PDC; break;
}
snprintf(topic, 30, "total/%s", fields[fieldId]);
snprintf(val, 10, "%.3f", total[i]);
mMqtt.sendMsg(topic, val);
}
}
}
#ifdef __MQTT_AFTER_RX__