esphome 2024.10.2__py3-none-any.whl → 2024.11.0__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/__main__.py +22 -4
- esphome/automation.py +29 -2
- esphome/components/animation/__init__.py +5 -8
- esphome/components/animation/animation.cpp +1 -1
- esphome/components/audio/__init__.py +9 -0
- esphome/components/audio/audio.h +21 -0
- esphome/components/axs15231/__init__.py +6 -0
- esphome/components/axs15231/touchscreen/__init__.py +36 -0
- esphome/components/axs15231/touchscreen/axs15231_touchscreen.cpp +64 -0
- esphome/components/axs15231/touchscreen/axs15231_touchscreen.h +27 -0
- esphome/components/bme68x_bsec2/__init__.py +1 -1
- esphome/components/bme68x_bsec2/bme68x_bsec2.cpp +50 -47
- esphome/components/bme68x_bsec2/bme68x_bsec2.h +0 -2
- esphome/components/bytebuffer/__init__.py +5 -0
- esphome/components/bytebuffer/bytebuffer.h +421 -0
- esphome/components/climate/__init__.py +14 -13
- esphome/components/datetime/__init__.py +3 -3
- esphome/components/debug/debug_esp32.cpp +16 -8
- esphome/components/dfplayer/dfplayer.cpp +132 -6
- esphome/components/dfplayer/dfplayer.h +19 -53
- esphome/components/display/display.cpp +142 -0
- esphome/components/display/display.h +7 -0
- esphome/components/es8311/__init__.py +0 -0
- esphome/components/es8311/audio_dac.py +70 -0
- esphome/components/es8311/es8311.cpp +227 -0
- esphome/components/es8311/es8311.h +135 -0
- esphome/components/es8311/es8311_const.h +195 -0
- esphome/components/esp32/boards.py +199 -1
- esphome/components/esp32/gpio.py +3 -1
- esphome/components/esp32_ble/const_esp32c6.h +7 -0
- esphome/components/esp32_ble_client/ble_client_base.h +1 -1
- esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +3 -0
- esphome/components/esp32_ble_tracker/esp32_ble_tracker.h +2 -1
- esphome/components/esp32_rmt_led_strip/led_strip.cpp +2 -2
- esphome/components/esp32_rmt_led_strip/led_strip.h +2 -0
- esphome/components/esp32_rmt_led_strip/light.py +3 -1
- esphome/components/esp8266/gpio.py +7 -5
- esphome/components/ethernet/__init__.py +55 -1
- esphome/components/ethernet/ethernet_component.cpp +14 -1
- esphome/components/ethernet/ethernet_component.h +7 -1
- esphome/components/font/__init__.py +213 -108
- esphome/components/gp8403/output/__init__.py +1 -1
- esphome/components/host/gpio.py +6 -4
- esphome/components/http_request/__init__.py +12 -0
- esphome/components/http_request/http_request.h +65 -3
- esphome/components/http_request/http_request_arduino.cpp +4 -3
- esphome/components/http_request/http_request_idf.cpp +12 -14
- esphome/components/http_request/ota/ota_http_request.cpp +1 -1
- esphome/components/http_request/update/http_request_update.cpp +1 -1
- esphome/components/i2c_device/__init__.py +26 -0
- esphome/components/i2c_device/i2c_device.cpp +17 -0
- esphome/components/i2c_device/i2c_device.h +18 -0
- esphome/components/i2s_audio/__init__.py +1 -3
- esphome/components/i2s_audio/speaker/__init__.py +12 -4
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +426 -200
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +92 -33
- esphome/components/ili9xxx/display.py +5 -1
- esphome/components/image/__init__.py +5 -8
- esphome/components/image/image.cpp +14 -14
- esphome/components/image/image.h +20 -24
- esphome/components/internal_temperature/internal_temperature.cpp +51 -2
- esphome/components/internal_temperature/internal_temperature.h +1 -0
- esphome/components/ld2420/ld2420.cpp +1 -1
- esphome/components/libretiny/gpio.py +4 -2
- esphome/components/light/__init__.py +32 -1
- esphome/components/light/automation.py +39 -32
- esphome/components/light/effects.py +36 -36
- esphome/components/light/light_state.cpp +6 -16
- esphome/components/light/light_state.h +34 -0
- esphome/components/light/types.py +3 -1
- esphome/components/logger/logger_esp32.cpp +15 -0
- esphome/components/lvgl/__init__.py +202 -95
- esphome/components/lvgl/automation.py +42 -40
- esphome/components/lvgl/binary_sensor/__init__.py +8 -15
- esphome/components/lvgl/defines.py +14 -8
- esphome/components/lvgl/encoders.py +11 -8
- esphome/components/lvgl/keypads.py +77 -0
- esphome/components/lvgl/light/__init__.py +6 -8
- esphome/components/lvgl/lv_validation.py +2 -4
- esphome/components/lvgl/lvcode.py +3 -9
- esphome/components/lvgl/lvgl_esphome.cpp +210 -89
- esphome/components/lvgl/lvgl_esphome.h +113 -30
- esphome/components/lvgl/lvgl_proxy.h +17 -0
- esphome/components/lvgl/number/__init__.py +10 -15
- esphome/components/lvgl/schemas.py +4 -2
- esphome/components/lvgl/select/__init__.py +12 -37
- esphome/components/lvgl/select/lvgl_select.h +27 -33
- esphome/components/lvgl/sensor/__init__.py +8 -14
- esphome/components/lvgl/styles.py +3 -4
- esphome/components/lvgl/switch/__init__.py +8 -13
- esphome/components/lvgl/text/__init__.py +5 -6
- esphome/components/lvgl/text_sensor/__init__.py +15 -15
- esphome/components/lvgl/touchscreens.py +2 -3
- esphome/components/lvgl/trigger.py +7 -9
- esphome/components/lvgl/types.py +9 -3
- esphome/components/lvgl/widgets/__init__.py +32 -21
- esphome/components/lvgl/widgets/animimg.py +4 -3
- esphome/components/lvgl/widgets/dropdown.py +22 -10
- esphome/components/lvgl/widgets/img.py +2 -0
- esphome/components/lvgl/widgets/msgbox.py +6 -5
- esphome/components/lvgl/widgets/obj.py +4 -2
- esphome/components/lvgl/widgets/page.py +3 -2
- esphome/components/lvgl/widgets/qrcode.py +54 -0
- esphome/components/lvgl/widgets/roller.py +21 -14
- esphome/components/lvgl/widgets/tileview.py +2 -1
- esphome/components/max17043/__init__.py +1 -0
- esphome/components/max17043/automation.h +20 -0
- esphome/components/max17043/max17043.cpp +98 -0
- esphome/components/max17043/max17043.h +29 -0
- esphome/components/max17043/sensor.py +77 -0
- esphome/components/media_player/__init__.py +11 -0
- esphome/components/media_player/automation.h +10 -0
- esphome/components/media_player/media_player.cpp +4 -0
- esphome/components/midea/air_conditioner.cpp +17 -1
- esphome/components/mlx90393/sensor.py +1 -1
- esphome/components/modbus/modbus.cpp +24 -12
- esphome/components/modbus_controller/__init__.py +31 -1
- esphome/components/modbus_controller/automation.h +16 -0
- esphome/components/modbus_controller/const.py +2 -0
- esphome/components/modbus_controller/modbus_controller.cpp +14 -2
- esphome/components/modbus_controller/modbus_controller.h +9 -0
- esphome/components/mopeka_pro_check/mopeka_pro_check.cpp +40 -21
- esphome/components/mopeka_pro_check/mopeka_pro_check.h +9 -2
- esphome/components/mopeka_pro_check/sensor.py +41 -0
- esphome/components/mqtt/__init__.py +36 -0
- esphome/components/mqtt/mqtt_client.cpp +27 -3
- esphome/components/mqtt/mqtt_client.h +27 -2
- esphome/components/mqtt/mqtt_climate.cpp +4 -2
- esphome/components/mqtt/mqtt_component.cpp +6 -0
- esphome/components/mqtt/mqtt_component.h +4 -0
- esphome/components/mqtt/mqtt_const.h +6 -0
- esphome/components/online_image/online_image.cpp +2 -8
- esphome/components/online_image/online_image.h +2 -6
- esphome/components/opentherm/__init__.py +35 -9
- esphome/components/opentherm/binary_sensor/__init__.py +33 -0
- esphome/components/opentherm/const.py +11 -0
- esphome/components/opentherm/generate.py +142 -0
- esphome/components/opentherm/hub.cpp +130 -24
- esphome/components/opentherm/hub.h +62 -9
- esphome/components/opentherm/input.h +18 -0
- esphome/components/opentherm/input.py +51 -0
- esphome/components/opentherm/number/__init__.py +74 -0
- esphome/components/opentherm/number/number.cpp +40 -0
- esphome/components/opentherm/number/number.h +31 -0
- esphome/components/opentherm/opentherm.cpp +30 -0
- esphome/components/opentherm/opentherm.h +34 -2
- esphome/components/opentherm/opentherm_macros.h +151 -0
- esphome/components/opentherm/output/__init__.py +47 -0
- esphome/components/opentherm/output/output.cpp +18 -0
- esphome/components/opentherm/output/output.h +33 -0
- esphome/components/opentherm/schema.py +814 -0
- esphome/components/opentherm/sensor/__init__.py +51 -0
- esphome/components/opentherm/switch/__init__.py +43 -0
- esphome/components/opentherm/switch/switch.cpp +28 -0
- esphome/components/opentherm/switch/switch.h +20 -0
- esphome/components/opentherm/validate.py +31 -0
- esphome/components/pcd8544/display.py +8 -4
- esphome/components/prometheus/prometheus_handler.cpp +176 -14
- esphome/components/prometheus/prometheus_handler.h +25 -7
- esphome/components/qspi_amoled/display.py +1 -141
- esphome/components/qspi_dbi/display.py +185 -0
- esphome/components/qspi_dbi/models.py +64 -0
- esphome/components/{qspi_amoled/qspi_amoled.cpp → qspi_dbi/qspi_dbi.cpp} +95 -46
- esphome/components/{qspi_amoled/qspi_amoled.h → qspi_dbi/qspi_dbi.h} +26 -15
- esphome/components/rp2040/__init__.py +6 -3
- esphome/components/rp2040/gpio.py +5 -3
- esphome/components/rpi_dpi_rgb/rpi_dpi_rgb.cpp +20 -0
- esphome/components/rpi_dpi_rgb/rpi_dpi_rgb.h +3 -2
- esphome/components/rtttl/rtttl.cpp +4 -1
- esphome/components/rtttl/rtttl.h +1 -0
- esphome/components/sdl/sdl_esphome.cpp +22 -5
- esphome/components/sdl/sdl_esphome.h +1 -0
- esphome/components/sdm_meter/sdm_meter.cpp +1 -1
- esphome/components/sensor/__init__.py +18 -8
- esphome/components/sensor/filter.cpp +19 -18
- esphome/components/sensor/filter.h +9 -10
- esphome/components/sgp4x/sgp4x.cpp +40 -74
- esphome/components/sgp4x/sgp4x.h +5 -3
- esphome/components/speaker/__init__.py +51 -5
- esphome/components/speaker/automation.h +25 -0
- esphome/components/speaker/speaker.h +72 -1
- esphome/components/spi/__init__.py +15 -14
- esphome/components/spi_device/__init__.py +4 -15
- esphome/components/ssd1306_spi/display.py +6 -2
- esphome/components/ssd1322_spi/display.py +6 -2
- esphome/components/ssd1325_spi/display.py +6 -2
- esphome/components/ssd1327_spi/display.py +6 -2
- esphome/components/ssd1331_spi/display.py +6 -2
- esphome/components/ssd1351_spi/display.py +6 -2
- esphome/components/st7567_spi/display.py +6 -2
- esphome/components/st7701s/display.py +5 -1
- esphome/components/st7735/display.py +10 -5
- esphome/components/st7789v/display.py +12 -7
- esphome/components/statsd/statsd.cpp +2 -0
- esphome/components/statsd/statsd.h +2 -0
- esphome/components/sun/sun.h +3 -0
- esphome/components/tc74/__init__.py +1 -0
- esphome/components/tc74/sensor.py +32 -0
- esphome/components/tc74/tc74.cpp +68 -0
- esphome/components/tc74/tc74.h +28 -0
- esphome/components/touchscreen/__init__.py +41 -50
- esphome/components/touchscreen/touchscreen.h +4 -8
- esphome/components/tuya/fan/tuya_fan.cpp +1 -1
- esphome/components/udp/udp_component.cpp +6 -3
- esphome/components/udp/udp_component.h +4 -2
- esphome/components/waveshare_epaper/display.py +6 -2
- esphome/components/web_server/web_server.cpp +22 -0
- esphome/components/web_server/web_server.h +3 -0
- esphome/components/weikai/weikai.h +2 -2
- esphome/components/wifi/wifi_component.cpp +2 -2
- esphome/components/wifi/wifi_component_esp32_arduino.cpp +4 -4
- esphome/components/wifi/wifi_component_esp8266.cpp +4 -4
- esphome/components/wifi/wifi_component_esp_idf.cpp +2 -2
- esphome/components/xpt2046/touchscreen/__init__.py +7 -32
- esphome/config_validation.py +3 -1
- esphome/const.py +9 -2
- esphome/core/defines.h +8 -2
- esphome/core/helpers.cpp +32 -17
- esphome/core/helpers.h +32 -16
- esphome/core/ring_buffer.cpp +2 -2
- esphome/core/ring_buffer.h +2 -2
- esphome/dashboard/core.py +25 -0
- esphome/dashboard/status/mdns.py +3 -4
- esphome/dashboard/web_server.py +54 -19
- esphome/espota2.py +36 -35
- esphome/helpers.py +68 -16
- esphome/mqtt.py +9 -2
- esphome/storage_json.py +4 -0
- esphome/writer.py +7 -18
- esphome/zeroconf.py +8 -6
- {esphome-2024.10.2.dist-info → esphome-2024.11.0.dist-info}/METADATA +7 -5
- {esphome-2024.10.2.dist-info → esphome-2024.11.0.dist-info}/RECORD +237 -191
- esphome/core/bytebuffer.cpp +0 -167
- esphome/core/bytebuffer.h +0 -144
- /esphome/components/{qspi_amoled → qspi_dbi}/__init__.py +0 -0
- {esphome-2024.10.2.dist-info → esphome-2024.11.0.dist-info}/LICENSE +0 -0
- {esphome-2024.10.2.dist-info → esphome-2024.11.0.dist-info}/WHEEL +0 -0
- {esphome-2024.10.2.dist-info → esphome-2024.11.0.dist-info}/entry_points.txt +0 -0
- {esphome-2024.10.2.dist-info → esphome-2024.11.0.dist-info}/top_level.txt +0 -0
@@ -22,6 +22,63 @@ struct Header {
|
|
22
22
|
const char *value;
|
23
23
|
};
|
24
24
|
|
25
|
+
// Some common HTTP status codes
|
26
|
+
enum HttpStatus {
|
27
|
+
HTTP_STATUS_OK = 200,
|
28
|
+
HTTP_STATUS_NO_CONTENT = 204,
|
29
|
+
HTTP_STATUS_PARTIAL_CONTENT = 206,
|
30
|
+
|
31
|
+
/* 3xx - Redirection */
|
32
|
+
HTTP_STATUS_MULTIPLE_CHOICES = 300,
|
33
|
+
HTTP_STATUS_MOVED_PERMANENTLY = 301,
|
34
|
+
HTTP_STATUS_FOUND = 302,
|
35
|
+
HTTP_STATUS_SEE_OTHER = 303,
|
36
|
+
HTTP_STATUS_NOT_MODIFIED = 304,
|
37
|
+
HTTP_STATUS_TEMPORARY_REDIRECT = 307,
|
38
|
+
HTTP_STATUS_PERMANENT_REDIRECT = 308,
|
39
|
+
|
40
|
+
/* 4XX - CLIENT ERROR */
|
41
|
+
HTTP_STATUS_BAD_REQUEST = 400,
|
42
|
+
HTTP_STATUS_UNAUTHORIZED = 401,
|
43
|
+
HTTP_STATUS_FORBIDDEN = 403,
|
44
|
+
HTTP_STATUS_NOT_FOUND = 404,
|
45
|
+
HTTP_STATUS_METHOD_NOT_ALLOWED = 405,
|
46
|
+
HTTP_STATUS_NOT_ACCEPTABLE = 406,
|
47
|
+
HTTP_STATUS_LENGTH_REQUIRED = 411,
|
48
|
+
|
49
|
+
/* 5xx - Server Error */
|
50
|
+
HTTP_STATUS_INTERNAL_ERROR = 500
|
51
|
+
};
|
52
|
+
|
53
|
+
/**
|
54
|
+
* @brief Returns true if the HTTP status code is a redirect.
|
55
|
+
*
|
56
|
+
* @param status the HTTP status code to check
|
57
|
+
* @return true if the status code is a redirect, false otherwise
|
58
|
+
*/
|
59
|
+
inline bool is_redirect(int const status) {
|
60
|
+
switch (status) {
|
61
|
+
case HTTP_STATUS_MOVED_PERMANENTLY:
|
62
|
+
case HTTP_STATUS_FOUND:
|
63
|
+
case HTTP_STATUS_SEE_OTHER:
|
64
|
+
case HTTP_STATUS_TEMPORARY_REDIRECT:
|
65
|
+
case HTTP_STATUS_PERMANENT_REDIRECT:
|
66
|
+
return true;
|
67
|
+
default:
|
68
|
+
return false;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
/**
|
73
|
+
* @brief Checks if the given HTTP status code indicates a successful request.
|
74
|
+
*
|
75
|
+
* A successful request is one where the status code is in the range 200-299
|
76
|
+
*
|
77
|
+
* @param status the HTTP status code to check
|
78
|
+
* @return true if the status code indicates a successful request, false otherwise
|
79
|
+
*/
|
80
|
+
inline bool is_success(int const status) { return status >= HTTP_STATUS_OK && status < HTTP_STATUS_MULTIPLE_CHOICES; }
|
81
|
+
|
25
82
|
class HttpRequestComponent;
|
26
83
|
|
27
84
|
class HttpContainer : public Parented<HttpRequestComponent> {
|
@@ -78,8 +135,8 @@ class HttpRequestComponent : public Component {
|
|
78
135
|
|
79
136
|
protected:
|
80
137
|
const char *useragent_{nullptr};
|
81
|
-
bool follow_redirects_;
|
82
|
-
uint16_t redirect_limit_;
|
138
|
+
bool follow_redirects_{};
|
139
|
+
uint16_t redirect_limit_{};
|
83
140
|
uint16_t timeout_{4500};
|
84
141
|
uint32_t watchdog_timeout_{0};
|
85
142
|
};
|
@@ -100,6 +157,8 @@ template<typename... Ts> class HttpRequestSendAction : public Action<Ts...> {
|
|
100
157
|
|
101
158
|
void register_response_trigger(HttpRequestResponseTrigger *trigger) { this->response_triggers_.push_back(trigger); }
|
102
159
|
|
160
|
+
void register_error_trigger(Trigger<> *trigger) { this->error_triggers_.push_back(trigger); }
|
161
|
+
|
103
162
|
void set_max_response_buffer_size(size_t max_response_buffer_size) {
|
104
163
|
this->max_response_buffer_size_ = max_response_buffer_size;
|
105
164
|
}
|
@@ -129,6 +188,8 @@ template<typename... Ts> class HttpRequestSendAction : public Action<Ts...> {
|
|
129
188
|
auto container = this->parent_->start(this->url_.value(x...), this->method_.value(x...), body, headers);
|
130
189
|
|
131
190
|
if (container == nullptr) {
|
191
|
+
for (auto *trigger : this->error_triggers_)
|
192
|
+
trigger->trigger(x...);
|
132
193
|
return;
|
133
194
|
}
|
134
195
|
|
@@ -180,7 +241,8 @@ template<typename... Ts> class HttpRequestSendAction : public Action<Ts...> {
|
|
180
241
|
std::map<const char *, TemplatableValue<const char *, Ts...>> headers_{};
|
181
242
|
std::map<const char *, TemplatableValue<std::string, Ts...>> json_{};
|
182
243
|
std::function<void(Ts..., JsonObject)> json_func_{nullptr};
|
183
|
-
std::vector<HttpRequestResponseTrigger *> response_triggers_;
|
244
|
+
std::vector<HttpRequestResponseTrigger *> response_triggers_{};
|
245
|
+
std::vector<Trigger<> *> error_triggers_{};
|
184
246
|
|
185
247
|
size_t max_response_buffer_size_{SIZE_MAX};
|
186
248
|
};
|
@@ -104,7 +104,9 @@ std::shared_ptr<HttpContainer> HttpRequestArduino::start(std::string url, std::s
|
|
104
104
|
static const size_t HEADER_COUNT = sizeof(header_keys) / sizeof(header_keys[0]);
|
105
105
|
container->client_.collectHeaders(header_keys, HEADER_COUNT);
|
106
106
|
|
107
|
+
App.feed_wdt();
|
107
108
|
container->status_code = container->client_.sendRequest(method.c_str(), body.c_str());
|
109
|
+
App.feed_wdt();
|
108
110
|
if (container->status_code < 0) {
|
109
111
|
ESP_LOGW(TAG, "HTTP Request failed; URL: %s; Error: %s", url.c_str(),
|
110
112
|
HTTPClient::errorToString(container->status_code).c_str());
|
@@ -113,11 +115,10 @@ std::shared_ptr<HttpContainer> HttpRequestArduino::start(std::string url, std::s
|
|
113
115
|
return nullptr;
|
114
116
|
}
|
115
117
|
|
116
|
-
if (container->status_code
|
118
|
+
if (!is_success(container->status_code)) {
|
117
119
|
ESP_LOGE(TAG, "HTTP Request failed; URL: %s; Code: %d", url.c_str(), container->status_code);
|
118
120
|
this->status_momentary_error("failed", 1000);
|
119
|
-
container
|
120
|
-
return nullptr;
|
121
|
+
// Still return the container, so it can be used to get the status code and error message
|
121
122
|
}
|
122
123
|
|
123
124
|
int content_length = container->client_.getSize();
|
@@ -6,7 +6,6 @@
|
|
6
6
|
#include "esphome/components/watchdog/watchdog.h"
|
7
7
|
|
8
8
|
#include "esphome/core/application.h"
|
9
|
-
#include "esphome/core/defines.h"
|
10
9
|
#include "esphome/core/log.h"
|
11
10
|
|
12
11
|
#if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE
|
@@ -118,20 +117,17 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::start(std::string url, std::strin
|
|
118
117
|
return nullptr;
|
119
118
|
}
|
120
119
|
|
121
|
-
|
122
|
-
|
120
|
+
App.feed_wdt();
|
123
121
|
container->content_length = esp_http_client_fetch_headers(client);
|
122
|
+
App.feed_wdt();
|
124
123
|
container->status_code = esp_http_client_get_status_code(client);
|
125
|
-
|
124
|
+
App.feed_wdt();
|
125
|
+
if (is_success(container->status_code)) {
|
126
126
|
container->duration_ms = millis() - start;
|
127
127
|
return container;
|
128
128
|
}
|
129
129
|
|
130
130
|
if (this->follow_redirects_) {
|
131
|
-
auto is_redirect = [](int code) {
|
132
|
-
return code == HttpStatus_MovedPermanently || code == HttpStatus_Found || code == HttpStatus_SeeOther ||
|
133
|
-
code == HttpStatus_TemporaryRedirect || code == HttpStatus_PermanentRedirect;
|
134
|
-
};
|
135
131
|
auto num_redirects = this->redirect_limit_;
|
136
132
|
while (is_redirect(container->status_code) && num_redirects > 0) {
|
137
133
|
err = esp_http_client_set_redirection(client);
|
@@ -142,9 +138,9 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::start(std::string url, std::strin
|
|
142
138
|
return nullptr;
|
143
139
|
}
|
144
140
|
#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
|
145
|
-
char
|
146
|
-
if (esp_http_client_get_url(client,
|
147
|
-
ESP_LOGV(TAG, "redirecting to url: %s",
|
141
|
+
char redirect_url[256]{};
|
142
|
+
if (esp_http_client_get_url(client, redirect_url, sizeof(redirect_url) - 1) == ESP_OK) {
|
143
|
+
ESP_LOGV(TAG, "redirecting to url: %s", redirect_url);
|
148
144
|
}
|
149
145
|
#endif
|
150
146
|
err = esp_http_client_open(client, 0);
|
@@ -155,9 +151,12 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::start(std::string url, std::strin
|
|
155
151
|
return nullptr;
|
156
152
|
}
|
157
153
|
|
154
|
+
App.feed_wdt();
|
158
155
|
container->content_length = esp_http_client_fetch_headers(client);
|
156
|
+
App.feed_wdt();
|
159
157
|
container->status_code = esp_http_client_get_status_code(client);
|
160
|
-
|
158
|
+
App.feed_wdt();
|
159
|
+
if (is_success(container->status_code)) {
|
161
160
|
container->duration_ms = millis() - start;
|
162
161
|
return container;
|
163
162
|
}
|
@@ -172,8 +171,7 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::start(std::string url, std::strin
|
|
172
171
|
|
173
172
|
ESP_LOGE(TAG, "HTTP Request failed; URL: %s; Code: %d", url.c_str(), container->status_code);
|
174
173
|
this->status_momentary_error("failed", 1000);
|
175
|
-
|
176
|
-
return nullptr;
|
174
|
+
return container;
|
177
175
|
}
|
178
176
|
|
179
177
|
int HttpContainerIDF::read(uint8_t *buf, size_t max_len) {
|
@@ -106,7 +106,7 @@ uint8_t OtaHttpRequestComponent::do_ota_() {
|
|
106
106
|
|
107
107
|
auto container = this->parent_->get(url_with_auth);
|
108
108
|
|
109
|
-
if (container == nullptr) {
|
109
|
+
if (container == nullptr || container->status_code != HTTP_STATUS_OK) {
|
110
110
|
return OTA_CONNECTION_ERROR;
|
111
111
|
}
|
112
112
|
|
@@ -31,7 +31,7 @@ void HttpRequestUpdate::setup() {
|
|
31
31
|
void HttpRequestUpdate::update() {
|
32
32
|
auto container = this->request_parent_->get(this->source_url_);
|
33
33
|
|
34
|
-
if (container == nullptr) {
|
34
|
+
if (container == nullptr || container->status_code != HTTP_STATUS_OK) {
|
35
35
|
std::string msg = str_sprintf("Failed to fetch manifest from %s", this->source_url_.c_str());
|
36
36
|
this->status_set_error(msg.c_str());
|
37
37
|
return;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import esphome.codegen as cg
|
2
|
+
import esphome.config_validation as cv
|
3
|
+
from esphome.components import i2c
|
4
|
+
from esphome.const import CONF_ID
|
5
|
+
|
6
|
+
DEPENDENCIES = ["i2c"]
|
7
|
+
CODEOWNERS = ["@gabest11"]
|
8
|
+
MULTI_CONF = True
|
9
|
+
|
10
|
+
i2c_device_ns = cg.esphome_ns.namespace("i2c_device")
|
11
|
+
|
12
|
+
I2CDeviceComponent = i2c_device_ns.class_(
|
13
|
+
"I2CDeviceComponent", cg.Component, i2c.I2CDevice
|
14
|
+
)
|
15
|
+
|
16
|
+
CONFIG_SCHEMA = cv.Schema(
|
17
|
+
{
|
18
|
+
cv.GenerateID(CONF_ID): cv.declare_id(I2CDeviceComponent),
|
19
|
+
}
|
20
|
+
).extend(i2c.i2c_device_schema(None))
|
21
|
+
|
22
|
+
|
23
|
+
async def to_code(config):
|
24
|
+
var = cg.new_Pvariable(config[CONF_ID])
|
25
|
+
await cg.register_component(var, config)
|
26
|
+
await i2c.register_i2c_device(var, config)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#include "i2c_device.h"
|
2
|
+
#include "esphome/core/log.h"
|
3
|
+
#include "esphome/core/hal.h"
|
4
|
+
#include <cinttypes>
|
5
|
+
|
6
|
+
namespace esphome {
|
7
|
+
namespace i2c_device {
|
8
|
+
|
9
|
+
static const char *const TAG = "i2c_device";
|
10
|
+
|
11
|
+
void I2CDeviceComponent::dump_config() {
|
12
|
+
ESP_LOGCONFIG(TAG, "I2CDevice");
|
13
|
+
LOG_I2C_DEVICE(this);
|
14
|
+
}
|
15
|
+
|
16
|
+
} // namespace i2c_device
|
17
|
+
} // namespace esphome
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "esphome/core/component.h"
|
4
|
+
#include "esphome/components/i2c/i2c.h"
|
5
|
+
|
6
|
+
namespace esphome {
|
7
|
+
namespace i2c_device {
|
8
|
+
|
9
|
+
class I2CDeviceComponent : public Component, public i2c::I2CDevice {
|
10
|
+
public:
|
11
|
+
void dump_config() override;
|
12
|
+
float get_setup_priority() const override { return setup_priority::DATA; }
|
13
|
+
|
14
|
+
protected:
|
15
|
+
};
|
16
|
+
|
17
|
+
} // namespace i2c_device
|
18
|
+
} // namespace esphome
|
@@ -8,7 +8,7 @@ from esphome.components.esp32.const import (
|
|
8
8
|
VARIANT_ESP32S3,
|
9
9
|
)
|
10
10
|
import esphome.config_validation as cv
|
11
|
-
from esphome.const import CONF_CHANNEL, CONF_ID, CONF_SAMPLE_RATE
|
11
|
+
from esphome.const import CONF_BITS_PER_SAMPLE, CONF_CHANNEL, CONF_ID, CONF_SAMPLE_RATE
|
12
12
|
from esphome.cpp_generator import MockObjClass
|
13
13
|
import esphome.final_validate as fv
|
14
14
|
|
@@ -25,13 +25,11 @@ CONF_I2S_LRCLK_PIN = "i2s_lrclk_pin"
|
|
25
25
|
CONF_I2S_AUDIO = "i2s_audio"
|
26
26
|
CONF_I2S_AUDIO_ID = "i2s_audio_id"
|
27
27
|
|
28
|
-
CONF_BITS_PER_SAMPLE = "bits_per_sample"
|
29
28
|
CONF_I2S_MODE = "i2s_mode"
|
30
29
|
CONF_PRIMARY = "primary"
|
31
30
|
CONF_SECONDARY = "secondary"
|
32
31
|
|
33
32
|
CONF_USE_APLL = "use_apll"
|
34
|
-
CONF_BITS_PER_SAMPLE = "bits_per_sample"
|
35
33
|
CONF_BITS_PER_CHANNEL = "bits_per_channel"
|
36
34
|
CONF_MONO = "mono"
|
37
35
|
CONF_LEFT = "left"
|
@@ -16,16 +16,18 @@ from .. import (
|
|
16
16
|
register_i2s_audio_component,
|
17
17
|
)
|
18
18
|
|
19
|
-
|
19
|
+
AUTO_LOAD = ["audio"]
|
20
|
+
CODEOWNERS = ["@jesserockz", "@kahrendt"]
|
20
21
|
DEPENDENCIES = ["i2s_audio"]
|
21
22
|
|
22
23
|
I2SAudioSpeaker = i2s_audio_ns.class_(
|
23
24
|
"I2SAudioSpeaker", cg.Component, speaker.Speaker, I2SAudioOut
|
24
25
|
)
|
25
26
|
|
26
|
-
|
27
|
+
CONF_BUFFER_DURATION = "buffer_duration"
|
27
28
|
CONF_DAC_TYPE = "dac_type"
|
28
29
|
CONF_I2S_COMM_FMT = "i2s_comm_fmt"
|
30
|
+
CONF_NEVER = "never"
|
29
31
|
|
30
32
|
i2s_dac_mode_t = cg.global_ns.enum("i2s_dac_mode_t")
|
31
33
|
INTERNAL_DAC_OPTIONS = {
|
@@ -72,8 +74,12 @@ BASE_SCHEMA = (
|
|
72
74
|
.extend(
|
73
75
|
{
|
74
76
|
cv.Optional(
|
75
|
-
|
77
|
+
CONF_BUFFER_DURATION, default="500ms"
|
76
78
|
): cv.positive_time_period_milliseconds,
|
79
|
+
cv.Optional(CONF_TIMEOUT, default="500ms"): cv.Any(
|
80
|
+
cv.positive_time_period_milliseconds,
|
81
|
+
cv.one_of(CONF_NEVER, lower=True),
|
82
|
+
),
|
77
83
|
}
|
78
84
|
)
|
79
85
|
.extend(cv.COMPONENT_SCHEMA)
|
@@ -115,4 +121,6 @@ async def to_code(config):
|
|
115
121
|
else:
|
116
122
|
cg.add(var.set_dout_pin(config[CONF_I2S_DOUT_PIN]))
|
117
123
|
cg.add(var.set_i2s_comm_fmt(config[CONF_I2S_COMM_FMT]))
|
118
|
-
|
124
|
+
if config[CONF_TIMEOUT] != CONF_NEVER:
|
125
|
+
cg.add(var.set_timeout(config[CONF_TIMEOUT]))
|
126
|
+
cg.add(var.set_buffer_duration(config[CONF_BUFFER_DURATION]))
|