From cd54a924c21d2858e43f4b06453b441b23eaa81f Mon Sep 17 00:00:00 2001 From: Barbudor Date: Sun, 24 Sep 2023 15:39:20 +0200 Subject: [PATCH] support https URL (#19582) --- .../tasmota_xdrv_driver/xdrv_59_influxdb.ino | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_59_influxdb.ino b/tasmota/tasmota_xdrv_driver/xdrv_59_influxdb.ino index 7c1f45ed5129..d53330e25a45 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_59_influxdb.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_59_influxdb.ino @@ -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; } @@ -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")); } @@ -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(); }