CaCO3 преди 3 години
родител
ревизия
7e997889aa

+ 12 - 8
code/components/jomjol_flowcontroll/ClassFlowControll.cpp

@@ -19,6 +19,8 @@ extern "C" {
 #include "time_sntp.h"
 #include "Helper.h"
 #include "server_ota.h"
+#include "interface_mqtt.h"
+#include "server_mqtt.h"
 
 
 //#include "CImg.h"
@@ -30,7 +32,6 @@ extern "C" {
 static const char* TAG = "FLOW CTRL";
 
 
-
 std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
     std::string _classname = "";
     std::string result = "";
@@ -275,7 +276,10 @@ void ClassFlowControll::doFlowMakeImageOnly(string time){
         if (FlowControll[i]->name() == "ClassFlowMakeImage") {
 //            zw_time = gettimestring("%Y%m%d-%H%M%S");
             zw_time = gettimestring("%H:%M:%S");
-            aktstatus = TranslateAktstatus(FlowControll[i]->name()) + " (" + zw_time + ")";
+            std::string flowStatus = TranslateAktstatus(FlowControll[i]->name());
+            aktstatus = flowStatus + " (" + zw_time + ")";
+            MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
+
             FlowControll[i]->doFlow(time);
         }
     }
@@ -302,12 +306,10 @@ bool ClassFlowControll::doFlow(string time)
     for (int i = 0; i < FlowControll.size(); ++i)
     {
         zw_time = gettimestring("%H:%M:%S");
-        aktstatus = TranslateAktstatus(FlowControll[i]->name()) + " (" + zw_time + ")";
+        std::string flowStatus = TranslateAktstatus(FlowControll[i]->name());
+        aktstatus = flowStatus + " (" + zw_time + ")";
+        MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
 
-//        zw_time = gettimestring("%Y%m%d-%H%M%S");
-//        aktstatus = zw_time + ": " + FlowControll[i]->name();
-        
-       
         string zw = "FlowControll.doFlow - " + FlowControll[i]->name();
         LogFile.WriteHeapInfo(zw);
 
@@ -333,7 +335,9 @@ bool ClassFlowControll::doFlow(string time)
 
     }
     zw_time = gettimestring("%H:%M:%S");
-    aktstatus = "Flow finished (" + zw_time + ")";
+    std::string flowStatus = "Flow finished";
+    aktstatus = flowStatus + " (" + zw_time + ")";
+    MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
     return result;
 }
 

+ 7 - 0
code/components/jomjol_mqtt/server_mqtt.cpp

@@ -139,6 +139,9 @@ void MQTThomeassistantDiscovery() {
     sendHomeAssistantDiscoveryTopic("",     "CPUtemp",         "CPU Temperature",   "thermometer",              "°C",  "temperature",     "measurement", "diagnostic");
     sendHomeAssistantDiscoveryTopic("",     "interval",        "Interval",          "clock-time-eight-outline", "min",  ""           ,    "measurement", "diagnostic");
     sendHomeAssistantDiscoveryTopic("",     "IP",              "IP",                "network-outline",           "",    "",               "",            "diagnostic");
+    sendHomeAssistantDiscoveryTopic("",     "status",          "Status",            "list-status",               "",    "",               "",            "diagnostic");
+
+
 
     for (int i = 0; i < (*NUMBERS).size(); ++i) {
          std::string group = (*NUMBERS)[i]->name;
@@ -236,3 +239,7 @@ void setMqtt_Server_Retain(int _retainFlag) {
 void mqttServer_setMainTopic( std::string _maintopic) {
     maintopic = _maintopic;
 }
+
+std::string mqttServer_getMainTopic() {
+    return maintopic;
+}

+ 1 - 0
code/components/jomjol_mqtt/server_mqtt.h

@@ -10,6 +10,7 @@ void mqttServer_setParameter(std::vector<NumberPost*>* _NUMBERS, int interval, f
 void mqttServer_setMeterType(std::string meterType, std::string valueUnit, std::string timeUnit,std::string rateUnit);
 void setMqtt_Server_Retain(int SetRetainFlag);
 void mqttServer_setMainTopic( std::string maintopic);
+std::string mqttServer_getMainTopic();
 
 void register_server_mqtt_uri(httpd_handle_t server);