Fix mangled first sensor name

This commit is contained in:
Theo Arends 2021-08-13 13:55:57 +02:00
parent cdb35ecade
commit 20d88f3d68
1 changed files with 7 additions and 3 deletions

View File

@ -156,10 +156,10 @@ void InfluxDbAfterRequest(int expectedStatusCode, bool modifyLastConnStatus) {
if (IFDB._lastStatusCode != expectedStatusCode) { if (IFDB._lastStatusCode != expectedStatusCode) {
if (IFDB._lastStatusCode > 0) { if (IFDB._lastStatusCode > 0) {
IFDB._lastErrorResponse = IFDBhttpClient->getString(); IFDB._lastErrorResponse = IFDBhttpClient->getString();
AddLog(LOG_LEVEL_DEBUG, PSTR("IFX: Response\n%s"), IFDB._lastErrorResponse.c_str()); AddLog(LOG_LEVEL_INFO, PSTR("IFX: Response %s"), IFDB._lastErrorResponse.c_str()); // {"error":"database not found: \"db\""}
} else { } else {
IFDB._lastErrorResponse = IFDBhttpClient->errorToString(IFDB._lastStatusCode); IFDB._lastErrorResponse = IFDBhttpClient->errorToString(IFDB._lastStatusCode);
AddLog(LOG_LEVEL_DEBUG, PSTR("IFX: Error %s"), IFDB._lastErrorResponse.c_str()); AddLog(LOG_LEVEL_INFO, PSTR("IFX: Error %s"), IFDB._lastErrorResponse.c_str());
} }
} }
} }
@ -177,7 +177,7 @@ bool InfluxDbValidateConnection(void) {
} }
// on version 1.8.9 /health works fine // on version 1.8.9 /health works fine
// String url = IFDB._serverUrl + "/health"; // String url = IFDB._serverUrl + "/health";
AddLog(LOG_LEVEL_DEBUG, PSTR("IFX: Validating connection to %s"), url.c_str()); AddLog(LOG_LEVEL_INFO, PSTR("IFX: Validating connection to %s"), url.c_str());
if (!IFDBhttpClient->begin(*IFDBwifiClient, url)) { if (!IFDBhttpClient->begin(*IFDBwifiClient, url)) {
AddLog(LOG_LEVEL_DEBUG, PSTR("IFX: Begin failed")); AddLog(LOG_LEVEL_DEBUG, PSTR("IFX: Begin failed"));
@ -231,6 +231,8 @@ void InfluxDbMetrics(void) {
char sensor[64]; // 'ds18b20' char sensor[64]; // 'ds18b20'
char type[64]; // 'temperature' char type[64]; // 'temperature'
char sensor_id[32]; // ',id=01144A0CB2AA' char sensor_id[32]; // ',id=01144A0CB2AA'
sensor_id[0] = '\0';
String data = ""; // Multiple linebufs String data = ""; // Multiple linebufs
for (auto key1 : root) { for (auto key1 : root) {
@ -261,6 +263,8 @@ void InfluxDbMetrics(void) {
LowerCase(sensor, key1.getStr()); LowerCase(sensor, key1.getStr());
LowerCase(type, key2.getStr()); LowerCase(type, key2.getStr());
// AddLog(LOG_LEVEL_DEBUG, PSTR("IFX2: sensor %s (%s), type %s (%s)"), key1.getStr(), sensor, key2.getStr(), type);
if (strcmp(type, "totalstarttime") != 0) { // Not needed/wanted if (strcmp(type, "totalstarttime") != 0) { // Not needed/wanted
if (strcmp(type, "id") == 0) { // Index for DS18B20 if (strcmp(type, "id") == 0) { // Index for DS18B20
snprintf_P(sensor_id, sizeof(sensor_id), PSTR(",id=%s"), value); snprintf_P(sensor_id, sizeof(sensor_id), PSTR(",id=%s"), value);