esphome 2024.7.1__py3-none-any.whl → 2024.7.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- esphome/components/http_request/__init__.py +7 -7
- esphome/components/http_request/http_request.h +1 -1
- esphome/components/http_request/http_request_idf.cpp +54 -10
- esphome/const.py +1 -1
- {esphome-2024.7.1.dist-info → esphome-2024.7.2.dist-info}/METADATA +1 -1
- {esphome-2024.7.1.dist-info → esphome-2024.7.2.dist-info}/RECORD +10 -10
- {esphome-2024.7.1.dist-info → esphome-2024.7.2.dist-info}/LICENSE +0 -0
- {esphome-2024.7.1.dist-info → esphome-2024.7.2.dist-info}/WHEEL +0 -0
- {esphome-2024.7.1.dist-info → esphome-2024.7.2.dist-info}/entry_points.txt +0 -0
- {esphome-2024.7.1.dist-info → esphome-2024.7.2.dist-info}/top_level.txt +0 -0
@@ -1,17 +1,17 @@
|
|
1
|
+
from esphome import automation
|
1
2
|
import esphome.codegen as cg
|
3
|
+
from esphome.components import esp32
|
2
4
|
import esphome.config_validation as cv
|
3
|
-
from esphome import automation
|
4
5
|
from esphome.const import (
|
5
|
-
|
6
|
+
CONF_ESP8266_DISABLE_SSL_SUPPORT,
|
6
7
|
CONF_ID,
|
7
|
-
CONF_TIMEOUT,
|
8
8
|
CONF_METHOD,
|
9
|
+
CONF_TIMEOUT,
|
9
10
|
CONF_TRIGGER_ID,
|
10
11
|
CONF_URL,
|
11
|
-
|
12
|
+
__version__,
|
12
13
|
)
|
13
|
-
from esphome.core import
|
14
|
-
from esphome.components import esp32
|
14
|
+
from esphome.core import CORE, Lambda
|
15
15
|
|
16
16
|
DEPENDENCIES = ["network"]
|
17
17
|
AUTO_LOAD = ["json"]
|
@@ -99,7 +99,7 @@ CONFIG_SCHEMA = cv.All(
|
|
99
99
|
cv.Optional(CONF_FOLLOW_REDIRECTS, True): cv.boolean,
|
100
100
|
cv.Optional(CONF_REDIRECT_LIMIT, 3): cv.int_,
|
101
101
|
cv.Optional(
|
102
|
-
CONF_TIMEOUT, default="5s"
|
102
|
+
CONF_TIMEOUT, default="4.5s"
|
103
103
|
): cv.positive_time_period_milliseconds,
|
104
104
|
cv.SplitDefault(CONF_ESP8266_DISABLE_SSL_SUPPORT, esp8266=False): cv.All(
|
105
105
|
cv.only_on_esp8266, cv.boolean
|
@@ -77,7 +77,7 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::start(std::string url, std::strin
|
|
77
77
|
esp_http_client_set_header(client, header.name, header.value);
|
78
78
|
}
|
79
79
|
|
80
|
-
int body_len = body.length();
|
80
|
+
const int body_len = body.length();
|
81
81
|
|
82
82
|
esp_err_t err = esp_http_client_open(client, body_len);
|
83
83
|
if (err != ESP_OK) {
|
@@ -109,18 +109,62 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::start(std::string url, std::strin
|
|
109
109
|
return nullptr;
|
110
110
|
}
|
111
111
|
|
112
|
+
auto is_ok = [](int code) { return code >= HttpStatus_Ok && code < HttpStatus_MultipleChoices; };
|
113
|
+
|
112
114
|
container->content_length = esp_http_client_fetch_headers(client);
|
113
|
-
|
114
|
-
container->status_code
|
115
|
+
container->status_code = esp_http_client_get_status_code(client);
|
116
|
+
if (is_ok(container->status_code)) {
|
117
|
+
container->duration_ms = millis() - start;
|
118
|
+
return container;
|
119
|
+
}
|
115
120
|
|
116
|
-
if (
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
+
if (this->follow_redirects_) {
|
122
|
+
auto is_redirect = [](int code) {
|
123
|
+
return code == HttpStatus_MovedPermanently || code == HttpStatus_Found || code == HttpStatus_SeeOther ||
|
124
|
+
code == HttpStatus_TemporaryRedirect || code == HttpStatus_PermanentRedirect;
|
125
|
+
};
|
126
|
+
auto num_redirects = this->redirect_limit_;
|
127
|
+
while (is_redirect(container->status_code) && num_redirects > 0) {
|
128
|
+
err = esp_http_client_set_redirection(client);
|
129
|
+
if (err != ESP_OK) {
|
130
|
+
ESP_LOGE(TAG, "esp_http_client_set_redirection failed: %s", esp_err_to_name(err));
|
131
|
+
this->status_momentary_error("failed", 1000);
|
132
|
+
esp_http_client_cleanup(client);
|
133
|
+
return nullptr;
|
134
|
+
}
|
135
|
+
#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
|
136
|
+
char url[256]{};
|
137
|
+
if (esp_http_client_get_url(client, url, sizeof(url) - 1) == ESP_OK) {
|
138
|
+
ESP_LOGV(TAG, "redirecting to url: %s", url);
|
139
|
+
}
|
140
|
+
#endif
|
141
|
+
err = esp_http_client_open(client, 0);
|
142
|
+
if (err != ESP_OK) {
|
143
|
+
ESP_LOGE(TAG, "esp_http_client_open failed: %s", esp_err_to_name(err));
|
144
|
+
this->status_momentary_error("failed", 1000);
|
145
|
+
esp_http_client_cleanup(client);
|
146
|
+
return nullptr;
|
147
|
+
}
|
148
|
+
|
149
|
+
container->content_length = esp_http_client_fetch_headers(client);
|
150
|
+
container->status_code = esp_http_client_get_status_code(client);
|
151
|
+
if (is_ok(container->status_code)) {
|
152
|
+
container->duration_ms = millis() - start;
|
153
|
+
return container;
|
154
|
+
}
|
155
|
+
|
156
|
+
num_redirects--;
|
157
|
+
}
|
158
|
+
|
159
|
+
if (num_redirects == 0) {
|
160
|
+
ESP_LOGW(TAG, "Reach redirect limit count=%d", this->redirect_limit_);
|
161
|
+
}
|
121
162
|
}
|
122
|
-
|
123
|
-
|
163
|
+
|
164
|
+
ESP_LOGE(TAG, "HTTP Request failed; URL: %s; Code: %d", url.c_str(), container->status_code);
|
165
|
+
this->status_momentary_error("failed", 1000);
|
166
|
+
esp_http_client_cleanup(client);
|
167
|
+
return nullptr;
|
124
168
|
}
|
125
169
|
|
126
170
|
int HttpContainerIDF::read(uint8_t *buf, size_t max_len) {
|
esphome/const.py
CHANGED
@@ -5,7 +5,7 @@ esphome/codegen.py,sha256=LCJVpAwy1L9DTBsIvbgAbHj1TOXUSPgBoN--aio0gBk,1855
|
|
5
5
|
esphome/config.py,sha256=wztK2UmO7-hc6HFDAi6YWtrPVy5mH0diKuqpsWp4-XA,39616
|
6
6
|
esphome/config_helpers.py,sha256=MKf_wzO35nn41FvigXE0iYKDslPgL2ruf8R-EPtTT2I,3256
|
7
7
|
esphome/config_validation.py,sha256=G79LGVIh5BdpGkzuehkm7Db_llpbC2of4dKqZEpHc3A,64838
|
8
|
-
esphome/const.py,sha256=
|
8
|
+
esphome/const.py,sha256=BVQ2wvONSk-sHYjZBCwxUn2Wc7zl6c7e4H6dYSlml2Q,38952
|
9
9
|
esphome/coroutine.py,sha256=IG2kC92OrenyiRm7Qo9uC-4qU4b4-Lmj0TkMIjRG2RY,9344
|
10
10
|
esphome/cpp_generator.py,sha256=hW2EfubUiildhKXZIdV8Dr3Q9TM5oHybFwiTo5-vEUE,31203
|
11
11
|
esphome/cpp_helpers.py,sha256=KadRBBoo4QRT-VwdWFtvxv_FYjqhZTkBhfMX-JhEMwg,4803
|
@@ -1065,12 +1065,12 @@ esphome/components/hte501/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
|
|
1065
1065
|
esphome/components/hte501/hte501.cpp,sha256=PZjDGzy2AAZ6tz4xvrlAD0GGcFmV-HjSnsZ5lIptkNM,2789
|
1066
1066
|
esphome/components/hte501/hte501.h,sha256=EY-aX8KwudhZPQ3tyRzSU2hPFUzFkmAhrGdhAXR-8rA,998
|
1067
1067
|
esphome/components/hte501/sensor.py,sha256=H7cfhfjQ0lyUgHABpoyiKOaj_f2qhN7nDW-tTj2sttQ,1723
|
1068
|
-
esphome/components/http_request/__init__.py,sha256=
|
1068
|
+
esphome/components/http_request/__init__.py,sha256=VrQgzo1UIKfaTLjvz2j2z-CUXm2WF32IR1rC16234Pw,9338
|
1069
1069
|
esphome/components/http_request/http_request.cpp,sha256=UFpMPffAuE2enh8iBvZzV3EDr7lS-MoLaquDoi5FGEw,705
|
1070
|
-
esphome/components/http_request/http_request.h,sha256
|
1070
|
+
esphome/components/http_request/http_request.h,sha256=HjVTuX_TtonLmNNajf_W-Q-zwsXsbiUMpI0EV3xinCI,6758
|
1071
1071
|
esphome/components/http_request/http_request_arduino.cpp,sha256=HyePONw2B2095vN-f9WOFkuWkhZSYLYrcwYI5tfzakk,5362
|
1072
1072
|
esphome/components/http_request/http_request_arduino.h,sha256=iaOY5aKpQJREygOoyBB8Nsozp4cfETDt-G6Hgu_pkm0,871
|
1073
|
-
esphome/components/http_request/http_request_idf.cpp,sha256=
|
1073
|
+
esphome/components/http_request/http_request_idf.cpp,sha256=BW2i4wHlQedmtiUh0Escvwyby8nSwFg5vILRCEfQltI,6108
|
1074
1074
|
esphome/components/http_request/http_request_idf.h,sha256=RmtzXsXsi8M66Lnf6eHbdEK5PIwALlvHyNXVz4skeGQ,774
|
1075
1075
|
esphome/components/http_request/watchdog.cpp,sha256=vrRWycQv1a4iOxYaR2Ld4UJdnYgp-s2E1V6kLjqoK_w,1687
|
1076
1076
|
esphome/components/http_request/watchdog.h,sha256=45UrEdgj6KmB7lLPIK4-_BdpwZy-aDki3tMWrQn-hF8,454
|
@@ -3119,9 +3119,9 @@ esphome/dashboard/util/itertools.py,sha256=8eLrWEWmICLtXNxkKdYPQV0c_N4GEz8m9Npnb
|
|
3119
3119
|
esphome/dashboard/util/password.py,sha256=cQz3b9B-ijTe7zS6BeCW0hc3pWv6JjC78jmnycYYAh8,321
|
3120
3120
|
esphome/dashboard/util/subprocess.py,sha256=T8EW6dbU4LPd2DG1dRrdh8li71tt6J1isn411poMhkk,1022
|
3121
3121
|
esphome/dashboard/util/text.py,sha256=ENDnfN4O0NdA3CKVJjQYabFbwbrsIhVKrAMQe53qYu4,534
|
3122
|
-
esphome-2024.7.
|
3123
|
-
esphome-2024.7.
|
3124
|
-
esphome-2024.7.
|
3125
|
-
esphome-2024.7.
|
3126
|
-
esphome-2024.7.
|
3127
|
-
esphome-2024.7.
|
3122
|
+
esphome-2024.7.2.dist-info/LICENSE,sha256=HzEjkBInJe44L4WvAOPfhPJJDNj6YbnqFyvGWRzArGM,36664
|
3123
|
+
esphome-2024.7.2.dist-info/METADATA,sha256=_B0VlgrMRh3cGXgvmvDx8lKPvyG3DpQ3SpG_auc9iHg,3263
|
3124
|
+
esphome-2024.7.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
3125
|
+
esphome-2024.7.2.dist-info/entry_points.txt,sha256=mIxVNuWtbYzeEcaWCl-AQ-97aBOWbnYBAK8nbF6P4M0,50
|
3126
|
+
esphome-2024.7.2.dist-info/top_level.txt,sha256=0GSXEW3cnITpgG3qnsSMz0qoqJHAFyfw7Y8MVtEf1Yk,8
|
3127
|
+
esphome-2024.7.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|