From 8614e4a424b3063dd8c68bfef0b52ae503c7325a Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Thu, 16 Nov 2023 23:58:19 +0100 Subject: [PATCH 1/3] rename InfluxDBv2 parameter Database to Basket --- .../jomjol_flowcontroll/ClassFlowInfluxDBv2.cpp | 10 +++++----- .../jomjol_flowcontroll/ClassFlowInfluxDBv2.h | 2 +- .../jomjol_influxdb/interface_influxdb.cpp | 10 +++++----- code/components/jomjol_influxdb/interface_influxdb.h | 2 +- code/main/main.cpp | 5 +++++ sd-card/config/config.ini | 2 +- sd-card/html/edit_config_param.html | 12 ++++++------ sd-card/html/readconfigparam.js | 2 +- 8 files changed, 25 insertions(+), 20 deletions(-) diff --git a/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.cpp b/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.cpp index 67d917e30..26f1e2ae9 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.cpp @@ -20,7 +20,7 @@ static const char* TAG = "INFLUXDBV2"; void ClassFlowInfluxDBv2::SetInitialParameter(void) { uri = ""; - database = ""; + basket = ""; dborg = ""; dbtoken = ""; // dbfield = ""; @@ -109,9 +109,9 @@ bool ClassFlowInfluxDBv2::ReadParameter(FILE* pfile, string& aktparamgraph) { handleMeasurement(splitted[0], splitted[1]); } - if (((toUpper(splitted[0]) == "DATABASE")) && (splitted.size() > 1)) + if (((toUpper(splitted[0]) == "BASKET")) && (splitted.size() > 1)) { - this->database = splitted[1]; + this->basket = splitted[1]; } } @@ -119,11 +119,11 @@ bool ClassFlowInfluxDBv2::ReadParameter(FILE* pfile, string& aktparamgraph) printf("org: %s\n", dborg.c_str()); printf("token: %s\n", dbtoken.c_str()); - if ((uri.length() > 0) && (database.length() > 0) && (dbtoken.length() > 0) && (dborg.length() > 0)) + if ((uri.length() > 0) && (basket.length() > 0) && (dbtoken.length() > 0) && (dborg.length() > 0)) { LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Init InfluxDB with uri: " + uri + ", org: " + dborg + ", token: *****"); // printf("vor V2 Init\n"); - InfluxDB_V2_Init(uri, database, dborg, dbtoken); + InfluxDB_V2_Init(uri, basket, dborg, dbtoken); // printf("nach V2 Init\n"); InfluxDBenable = true; } else { diff --git a/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.h b/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.h index 1c73d0c15..010d75afd 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.h +++ b/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.h @@ -15,7 +15,7 @@ class ClassFlowInfluxDBv2 : public ClassFlow { protected: - std::string uri, database; + std::string uri, basket; std::string dborg, dbtoken, dbfield; std::string OldValue; ClassFlowPostProcessing* flowpostprocessing; diff --git a/code/components/jomjol_influxdb/interface_influxdb.cpp b/code/components/jomjol_influxdb/interface_influxdb.cpp index e1b221461..6d4549d49 100644 --- a/code/components/jomjol_influxdb/interface_influxdb.cpp +++ b/code/components/jomjol_influxdb/interface_influxdb.cpp @@ -16,16 +16,16 @@ std::string _influxDBUser; std::string _influxDBPassword; std::string _influxDB_V2_URI; -std::string _influxDB_V2_Database; +std::string _influxDB_V2_Basket; 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 _org, std::string _token) +void InfluxDB_V2_Init(std::string _uri, std::string _basket, std::string _org, std::string _token) { _influxDB_V2_URI = _uri; - _influxDB_V2_Database = _database; + _influxDB_V2_Basket = _basket; _influxDB_V2_Org = _org; _influxDB_V2_Token = _token; } @@ -70,7 +70,7 @@ void InfluxDB_V2_Publish(std::string _measurement, std::string _key, std::string LogFile.WriteToFile(ESP_LOG_INFO, TAG, "sending line to influxdb:" + payload); - std::string apiURI = _influxDB_V2_URI + "/api/v2/write?org=" + _influxDB_V2_Org + "&bucket=" + _influxDB_V2_Database; + std::string apiURI = _influxDB_V2_URI + "/api/v2/write?org=" + _influxDB_V2_Org + "&bucket=" + _influxDB_V2_Basket; apiURI.shrink_to_fit(); http_config.url = apiURI.c_str(); ESP_LOGI(TAG, "http_config: %s", http_config.url); // Add mark on log to see when it restarted @@ -183,7 +183,7 @@ void InfluxDBPublish(std::string _measurement, std::string _key, std::string _co LogFile.WriteToFile(ESP_LOG_INFO, TAG, "sending line to influxdb:" + payload); - // use the default retention policy of the database + // use the default retention policy of the basket std::string apiURI = _influxDBURI + "/write?db=" + _influxDBDatabase; // std::string apiURI = _influxDBURI + "/api/v2/write?bucket=" + _influxDBDatabase + "/"; diff --git a/code/components/jomjol_influxdb/interface_influxdb.h b/code/components/jomjol_influxdb/interface_influxdb.h index bc29bf21d..3141c6dbb 100644 --- a/code/components/jomjol_influxdb/interface_influxdb.h +++ b/code/components/jomjol_influxdb/interface_influxdb.h @@ -13,7 +13,7 @@ void InfluxDBInit(std::string _influxDBURI, std::string _database, std::string _ 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 _org, std::string _token); +void InfluxDB_V2_Init(std::string _uri, std::string _basket, std::string _org, std::string _token); void InfluxDB_V2_Publish(std::string _measurement, std::string _key, std::string _content, std::string _timestamp); diff --git a/code/main/main.cpp b/code/main/main.cpp index a6774eab0..1c23cd72e 100644 --- a/code/main/main.cpp +++ b/code/main/main.cpp @@ -652,6 +652,11 @@ void migrateConfiguration(void) { migrated = migrated | replaceString(configLines[i], "Fieldname", "Field"); // Rename it to Field migrated = migrated | replaceString(configLines[i], ";", ""); // Enable it } + /* Database got renamed to Basket! */ + if (isInString(configLines[i], "Database")) { // It is the parameter "Database" + migrated = migrated | replaceString(configLines[i], "Database", "Basket"); // Rename it to Basket + migrated = migrated | replaceString(configLines[i], ";", ""); // Enable it + } } if (section == "[GPIO]") { diff --git a/sd-card/config/config.ini b/sd-card/config/config.ini index 49a6718c4..d82c25c6f 100644 --- a/sd-card/config/config.ini +++ b/sd-card/config/config.ini @@ -75,7 +75,7 @@ HomeassistantDiscovery = false ;[InfluxDBv2] ;Uri = undefined -;Database = undefined +;Basket = undefined ;Measurement = undefined ;Org = undefined ;Token = undefined diff --git a/sd-card/html/edit_config_param.html b/sd-card/html/edit_config_param.html index a3b4bcc29..d13480ad3 100644 --- a/sd-card/html/edit_config_param.html +++ b/sd-card/html/edit_config_param.html @@ -952,13 +952,13 @@

- - + + - + - $TOOLTIP_InfluxDBv2_Database + $TOOLTIP_InfluxDBv2_Basket @@ -2134,7 +2134,7 @@

Date: Fri, 17 Nov 2023 00:09:39 +0100 Subject: [PATCH 2/3] only enable the field if it is a boolean --- code/main/main.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/code/main/main.cpp b/code/main/main.cpp index 1c23cd72e..7d110df9d 100644 --- a/code/main/main.cpp +++ b/code/main/main.cpp @@ -642,7 +642,6 @@ void migrateConfiguration(void) { /* Fieldname has a 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 } } @@ -650,12 +649,10 @@ void migrateConfiguration(void) { /* Fieldname has a 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 } /* Database got renamed to Basket! */ if (isInString(configLines[i], "Database")) { // It is the parameter "Database" migrated = migrated | replaceString(configLines[i], "Database", "Basket"); // Rename it to Basket - migrated = migrated | replaceString(configLines[i], ";", ""); // Enable it } } @@ -819,4 +816,4 @@ bool setCpuFrequency(void) { } return true; -} \ No newline at end of file +} From 4d09566b31008c04ef293d2da95d6247d3d3a32f Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Mon, 20 Nov 2023 22:49:11 +0100 Subject: [PATCH 3/3] corrected "Basket" to "Bucket" --- .../jomjol_flowcontroll/ClassFlowInfluxDBv2.cpp | 10 +++++----- .../jomjol_flowcontroll/ClassFlowInfluxDBv2.h | 2 +- .../jomjol_influxdb/interface_influxdb.cpp | 10 +++++----- code/components/jomjol_influxdb/interface_influxdb.h | 2 +- code/main/main.cpp | 4 ++-- sd-card/config/config.ini | 2 +- sd-card/html/edit_config_param.html | 12 ++++++------ sd-card/html/readconfigparam.js | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.cpp b/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.cpp index 26f1e2ae9..bd4233059 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.cpp @@ -20,7 +20,7 @@ static const char* TAG = "INFLUXDBV2"; void ClassFlowInfluxDBv2::SetInitialParameter(void) { uri = ""; - basket = ""; + bucket = ""; dborg = ""; dbtoken = ""; // dbfield = ""; @@ -109,9 +109,9 @@ bool ClassFlowInfluxDBv2::ReadParameter(FILE* pfile, string& aktparamgraph) { handleMeasurement(splitted[0], splitted[1]); } - if (((toUpper(splitted[0]) == "BASKET")) && (splitted.size() > 1)) + if (((toUpper(splitted[0]) == "BUCKET")) && (splitted.size() > 1)) { - this->basket = splitted[1]; + this->bucket = splitted[1]; } } @@ -119,11 +119,11 @@ bool ClassFlowInfluxDBv2::ReadParameter(FILE* pfile, string& aktparamgraph) printf("org: %s\n", dborg.c_str()); printf("token: %s\n", dbtoken.c_str()); - if ((uri.length() > 0) && (basket.length() > 0) && (dbtoken.length() > 0) && (dborg.length() > 0)) + if ((uri.length() > 0) && (bucket.length() > 0) && (dbtoken.length() > 0) && (dborg.length() > 0)) { LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Init InfluxDB with uri: " + uri + ", org: " + dborg + ", token: *****"); // printf("vor V2 Init\n"); - InfluxDB_V2_Init(uri, basket, dborg, dbtoken); + InfluxDB_V2_Init(uri, bucket, dborg, dbtoken); // printf("nach V2 Init\n"); InfluxDBenable = true; } else { diff --git a/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.h b/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.h index 010d75afd..01ced8fa0 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.h +++ b/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.h @@ -15,7 +15,7 @@ class ClassFlowInfluxDBv2 : public ClassFlow { protected: - std::string uri, basket; + std::string uri, bucket; std::string dborg, dbtoken, dbfield; std::string OldValue; ClassFlowPostProcessing* flowpostprocessing; diff --git a/code/components/jomjol_influxdb/interface_influxdb.cpp b/code/components/jomjol_influxdb/interface_influxdb.cpp index 6d4549d49..dfad93203 100644 --- a/code/components/jomjol_influxdb/interface_influxdb.cpp +++ b/code/components/jomjol_influxdb/interface_influxdb.cpp @@ -16,16 +16,16 @@ std::string _influxDBUser; std::string _influxDBPassword; std::string _influxDB_V2_URI; -std::string _influxDB_V2_Basket; +std::string _influxDB_V2_Bucket; 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 _basket, std::string _org, std::string _token) +void InfluxDB_V2_Init(std::string _uri, std::string _bucket, std::string _org, std::string _token) { _influxDB_V2_URI = _uri; - _influxDB_V2_Basket = _basket; + _influxDB_V2_Bucket = _bucket; _influxDB_V2_Org = _org; _influxDB_V2_Token = _token; } @@ -70,7 +70,7 @@ void InfluxDB_V2_Publish(std::string _measurement, std::string _key, std::string LogFile.WriteToFile(ESP_LOG_INFO, TAG, "sending line to influxdb:" + payload); - std::string apiURI = _influxDB_V2_URI + "/api/v2/write?org=" + _influxDB_V2_Org + "&bucket=" + _influxDB_V2_Basket; + std::string apiURI = _influxDB_V2_URI + "/api/v2/write?org=" + _influxDB_V2_Org + "&bucket=" + _influxDB_V2_Bucket; apiURI.shrink_to_fit(); http_config.url = apiURI.c_str(); ESP_LOGI(TAG, "http_config: %s", http_config.url); // Add mark on log to see when it restarted @@ -183,7 +183,7 @@ void InfluxDBPublish(std::string _measurement, std::string _key, std::string _co LogFile.WriteToFile(ESP_LOG_INFO, TAG, "sending line to influxdb:" + payload); - // use the default retention policy of the basket + // use the default retention policy of the bucket std::string apiURI = _influxDBURI + "/write?db=" + _influxDBDatabase; // std::string apiURI = _influxDBURI + "/api/v2/write?bucket=" + _influxDBDatabase + "/"; diff --git a/code/components/jomjol_influxdb/interface_influxdb.h b/code/components/jomjol_influxdb/interface_influxdb.h index 3141c6dbb..0d969800d 100644 --- a/code/components/jomjol_influxdb/interface_influxdb.h +++ b/code/components/jomjol_influxdb/interface_influxdb.h @@ -13,7 +13,7 @@ void InfluxDBInit(std::string _influxDBURI, std::string _database, std::string _ 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 _basket, std::string _org, std::string _token); +void InfluxDB_V2_Init(std::string _uri, std::string _bucket, std::string _org, std::string _token); void InfluxDB_V2_Publish(std::string _measurement, std::string _key, std::string _content, std::string _timestamp); diff --git a/code/main/main.cpp b/code/main/main.cpp index 7d110df9d..7a508bba0 100644 --- a/code/main/main.cpp +++ b/code/main/main.cpp @@ -650,9 +650,9 @@ void migrateConfiguration(void) { if (isInString(configLines[i], "Fieldname")) { // It is the parameter "Fieldname" migrated = migrated | replaceString(configLines[i], "Fieldname", "Field"); // Rename it to Field } - /* Database got renamed to Basket! */ + /* Database got renamed to Bucket! */ if (isInString(configLines[i], "Database")) { // It is the parameter "Database" - migrated = migrated | replaceString(configLines[i], "Database", "Basket"); // Rename it to Basket + migrated = migrated | replaceString(configLines[i], "Database", "Bucket"); // Rename it to Bucket } } diff --git a/sd-card/config/config.ini b/sd-card/config/config.ini index d82c25c6f..7179e354c 100644 --- a/sd-card/config/config.ini +++ b/sd-card/config/config.ini @@ -75,7 +75,7 @@ HomeassistantDiscovery = false ;[InfluxDBv2] ;Uri = undefined -;Basket = undefined +;Bucket = undefined ;Measurement = undefined ;Org = undefined ;Token = undefined diff --git a/sd-card/html/edit_config_param.html b/sd-card/html/edit_config_param.html index d13480ad3..ce3b8335e 100644 --- a/sd-card/html/edit_config_param.html +++ b/sd-card/html/edit_config_param.html @@ -952,13 +952,13 @@

- - + + - + - $TOOLTIP_InfluxDBv2_Basket + $TOOLTIP_InfluxDBv2_Bucket @@ -2134,7 +2134,7 @@