Просмотр исходного кода

Extend InfluxDBv1 with individual topic names (#2319)

* Implement individual influx topic

* Update interface_influxdb.cpp

* Update interface_influxdb.cpp

* Update FieldName

* analogROI: Activate save button after ROI creation (#2326)

* Migration of PlatformIO 5.2.0 to 6.1.0 (resp. ESP IDF from 4.4.2 to 5.0.1) (#2305)

* Migration to PlatformIO 6.1.0

* Disable RMTMEM usage as it is no longer allowed -> Smart LEDs not functional!

* moved miniz into subfolder of jomjol_fileserver_ota, else it does not build anymore.

* cleanup

* fix leading NaN (#2310)

* Migration to PlatformIO 6.1.0

* Disable RMTMEM usage as it is no longer allowed -> Smart LEDs not functional!

* moved miniz into subfolder of jomjol_fileserver_ota, else it does not build anymore.

* cleanup

* Task watchdog has new config name

* Fix return value check. It must be something else than ESP_FAIL, but it does not need to be ESP_OK!

* add missing strucures to work around new RMTMEM restriction (untested)

---------

Co-authored-by: CaCO3 <caco@ruinelli.ch>

* Keep MainFlowTask alive to handle reboot (#2325)

* Shared PSRAM memory (#2285)

* enable PSRAM logging

* add extra functions for psram shared memroy handling

* CImageBasis objects still should used dynamic memory (eg. rawImage), haw ever tmpImage must be placed inside the shared memory

* Place all STBI allocs inside the shared memory

* The models are placed in the shared PSRAM reagion and must be allocated through the dedicated functions

* .

* renaming

* fix cast warning

* add flag to switch STBI PSRAM usage

* improve PSRAM shared handling

* reserve shared PSRAM as early as possible

* init logging eralier so we can use it in PSRAM shared alloc

* move Wifi_LWIP, BSS_SEG and MQTT Outbox into PSRAM to ffree internal memory

* Check if model fits into reserved shared memory

* Update code/components/jomjol_tfliteclass/CTfLiteClass.cpp

* Update code/components/jomjol_helper/psram.cpp

* Update code/components/jomjol_helper/psram.cpp

* Update code/components/jomjol_flowcontroll/ClassFlowControll.cpp

* Update code/components/jomjol_helper/psram.cpp

* Update code/components/jomjol_helper/psram.cpp

* Update code/components/jomjol_helper/psram.cpp

* Update code/components/jomjol_image_proc/CImageBasis.cpp

* Update code/components/jomjol_helper/psram.cpp

* Update code/components/jomjol_helper/psram.cpp

* Update code/components/jomjol_helper/psram.cpp

* Update code/components/jomjol_helper/psram.cpp

* Update code/components/jomjol_helper/psram.cpp

* Update code/components/jomjol_helper/psram.cpp

* Update code/components/jomjol_helper/psram.cpp

* .

* .

* .

* .

* Korrektur Merge Conflict in main.cpp

---------

Co-authored-by: CaCO3 <caco@ruinelli.ch>
Co-authored-by: jomjol <30766535+jomjol@users.noreply.github.com>

* fix PSRAM init return value check

* Extend incl. indiv. Measurement

* Implement UX

* Update ClassFlowInfluxDBv2.cpp

* Implement individual influx topic

* Update interface_influxdb.cpp

* Update interface_influxdb.cpp

* Update FieldName

* Extend incl. indiv. Measurement

* Implement UX

* Update ClassFlowInfluxDBv2.cpp

* Update main.cpp

---------

Co-authored-by: Slider0007 <115730895+Slider0007@users.noreply.github.com>
Co-authored-by: CaCO3 <caco3@ruinelli.ch>
Co-authored-by: CaCO3 <caco@ruinelli.ch>
jomjol 2 лет назад
Родитель
Сommit
2a7f3b33a3

+ 6 - 1
code/components/jomjol_flowcontroll/ClassFlowDefineTypes.h

@@ -50,7 +50,12 @@ struct NumberPost {
     int DecimalShiftInitial;
     float AnalogDigitalTransitionStart; // When is the digit > x.1, i.e. when does it start to tilt?
     int Nachkomma;
-    string Fieldname; // Fieldname in InfluxDB2  
+
+    string FieldV1; // Fieldname in InfluxDBv1  
+    string MeasurementV1;   // Measurement in InfluxDBv1
+
+    string FieldV2;         // Fieldname in InfluxDBv2  
+    string MeasurementV2;   // Measurement in InfluxDBv2
 
     bool isExtendedResolution;
 

+ 76 - 23
code/components/jomjol_flowcontroll/ClassFlowInfluxDB.cpp

@@ -21,7 +21,6 @@ void ClassFlowInfluxDB::SetInitialParameter(void)
 {
     uri = "";
     database = "";
-    measurement = "";
 
     OldValue = "";
     flowpostprocessing = NULL;  
@@ -86,33 +85,39 @@ bool ClassFlowInfluxDB::ReadParameter(FILE* pfile, string& aktparamgraph)
     {
         ESP_LOGD(TAG, "while loop reading line: %s", aktparamgraph.c_str());
         splitted = ZerlegeZeile(aktparamgraph);
-        if ((toUpper(splitted[0]) == "USER") && (splitted.size() > 1))
+        std::string _param = GetParameterName(splitted[0]);
+
+        if ((toUpper(_param) == "USER") && (splitted.size() > 1))
         {
             this->user = splitted[1];
         }  
-        if ((toUpper(splitted[0]) == "PASSWORD") && (splitted.size() > 1))
+        if ((toUpper(_param) == "PASSWORD") && (splitted.size() > 1))
         {
             this->password = splitted[1];
         }               
-        if ((toUpper(splitted[0]) == "URI") && (splitted.size() > 1))
+        if ((toUpper(_param) == "URI") && (splitted.size() > 1))
         {
             this->uri = splitted[1];
         }
-        if (((toUpper(splitted[0]) == "MEASUREMENT")) && (splitted.size() > 1))
+        if (((toUpper(_param) == "DATABASE")) && (splitted.size() > 1))
         {
-            this->measurement = splitted[1];
+            this->database = splitted[1];
         }
-        if (((toUpper(splitted[0]) == "DATABASE")) && (splitted.size() > 1))
+        if (((toUpper(_param) == "MEASUREMENT")) && (splitted.size() > 1))
         {
-            this->database = splitted[1];
+            handleMeasurement(splitted[0], splitted[1]);
+        }
+        if (((toUpper(_param) == "FIELD")) && (splitted.size() > 1))
+        {
+            handleFieldname(splitted[0], splitted[1]);
         }
     }
 
-    if ((uri.length() > 0) && (database.length() > 0) && (measurement.length() > 0)) 
+    if ((uri.length() > 0) && (database.length() > 0)) 
     { 
 //        ESP_LOGD(TAG, "Init InfluxDB with uri: %s, measurement: %s, user: %s, password: %s", uri.c_str(), measurement.c_str(), user.c_str(), password.c_str());
-        LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Init InfluxDB with uri: " + uri + ", measurement: " + measurement + ", user: " + user + ", password: " + password);
-        InfluxDBInit(uri, database, measurement, user, password); 
+        LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Init InfluxDB with uri: " + uri + ", user: " + user + ", password: " + password);
+        InfluxDBInit(uri, database, user, password); 
         InfluxDBenable = true;
     } else {
         LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "InfluxDB init skipped as we are missing some parameters");
@@ -121,19 +126,13 @@ bool ClassFlowInfluxDB::ReadParameter(FILE* pfile, string& aktparamgraph)
     return true;
 }
 
-
-string ClassFlowInfluxDB::GetInfluxDBMeasurement()
-{
-    return measurement;
-}
-
-
 bool ClassFlowInfluxDB::doFlow(string zwtime)
 {
     if (!InfluxDBenable)
         return true;
 
     std::string result;
+    std::string measurement;
     std::string resulterror = "";
     std::string resultraw = "";
     std::string resultrate = "";
@@ -147,20 +146,28 @@ bool ClassFlowInfluxDB::doFlow(string zwtime)
 
         for (int i = 0; i < (*NUMBERS).size(); ++i)
         {
+            measurement = (*NUMBERS)[i]->MeasurementV1;
             result =  (*NUMBERS)[i]->ReturnValue;
             resultraw =  (*NUMBERS)[i]->ReturnRawValue;
             resulterror = (*NUMBERS)[i]->ErrorMessageText;
             resultrate = (*NUMBERS)[i]->ReturnRateValue;
             resulttimestamp = (*NUMBERS)[i]->timeStamp;
 
-            namenumber = (*NUMBERS)[i]->name;
-            if (namenumber == "default")
-                namenumber = "value";
+            if ((*NUMBERS)[i]->FieldV1.length() > 0)
+            {
+                namenumber = (*NUMBERS)[i]->FieldV1;
+            }
             else
-                namenumber = namenumber + "/value";
+            {
+                namenumber = (*NUMBERS)[i]->name;
+                if (namenumber == "default")
+                    namenumber = "value";
+                else
+                    namenumber = namenumber + "/value";
+            }
 
             if (result.length() > 0)   
-                InfluxDBPublish(namenumber, result, resulttimestamp);
+                InfluxDBPublish(measurement, namenumber, result, resulttimestamp);
         }
     }
    
@@ -169,4 +176,50 @@ bool ClassFlowInfluxDB::doFlow(string zwtime)
     return true;
 }
 
+void ClassFlowInfluxDB::handleMeasurement(string _decsep, string _value)
+{
+    string _digit, _decpos;
+    int _pospunkt = _decsep.find_first_of(".");
+//    ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
+    if (_pospunkt > -1)
+        _digit = _decsep.substr(0, _pospunkt);
+    else
+        _digit = "default";
+    for (int j = 0; j < flowpostprocessing->NUMBERS.size(); ++j)
+    {
+        if (_digit == "default")                        //  Set to default first (if nothing else is set)
+        {
+            flowpostprocessing->NUMBERS[j]->MeasurementV1 = _value;
+        }
+        if (flowpostprocessing->NUMBERS[j]->name == _digit)
+        {
+            flowpostprocessing->NUMBERS[j]->MeasurementV1 = _value;
+        }
+    }
+}
+
+
+void ClassFlowInfluxDB::handleFieldname(string _decsep, string _value)
+{
+    string _digit, _decpos;
+    int _pospunkt = _decsep.find_first_of(".");
+//    ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
+    if (_pospunkt > -1)
+        _digit = _decsep.substr(0, _pospunkt);
+    else
+        _digit = "default";
+    for (int j = 0; j < flowpostprocessing->NUMBERS.size(); ++j)
+    {
+        if (_digit == "default")                        //  Set to default first (if nothing else is set)
+        {
+            flowpostprocessing->NUMBERS[j]->FieldV1 = _value;
+        }
+        if (flowpostprocessing->NUMBERS[j]->name == _digit)
+        {
+            flowpostprocessing->NUMBERS[j]->FieldV1 = _value;
+        }
+    }
+}
+
+
 #endif //ENABLE_INFLUXDB

+ 7 - 2
code/components/jomjol_flowcontroll/ClassFlowInfluxDB.h

@@ -21,14 +21,19 @@ protected:
     std::string user, password; 
     bool InfluxDBenable;
 
-    void SetInitialParameter(void);        
+    void SetInitialParameter(void);    
+    
+    void handleFieldname(string _decsep, string _value);   
+    void handleMeasurement(string _decsep, string _value);
+
+    
 
 public:
     ClassFlowInfluxDB();
     ClassFlowInfluxDB(std::vector<ClassFlow*>* lfc);
     ClassFlowInfluxDB(std::vector<ClassFlow*>* lfc, ClassFlow *_prev);
 
-    string GetInfluxDBMeasurement();
+//    string GetInfluxDBMeasurement();
 
     bool ReadParameter(FILE* pfile, string& aktparamgraph);
     bool doFlow(string time);

+ 38 - 15
code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.cpp

@@ -21,7 +21,6 @@ void ClassFlowInfluxDBv2::SetInitialParameter(void)
 {
     uri = "";
     database = "";
-    measurement = "";
     dborg = "";  
     dbtoken = "";  
 //    dbfield = "";
@@ -102,13 +101,13 @@ bool ClassFlowInfluxDBv2::ReadParameter(FILE* pfile, string& aktparamgraph)
         {
             this->uri = splitted[1];
         }
-        if (((toUpper(_param) == "MEASUREMENT")) && (splitted.size() > 1))
+        if (((toUpper(_param) == "FIELD")) && (splitted.size() > 1))
         {
-            this->measurement = splitted[1];
+            handleFieldname(splitted[0], splitted[1]);
         }
-        if (((toUpper(_param) == "FIELDNAME")) && (splitted.size() > 1))
+        if (((toUpper(_param) == "MEASUREMENT")) && (splitted.size() > 1))
         {
-            handleFieldname(splitted[0], splitted[1]);
+            handleMeasurement(splitted[0], splitted[1]);
         }
         if (((toUpper(splitted[0]) == "DATABASE")) && (splitted.size() > 1))
         {
@@ -117,15 +116,14 @@ bool ClassFlowInfluxDBv2::ReadParameter(FILE* pfile, string& aktparamgraph)
     }
 
     printf("uri:         %s\n", uri.c_str());
-    printf("measurement: %s\n", measurement.c_str());
     printf("org:         %s\n", dborg.c_str());
     printf("token:       %s\n", dbtoken.c_str());
 
-    if ((uri.length() > 0) && (database.length() > 0) && (measurement.length() > 0) && (dbtoken.length() > 0) && (dborg.length() > 0)) 
+    if ((uri.length() > 0) && (database.length() > 0) && (dbtoken.length() > 0) && (dborg.length() > 0)) 
     { 
-        LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Init InfluxDB with uri: " + uri + ", measurement: " + measurement + ", org: " + dborg + ", token: *****");
+        LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Init InfluxDB with uri: " + uri + ", org: " + dborg + ", token: *****");
 //        printf("vor V2 Init\n");
-        InfluxDB_V2_Init(uri, database, measurement, dborg, dbtoken); 
+        InfluxDB_V2_Init(uri, database, dborg, dbtoken); 
 //        printf("nach V2 Init\n");
         InfluxDBenable = true;
     } else {
@@ -135,11 +133,12 @@ bool ClassFlowInfluxDBv2::ReadParameter(FILE* pfile, string& aktparamgraph)
     return true;
 }
 
-
+/*
 string ClassFlowInfluxDBv2::GetInfluxDBMeasurement()
 {
     return measurement;
 }
+*/
 
 void ClassFlowInfluxDBv2::handleFieldname(string _decsep, string _value)
 {
@@ -154,15 +153,36 @@ void ClassFlowInfluxDBv2::handleFieldname(string _decsep, string _value)
     {
         if (_digit == "default")                        //  Set to default first (if nothing else is set)
         {
-            flowpostprocessing->NUMBERS[j]->Fieldname = _value;
+            flowpostprocessing->NUMBERS[j]->FieldV2 = _value;
         }
         if (flowpostprocessing->NUMBERS[j]->name == _digit)
         {
-            flowpostprocessing->NUMBERS[j]->Fieldname = _value;
+            flowpostprocessing->NUMBERS[j]->FieldV2 = _value;
         }
     }
 }
 
+void ClassFlowInfluxDBv2::handleMeasurement(string _decsep, string _value)
+{
+    string _digit, _decpos;
+    int _pospunkt = _decsep.find_first_of(".");
+//    ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
+    if (_pospunkt > -1)
+        _digit = _decsep.substr(0, _pospunkt);
+    else
+        _digit = "default";
+    for (int j = 0; j < flowpostprocessing->NUMBERS.size(); ++j)
+    {
+        if (_digit == "default")                        //  Set to default first (if nothing else is set)
+        {
+            flowpostprocessing->NUMBERS[j]->MeasurementV2 = _value;
+        }
+        if (flowpostprocessing->NUMBERS[j]->name == _digit)
+        {
+            flowpostprocessing->NUMBERS[j]->MeasurementV2 = _value;
+        }
+    }
+}
 
 
 bool ClassFlowInfluxDBv2::doFlow(string zwtime)
@@ -170,6 +190,7 @@ bool ClassFlowInfluxDBv2::doFlow(string zwtime)
     if (!InfluxDBenable)
         return true;
 
+    std::string measurement;
     std::string result;
     std::string resulterror = "";
     std::string resultraw = "";
@@ -178,21 +199,23 @@ bool ClassFlowInfluxDBv2::doFlow(string zwtime)
     string zw = "";
     string namenumber = "";
 
+
     if (flowpostprocessing)
     {
         std::vector<NumberPost*>* NUMBERS = flowpostprocessing->GetNumbers();
 
         for (int i = 0; i < (*NUMBERS).size(); ++i)
         {
+            measurement = (*NUMBERS)[i]->MeasurementV2;
             result =  (*NUMBERS)[i]->ReturnValue;
             resultraw =  (*NUMBERS)[i]->ReturnRawValue;
             resulterror = (*NUMBERS)[i]->ErrorMessageText;
             resultrate = (*NUMBERS)[i]->ReturnRateValue;
             resulttimestamp = (*NUMBERS)[i]->timeStamp;
 
-            if ((*NUMBERS)[i]->Fieldname.length() > 0)
+            if ((*NUMBERS)[i]->FieldV2.length() > 0)
             {
-                namenumber = (*NUMBERS)[i]->Fieldname;
+                namenumber = (*NUMBERS)[i]->FieldV2;
             }
             else
             {
@@ -206,7 +229,7 @@ bool ClassFlowInfluxDBv2::doFlow(string zwtime)
             printf("vor sende Influx_DB_V2 - namenumber. %s, result: %s, timestampt: %s", namenumber.c_str(), result.c_str(), resulttimestamp.c_str());
 
             if (result.length() > 0)   
-                InfluxDB_V2_Publish(namenumber, result, resulttimestamp);
+                InfluxDB_V2_Publish(measurement, namenumber, result, resulttimestamp);
 //                InfluxDB_V2_Publish(namenumber, result, resulttimestamp);
         }
     }

+ 4 - 2
code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.h

@@ -15,7 +15,7 @@ class ClassFlowInfluxDBv2 :
     public ClassFlow
 {
 protected:
-    std::string uri, database, measurement;
+    std::string uri, database;
     std::string dborg, dbtoken, dbfield;
     std::string OldValue;
 	ClassFlowPostProcessing* flowpostprocessing;  
@@ -24,13 +24,15 @@ protected:
     void SetInitialParameter(void);     
 
     void handleFieldname(string _decsep, string _value);   
+    void handleMeasurement(string _decsep, string _value);
+
 
 public:
     ClassFlowInfluxDBv2();
     ClassFlowInfluxDBv2(std::vector<ClassFlow*>* lfc);
     ClassFlowInfluxDBv2(std::vector<ClassFlow*>* lfc, ClassFlow *_prev);
 
-    string GetInfluxDBMeasurement();
+//    string GetInfluxDBMeasurement();
 
     bool ReadParameter(FILE* pfile, string& aktparamgraph);
     bool doFlow(string time);

+ 10 - 12
code/components/jomjol_influxdb/interface_influxdb.cpp

@@ -12,28 +12,25 @@ static const char *TAG = "INFLUXDB";
 
 std::string _influxDBURI;
 std::string _influxDBDatabase;
-std::string _influxDBMeasurement;
 std::string _influxDBUser;
 std::string _influxDBPassword;
 
 std::string _influxDB_V2_URI;
 std::string _influxDB_V2_Database;
-std::string _influxDB_V2_Measurement;
 std::string _influxDB_V2_Token;
 std::string _influxDB_V2_Org;
 
 static esp_err_t http_event_handler(esp_http_client_event_t *evt);
 
-void InfluxDB_V2_Init(std::string _uri, std::string _database, std::string _measurement, std::string _org, std::string _token)
+void InfluxDB_V2_Init(std::string _uri, std::string _database, std::string _org, std::string _token)
 {
     _influxDB_V2_URI = _uri;
     _influxDB_V2_Database = _database;
-    _influxDB_V2_Measurement = _measurement;
     _influxDB_V2_Org = _org;
     _influxDB_V2_Token = _token;
 }
 
-void InfluxDB_V2_Publish(std::string _key, std::string _content, std::string _timestamp) 
+void InfluxDB_V2_Publish(std::string _measurement, std::string _key, std::string _content, std::string _timestamp) 
 {
     char response_buffer[MAX_HTTP_OUTPUT_BUFFER] = {0};
     esp_http_client_config_t http_config = {
@@ -66,11 +63,11 @@ void InfluxDB_V2_Publish(std::string _key, std::string _content, std::string _ti
 
         sprintf(nowTimestamp,"%ld000000000", (long) t);           // UTC
 
-        payload = _influxDB_V2_Measurement + " " + _key + "=" + _content + " " + nowTimestamp;
+        payload = _measurement + " " + _key + "=" + _content + " " + nowTimestamp;
     }
     else
     {
-        payload = _influxDB_V2_Measurement + " " + _key + "=" + _content;
+        payload = _measurement + " " + _key + "=" + _content;
     }
 
     payload.shrink_to_fit();
@@ -144,7 +141,7 @@ static esp_err_t http_event_handler(esp_http_client_event_t *evt)
     return ESP_OK;
 }
 
-void InfluxDBPublish(std::string _key, std::string _content, std::string _timestamp) {
+void InfluxDBPublish(std::string _measurement, std::string _key, std::string _content, std::string _timestamp) {
     char response_buffer[MAX_HTTP_OUTPUT_BUFFER] = {0};
     esp_http_client_config_t http_config = {
        .user_agent = "ESP32 Meter reader",
@@ -182,11 +179,11 @@ void InfluxDBPublish(std::string _key, std::string _content, std::string _timest
 
         sprintf(nowTimestamp,"%ld000000000", (long) t);           // UTC
 
-        payload = _influxDBMeasurement + " " + _key + "=" + _content + " " + nowTimestamp;
+        payload = _measurement + " " + _key + "=" + _content + " " + nowTimestamp;
     }
     else
     {
-        payload = _influxDB_V2_Measurement + " " + _key + "=" + _content;
+        payload = _measurement + " " + _key + "=" + _content;
     }
 
     payload.shrink_to_fit();
@@ -196,6 +193,8 @@ void InfluxDBPublish(std::string _key, std::string _content, std::string _timest
 
     // use the default retention policy of the database
     std::string apiURI = _influxDBURI + "/write?db=" + _influxDBDatabase;
+//    std::string apiURI = _influxDBURI + "/api/v2/write?bucket=" + _influxDBDatabase + "/";
+
     apiURI.shrink_to_fit();
     http_config.url = apiURI.c_str();
 
@@ -223,10 +222,9 @@ void InfluxDBPublish(std::string _key, std::string _content, std::string _timest
 }
 
 
-void InfluxDBInit(std::string _uri, std::string _database, std::string _measurement, std::string _user, std::string _password){
+void InfluxDBInit(std::string _uri, std::string _database, std::string _user, std::string _password){
     _influxDBURI = _uri;
     _influxDBDatabase = _database;
-    _influxDBMeasurement = _measurement;
     _influxDBUser = _user;
     _influxDBPassword = _password;
  

+ 4 - 4
code/components/jomjol_influxdb/interface_influxdb.h

@@ -9,12 +9,12 @@
 #include <functional>
 
 // Interface to InfluxDB v1.x
-void InfluxDBInit(std::string _influxDBURI, std::string _database, std::string _measurement, std::string _user, std::string _password);
-void InfluxDBPublish(std::string _key, std::string _content, std::string _timestamp);
+void InfluxDBInit(std::string _influxDBURI, std::string _database, std::string _user, std::string _password);
+void InfluxDBPublish(std::string _measurement, std::string _key, std::string _content, std::string _timestamp);
 
 // Interface to InfluxDB v2.x
-void InfluxDB_V2_Init(std::string _uri, std::string _database, std::string _measurement, std::string _org, std::string _token);
-void InfluxDB_V2_Publish(std::string _key, std::string _content, std::string _timestamp);
+void InfluxDB_V2_Init(std::string _uri, std::string _database, std::string _org, std::string _token);
+void InfluxDB_V2_Publish(std::string _measurement, std::string _key, std::string _content, std::string _timestamp);
 
 
 

+ 12 - 0
code/main/main.cpp

@@ -639,7 +639,19 @@ void migrateConfiguration(void) {
         }
 
         if (section == "[InfluxDB]") {
+            /* Fieldname has a <NUMBER> as prefix! */
+            if (isInString(configLines[i], "Fieldname")) { // It is the parameter "Fieldname"
+                migrated = migrated | replaceString(configLines[i], "Fieldname", "Field"); // Rename it to Field
+                migrated = migrated | replaceString(configLines[i], ";", ""); // Enable it
+            }
+        }
 
+        if (section == "[InfluxDBv2]") {
+            /* Fieldname has a <NUMBER> as prefix! */
+            if (isInString(configLines[i], "Fieldname")) { // It is the parameter "Fieldname"
+                migrated = migrated | replaceString(configLines[i], "Fieldname", "Field"); // Rename it to Field
+                migrated = migrated | replaceString(configLines[i], ";", ""); // Enable it
+            }
         }
 
         if (section == "[GPIO]") {

+ 1 - 1
sd-card/html/common.js

@@ -1,7 +1,7 @@
  
 /* The UI can also be run locally, but you have to set the IP of your devide accordingly.
  * And you also might have to disable CORS in your webbrowser! */
-var domainname_for_testing = "192.168.1.153";
+var domainname_for_testing = "192.168.178.23";
 
 
 

+ 93 - 37
sd-card/html/edit_config_param.html

@@ -688,16 +688,6 @@ textarea {
 			</td>
 			<td>$TOOLTIP_InfluxDB_Database</td>
 		</tr>
-		<tr>
-			<td class="indent1">
-				<input type="checkbox" id="InfluxDB_Measurement_enabled" value="1"  onclick = 'InvertEnableItem("InfluxDB", "Measurement")' unchecked >
-				<label for=InfluxDB_Measurement_enabled><class id="InfluxDB_Measurement_text" style="color:black;">Measurement</class></label>
-			</td>
-			<td>
-				<input type="text" id="InfluxDB_Measurement_value1">
-			</td>
-			<td>$TOOLTIP_InfluxDB_Measurement</td>
-		</tr>
 		<tr>
 			<td class="indent1">
 				<input type="checkbox" id="InfluxDB_user_enabled" value="1"  onclick = 'InvertEnableItem("InfluxDB", "user")' unchecked >
@@ -718,6 +708,34 @@ textarea {
 			</td>
 			<td>$TOOLTIP_InfluxDB_password</td>
 		</tr>
+		<tr>
+			<td class="indent1" colspan="3">
+				<br>
+				<b>InfluxDB Individual Parameters: 
+                <select id="NumbersInfluxDB_value1" onchange="numberInfluxDBChanged()">
+                </select></b>
+			</td>
+		</tr>
+		<tr>
+			<td class="indent1" style="padding-left: 75px;">
+				<input type="checkbox" id="InfluxDB_Measurement_enabled" value="1"  onclick = 'InvertEnableItem("InfluxDB", "Measurement")' unchecked >
+				<label for=InfluxDB_Measurement_enabled><class id="InfluxDB_Measurement_text" style="color:black;">Measurement</class></label>
+			</td>
+			<td>
+				<input type="text" id="InfluxDB_Measurement_value1">
+			</td>
+			<td>$TOOLTIP_InfluxDB_NUMBER.Measurement</td>
+		</tr>
+		<tr>
+			<td class="indent1" style="padding-left: 75px;">
+				<input type="checkbox" id="InfluxDB_Field_enabled" value="1"  onclick = 'InvertEnableItem("InfluxDB", "Field")' unchecked >
+				<label for=InfluxDB_Field_enabled><class id="InfluxDB_Field_text" style="color:black;">Field</class></label>
+			</td>
+			<td>
+				<input type="text" id="InfluxDB_Field_value1">
+			</td>
+			<td>$TOOLTIP_InfluxDB_NUMBER.Field</td>
+		</tr>
 
 
 
@@ -749,16 +767,6 @@ textarea {
 			</td>
 			<td>$TOOLTIP_InfluxDBv2_Database</td>
 		</tr>
-		<tr>
-			<td class="indent1">
-				<input type="checkbox" id="InfluxDBv2_Measurement_enabled" value="1"  onclick = 'InvertEnableItem("InfluxDBv2", "Measurement")' unchecked >
-				<label for=InfluxDBv2_Measurement_enabled><class id="InfluxDBv2_Measurement_text" style="color:black;">Measurement</class></label>
-			</td>
-			<td>
-				<input type="text" id="InfluxDBv2_Measurement_value1">
-			</td>
-			<td>$TOOLTIP_InfluxDBv2_Measurement</td>
-		</tr>
 		<tr>
 			<td class="indent1">
 				<input type="checkbox" id="InfluxDBv2_Org_enabled" value="1"  onclick = 'InvertEnableItem("InfluxDBv2", "Org")' unchecked >
@@ -782,20 +790,30 @@ textarea {
 		<tr>
 			<td class="indent1" colspan="3">
 				<br>
-				<b>Postprocessing Individual Parameters: 
-                <select id="NumbersInfluxDB_value1" onchange="numberInfluxDBChanged()">
+				<b>InfluxDB v2 Individual Parameters: 
+                <select id="NumbersInfluxDBv2_value1" onchange="numberInfluxDBv2Changed()">
                 </select></b>
 			</td>
 		</tr>
 		<tr>
 			<td class="indent1" style="padding-left: 75px;">
-				<input type="checkbox" id="InfluxDBv2_Fieldname_enabled" value="1"  onclick = 'InvertEnableItem("InfluxDBv2", "Fieldname")' unchecked >
-				<label for=InfluxDBv2_Fieldname_enabled><class id="InfluxDBv2_Fieldname_text" style="color:black;">Fieldname</class></label>
+				<input type="checkbox" id="InfluxDBv2_Measurement_enabled" value="1"  onclick = 'InvertEnableItem("InfluxDBv2", "Measurement")' unchecked >
+				<label for=InfluxDBv2_Measurement_enabled><class id="InfluxDBv2_Measurement_text" style="color:black;">Measurement</class></label>
+			</td>
+			<td>
+				<input type="text" id="InfluxDBv2_Measurement_value1">
+			</td>
+			<td>$TOOLTIP_InfluxDBv2_NUMBER.Measurement</td>
+		</tr>
+		<tr>
+			<td class="indent1" style="padding-left: 75px;">
+				<input type="checkbox" id="InfluxDBv2_Field_enabled" value="1"  onclick = 'InvertEnableItem("InfluxDBv2", "Field")' unchecked >
+				<label for=InfluxDBv2_Field_enabled><class id="InfluxDBv2_Field_text" style="color:black;">Field</class></label>
 			</td>
 			<td>
-				<input type="text" id="InfluxDBv2_Fieldname_value1">
+				<input type="text" id="InfluxDBv2_Field_value1">
 			</td>
-			<td>$TOOLTIP_InfluxDBv2_NUMBER.Fieldname</td>
+			<td>$TOOLTIP_InfluxDBv2_NUMBER.Field</td>
 		</tr>
 
 		<tr>
@@ -1423,11 +1441,16 @@ function InitIndivParameter()
     var _index = document.getElementById("Numbers_value1");
     while (_index.length)
         _index.remove(0);
-	var _indexInflux = document.getElementById("NumbersInfluxDB_value1");
+
+	var _indexInflux = document.getElementById("NumbersInfluxDBv2_value1");
     while (_indexInflux.length)
 		_indexInflux.remove(0);
 
-    for (var i = 0; i < NUMBERS.length; ++i){
+	var _indexInfluxv1 = document.getElementById("NumbersInfluxDB_value1");
+    while (_indexInflux.length)
+	_indexInfluxv1.remove(0);
+
+	for (var i = 0; i < NUMBERS.length; ++i){
 		var option = document.createElement("option");
         option.text = NUMBERS[i]["name"];
         option.value = i;
@@ -1437,9 +1460,16 @@ function InitIndivParameter()
         optionInflux.text = NUMBERS[i]["name"];
         optionInflux.value = i;
 		_indexInflux.add(optionInflux);
-        }
+
+		var optionInfluxv1 = document.createElement("option");
+        optionInfluxv1.text = NUMBERS[i]["name"];
+        optionInfluxv1.value = i;
+		_indexInfluxv1.add(optionInfluxv1);
+
+	}
     _index.selectedIndex = 0; 
 	_indexInflux.selectedIndex = 0; 
+	_indexInfluxv1.selectedIndex = 0;
 }
 
 
@@ -1741,7 +1771,10 @@ function UpdateInputIndividual(sel)
 		ReadParameter(param, "PostProcessing", "ExtendedResolution", false, NUNBERSAkt)		
 		ReadParameter(param, "PostProcessing", "IgnoreLeadingNaN", false, NUNBERSAkt)		
 		ReadParameter(param, "PostProcessing", "AllowNegativeRates", false, NUNBERSAkt)		
-		ReadParameter(param, "InfluxDBv2", "Fieldname", true, NUNBERSAkt)
+		ReadParameter(param, "InfluxDB", "Field", true, NUNBERSAkt)
+		ReadParameter(param, "InfluxDBv2", "Field", true, NUNBERSAkt)
+		ReadParameter(param, "InfluxDB", "Measurement", true, NUNBERSAkt)
+		ReadParameter(param, "InfluxDBv2", "Measurement", true, NUNBERSAkt)
 	}
 
 //	var sel = document.getElementById("Numbers_value1");
@@ -1753,7 +1786,10 @@ function UpdateInputIndividual(sel)
 	WriteParameter(param, category, "PostProcessing", "ExtendedResolution", false, NUNBERSAkt);
 	WriteParameter(param, category, "PostProcessing", "IgnoreLeadingNaN", false, NUNBERSAkt);
 	WriteParameter(param, category, "PostProcessing", "AllowNegativeRates", false, NUNBERSAkt);
-	WriteParameter(param, category, "InfluxDBv2", "Fieldname", true, NUNBERSAkt);
+	WriteParameter(param, category, "InfluxDB", "Field", true, NUNBERSAkt);
+	WriteParameter(param, category, "InfluxDBv2", "Field", true, NUNBERSAkt);
+	WriteParameter(param, category, "InfluxDB", "Measurement", true, NUNBERSAkt);
+	WriteParameter(param, category, "InfluxDBv2", "Measurement", true, NUNBERSAkt);
 }
 
 function UpdateInput() {
@@ -1805,16 +1841,17 @@ function UpdateInput() {
 	
 	WriteParameter(param, category, "InfluxDB", "Uri", true);	
 	WriteParameter(param, category, "InfluxDB", "Database", true);	
-	WriteParameter(param, category, "InfluxDB", "Measurement", true);	
+//	WriteParameter(param, category, "InfluxDB", "Measurement", true);	
 	WriteParameter(param, category, "InfluxDB", "user", true);	
 	WriteParameter(param, category, "InfluxDB", "password", true);	
+//	WriteParameter(param, category, "InfluxDB", "Field", true);
 
 	WriteParameter(param, category, "InfluxDBv2", "Uri", true);	
 	WriteParameter(param, category, "InfluxDBv2", "Database", true);	
-	WriteParameter(param, category, "InfluxDBv2", "Measurement", true);	
+//	WriteParameter(param, category, "InfluxDBv2", "Measurement", true);	
 	WriteParameter(param, category, "InfluxDBv2", "Org", true);	
 	WriteParameter(param, category, "InfluxDBv2", "Token", true);	
-	WriteParameter(param, category, "InfluxDBv2", "Fieldname", true);
+//	WriteParameter(param, category, "InfluxDBv2", "Field", true);
 
 	WriteParameter(param, category, "GPIO", "IO0", true);
 	WriteParameter(param, category, "GPIO", "IO1", true);
@@ -1945,7 +1982,7 @@ function ReadParameterAll()
 	ReadParameter(param, "InfluxDBv2", "Measurement", true);	
 	ReadParameter(param, "InfluxDBv2", "Org", true);	
 	ReadParameter(param, "InfluxDBv2", "Token", true);	
-//	ReadParameter(param, "InfluxDB", "Fieldname", true);	
+//	ReadParameter(param, "InfluxDB", "Field", true);	
 
 	ReadParameter(param, "GPIO", "IO0", true);
 	ReadParameter(param, "GPIO", "IO1", true);
@@ -2086,11 +2123,26 @@ function numberChanged()
 	_neu = sel.selectedIndex;
 	UpdateInputIndividual(sel);
 
-	var _selInflux = document.getElementById("NumbersInfluxDB_value1");
+	var _selInflux = document.getElementById("NumbersInfluxDBv2_value1");
 	if (_selInflux.selectedIndex != _neu)
 		_selInflux.selectedIndex = _neu
 }
  
+function numberInfluxDBv2Changed()
+{
+	var sel = document.getElementById("NumbersInfluxDBv2_value1");
+	_neu = sel.selectedIndex;
+	UpdateInputIndividual(sel);
+
+	var _sel2 = document.getElementById("Numbers_value1");
+	if (_sel2.selectedIndex != _neu)
+		_sel2.selectedIndex = _neu
+
+	var _sel3 = document.getElementById("NumbersInfluxDB_value1");
+	if (_sel3.selectedIndex != _neu)
+		_sel3.selectedIndex = _neu
+}
+
 function numberInfluxDBChanged()
 {
 	var sel = document.getElementById("NumbersInfluxDB_value1");
@@ -2099,7 +2151,11 @@ function numberInfluxDBChanged()
 
 	var _sel2 = document.getElementById("Numbers_value1");
 	if (_sel2.selectedIndex != _neu)
-	_sel2.selectedIndex = _neu
+		_sel2.selectedIndex = _neu
+
+	var _sel3 = document.getElementById("NumbersInfluxDBv2_value1");
+	if (_sel3.selectedIndex != _neu)
+		_sel3.selectedIndex = _neu
 }
 
 LoadConfigNeu();

+ 6 - 3
sd-card/html/readconfigparam.js

@@ -191,9 +191,11 @@ function ParseConfig() {
      param[catname] = new Object();
      ParamAddValue(param, catname, "Uri");
      ParamAddValue(param, catname, "Database");
-     ParamAddValue(param, catname, "Measurement");
+//     ParamAddValue(param, catname, "Measurement");
      ParamAddValue(param, catname, "user");
      ParamAddValue(param, catname, "password");
+     ParamAddValue(param, catname, "Measurement", 1, true);
+     ParamAddValue(param, catname, "Field", 1, true);
 
      var catname = "InfluxDBv2";
      category[catname] = new Object(); 
@@ -202,10 +204,11 @@ function ParseConfig() {
      param[catname] = new Object();
      ParamAddValue(param, catname, "Uri");
      ParamAddValue(param, catname, "Database");
-     ParamAddValue(param, catname, "Measurement");
+//     ParamAddValue(param, catname, "Measurement");
      ParamAddValue(param, catname, "Org");
      ParamAddValue(param, catname, "Token");
-     ParamAddValue(param, catname, "Fieldname", 1, true);
+     ParamAddValue(param, catname, "Measurement", 1, true);
+     ParamAddValue(param, catname, "Field", 1, true);
 
      var catname = "GPIO";
      category[catname] = new Object();