mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-18 19:36:11 +02:00
#268 Statusausgabe über MQTT realisiert
This commit is contained in:
parent
e2d193e591
commit
96d397e8a9
2 changed files with 43 additions and 3 deletions
|
@ -390,7 +390,7 @@ void app::processPayload(bool retransmit) {
|
|||
// MQTT send out
|
||||
if(mMqttActive) {
|
||||
record_t<> *recRealtime = iv->getRecordStruct(RealTimeRunData_Debug);
|
||||
char topic[32 + MAX_NAME_LENGTH], val[10];
|
||||
char topic[32 + MAX_NAME_LENGTH], val[32];
|
||||
float total[4];
|
||||
memset(total, 0, sizeof(float) * 4);
|
||||
for (uint8_t id = 0; id < mSys->getNumInverters(); id++) {
|
||||
|
@ -411,6 +411,27 @@ void app::processPayload(bool retransmit) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(iv->isProducing(mTimestamp, rec)){
|
||||
snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/available_text", iv->name);
|
||||
snprintf(val, 32, DEF_MQTT_IV_MESSAGE_INVERTER_AVAIL_AND_PRODUCED);
|
||||
mMqtt.sendMsg(topic, val);
|
||||
snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/available", iv->name);
|
||||
snprintf(val, 32, "2");
|
||||
mMqtt.sendMsg(topic, val);
|
||||
} else {
|
||||
snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/available_text", iv->name);
|
||||
snprintf(val, 32, DEF_MQTT_IV_MESSAGE_INVERTER_AVAIL_AND_NOT_PRODUCED);
|
||||
mMqtt.sendMsg(topic, val);
|
||||
snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/available", iv->name);
|
||||
snprintf(val, 32, "1");
|
||||
mMqtt.sendMsg(topic, val);
|
||||
}
|
||||
|
||||
snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/last_success", iv->name);
|
||||
snprintf(val, 48, "%i", iv->getLastTs(rec) * 1000);
|
||||
mMqtt.sendMsg(topic, val);
|
||||
|
||||
yield();
|
||||
}
|
||||
}
|
||||
|
@ -446,6 +467,20 @@ void app::processPayload(bool retransmit) {
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if(mMqttActive) {
|
||||
record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug);
|
||||
char topic[32 + MAX_NAME_LENGTH], val[32];
|
||||
if (!iv->isAvailable(mTimestamp, rec) && !iv->isProducing(mTimestamp, rec)){
|
||||
snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/available_text", iv->name);
|
||||
snprintf(val, 32, DEF_MQTT_IV_MESSAGE_NOT_AVAIL_AND_NOT_PRODUCED);
|
||||
mMqtt.sendMsg(topic, val);
|
||||
snprintf(topic, 32 + MAX_NAME_LENGTH, "%s/available", iv->name);
|
||||
snprintf(val, 32, "0");
|
||||
mMqtt.sendMsg(topic, val);
|
||||
}
|
||||
}
|
||||
|
||||
yield();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,6 +108,11 @@
|
|||
// default MQTT topic
|
||||
#define DEF_MQTT_TOPIC "inverter"
|
||||
|
||||
//default MQTT Message Inverter Status
|
||||
#define DEF_MQTT_IV_MESSAGE_NOT_AVAIL_AND_NOT_PRODUCED "not available and not producing" // STATUS 0
|
||||
#define DEF_MQTT_IV_MESSAGE_INVERTER_AVAIL_AND_NOT_PRODUCED "available and not producing" // STATUS 1
|
||||
#define DEF_MQTT_IV_MESSAGE_INVERTER_AVAIL_AND_PRODUCED "available and producing" // STATUS 2
|
||||
|
||||
#if __has_include("config_override.h")
|
||||
#include "config_override.h"
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue