mirror of https://github.com/arendst/Tasmota.git
Add non-teleperiod data to influxdb
This commit is contained in:
parent
345d011dd1
commit
8b98839729
|
@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
|
|||
## [11.0.0.5]
|
||||
### Added
|
||||
- Support for improv as used by esp-web-tools
|
||||
- Non-teleperiod data to influxdb
|
||||
|
||||
### Changed
|
||||
- Remove support for Internet Explorer by allowing ECMAScript6 syntax using less JavaScript code bytes (#15280)
|
||||
|
|
|
@ -120,6 +120,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo
|
|||
- Support for PCF85363 RTC as used in Shelly 3EM [#13515](https://github.com/arendst/Tasmota/issues/13515)
|
||||
- Full RTC chip integration and synchronisation when using UBX (=GPS), NTP or manual time
|
||||
- NeoPool JSON modules, power module, cell info, chlorine, conductivity and ionization
|
||||
- Non-teleperiod data to influxdb
|
||||
- ESP32 Berry always enable rules
|
||||
- ESP32 Berry bootloop protection
|
||||
- ESP32 support for BLE Mi scale V1 [#13517](https://github.com/arendst/Tasmota/issues/13517)
|
||||
|
|
|
@ -257,15 +257,19 @@ char* InfluxDbNumber(char* alternative, JsonParserToken value) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void InfluxDbProcessJson(void) {
|
||||
void InfluxDbProcessJson(bool use_copy = false) {
|
||||
if (!IFDB.init) { return; }
|
||||
|
||||
AddLog(IFDB.log_level, PSTR("IFX: Process %s"), ResponseData());
|
||||
char *json_data = ResponseData();
|
||||
if (use_copy) {
|
||||
json_data = (char*)malloc(ResponseSize()+2);
|
||||
if (!json_data) { return; }
|
||||
strlcpy(json_data, ResponseData(), ResponseSize());
|
||||
}
|
||||
|
||||
// String jsonStr = ResponseData(); // Make a copy before use
|
||||
// JsonParser parser((char *)jsonStr.c_str());
|
||||
JsonParser parser((char *)ResponseData()); // Destroys ResponseData but saves heap space
|
||||
AddLog(IFDB.log_level, PSTR("IFX: Process %s"), json_data);
|
||||
|
||||
JsonParser parser(json_data); // Destroys json_data
|
||||
JsonParserObject root = parser.getRootObject();
|
||||
if (root) {
|
||||
char number[12]; // '1' to '255'
|
||||
|
@ -355,6 +359,10 @@ void InfluxDbProcessJson(void) {
|
|||
InfluxDbPostData(data.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (use_copy) {
|
||||
free(json_data);
|
||||
}
|
||||
}
|
||||
|
||||
void InfluxDbPublishPowerState(uint32_t device) {
|
||||
|
|
|
@ -1093,8 +1093,14 @@ bool XdrvRulesProcess(bool teleperiod, const char* event) {
|
|||
}
|
||||
|
||||
bool XdrvRulesProcess(bool teleperiod) {
|
||||
#ifdef USE_INFLUXDB
|
||||
if (!teleperiod) { // Only process ad-hoc data here
|
||||
InfluxDbProcessJson(1); // Use a copy
|
||||
}
|
||||
#endif
|
||||
|
||||
bool result = XdrvRulesProcess(teleperiod, ResponseData());
|
||||
ResponseClear(); // Free heap space
|
||||
ResponseClear(); // Free heap space
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue