Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InfluxDB driver properly support https URL #19582

Merged
merged 1 commit into from
Sep 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions tasmota/tasmota_xdrv_driver/xdrv_59_influxdb.ino
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ String InfluxDbAuth(void) {
}

bool InfluxDbHostByName(void) {
IPAddress ifdb_ip;
if (!WifiHostByName(SettingsText(SET_INFLUXDB_HOST), ifdb_ip)) {
AddLog(LOG_LEVEL_DEBUG, PSTR("IFX: Invalid ifxhost"));
return false;
String host = SettingsText(SET_INFLUXDB_HOST);
IFDB._serverUrl = "";
if (strncmp(host.c_str(),"http",4))
IFDB._serverUrl += "http://";
IFDB._serverUrl += host;
if (Settings->influxdb_port) {
IFDB._serverUrl += ":";
IFDB._serverUrl += Settings->influxdb_port;
}
IFDB._serverUrl = "http://";
IFDB._serverUrl += ifdb_ip.toString();
IFDB._serverUrl += ":";
IFDB._serverUrl += Settings->influxdb_port;
return true;
}

Expand Down Expand Up @@ -206,7 +206,7 @@ void InfluxDbAfterRequest(int expectedStatusCode, bool modifyLastConnStatus) {
IFDB._lastErrorResponse = IFDBhttpClient->errorToString(IFDB._lastStatusCode);
}
IFDB._lastErrorResponse.trim(); // Remove trailing \n
AddLog(LOG_LEVEL_INFO, PSTR("IFX: Error %s"), IFDB._lastErrorResponse.c_str());
AddLog(LOG_LEVEL_INFO, PSTR("IFX: Error '%s'"), IFDB._lastErrorResponse.c_str());
} else {
AddLog(IFDB.log_level, PSTR("IFX: Done"));
}
Expand Down Expand Up @@ -274,6 +274,7 @@ int InfluxDbPostData(const char *data) {
IFDBhttpClient->addHeader(F("Content-Type"), F("text/plain"));
InfluxDbBeforeRequest();
IFDB._lastStatusCode = IFDBhttpClient->POST((uint8_t*)data, strlen(data));
AddLog(IFDB.log_level, PSTR("IFX: POST statusCode %d"), IFDB._lastStatusCode);
InfluxDbAfterRequest(204, true);
IFDBhttpClient->end();
}
Expand Down