mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-28 05:06:32 +00:00
Fix influxdb id regression
This commit is contained in:
parent
0d9678eef6
commit
1ab2b2c865
@ -524,6 +524,7 @@ bool StrCaseStr_P(const char* source, const char* search) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool IsNumeric(const char* value) {
|
bool IsNumeric(const char* value) {
|
||||||
|
// Test for characters '-.0123456789'
|
||||||
char *digit = (char*)value;
|
char *digit = (char*)value;
|
||||||
while (isdigit(*digit) || *digit == '.' || *digit == '-') { digit++; }
|
while (isdigit(*digit) || *digit == '.' || *digit == '-') { digit++; }
|
||||||
return (*digit == '\0');
|
return (*digit == '\0');
|
||||||
|
@ -293,18 +293,21 @@ void InfluxDbProcessJson(void) {
|
|||||||
} else {
|
} else {
|
||||||
// Level 2
|
// Level 2
|
||||||
// { ... "ANALOG":{"Temperature":184.72},"DS18B20":{"Id":"01144A0CB2AA","Temperature":24.88},"HTU21":{"Temperature":25.32,"Humidity":49.2,"DewPoint":13.88},"Global":{"Temperature":24.88,"Humidity":49.2,"DewPoint":13.47}, ... }
|
// { ... "ANALOG":{"Temperature":184.72},"DS18B20":{"Id":"01144A0CB2AA","Temperature":24.88},"HTU21":{"Temperature":25.32,"Humidity":49.2,"DewPoint":13.88},"Global":{"Temperature":24.88,"Humidity":49.2,"DewPoint":13.47}, ... }
|
||||||
bool isarray = value2.isArray();
|
LowerCase(type, key2.getStr());
|
||||||
const char* value = InfluxDbNumber(number, (isarray) ? (value2.getArray())[0].getStr() : value2.getStr());
|
bool is_id = (!strcmp_P(type, PSTR("id"))); // Index for DS18B20
|
||||||
|
bool is_array = value2.isArray();
|
||||||
|
const char* value = nullptr;
|
||||||
|
if (is_id && !is_array) {
|
||||||
|
snprintf_P(sensor_id, sizeof(sensor_id), PSTR(",id=%s"), value2.getStr());
|
||||||
|
} else {
|
||||||
|
value = InfluxDbNumber(number, (is_array) ? (value2.getArray())[0].getStr() : value2.getStr());
|
||||||
|
}
|
||||||
if (value != nullptr) {
|
if (value != nullptr) {
|
||||||
LowerCase(sensor, key1.getStr());
|
LowerCase(sensor, key1.getStr());
|
||||||
LowerCase(type, key2.getStr());
|
|
||||||
|
|
||||||
// AddLog(LOG_LEVEL_DEBUG, PSTR("IFX2: sensor %s (%s), type %s (%s)"), key1.getStr(), sensor, key2.getStr(), type);
|
// AddLog(LOG_LEVEL_DEBUG, PSTR("IFX2: sensor %s (%s), type %s (%s)"), key1.getStr(), sensor, key2.getStr(), type);
|
||||||
|
|
||||||
if (strcmp(type, "id") == 0) { // Index for DS18B20
|
if (is_array) {
|
||||||
snprintf_P(sensor_id, sizeof(sensor_id), PSTR(",id=%s"), value);
|
|
||||||
} else {
|
|
||||||
if (isarray) {
|
|
||||||
JsonParserArray arr = value2.getArray();
|
JsonParserArray arr = value2.getArray();
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
for (auto val : arr) {
|
for (auto val : arr) {
|
||||||
@ -325,7 +328,6 @@ void InfluxDbProcessJson(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Level 1
|
// Level 1
|
||||||
// {"Time":"2021-08-13T14:15:56","Switch1":"ON","Switch2":"OFF", ... "TempUnit":"C"}
|
// {"Time":"2021-08-13T14:15:56","Switch1":"ON","Switch2":"OFF", ... "TempUnit":"C"}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user