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.
Files changed (239) hide show
  1. esphome/__main__.py +22 -4
  2. esphome/automation.py +29 -2
  3. esphome/components/animation/__init__.py +5 -8
  4. esphome/components/animation/animation.cpp +1 -1
  5. esphome/components/audio/__init__.py +9 -0
  6. esphome/components/audio/audio.h +21 -0
  7. esphome/components/axs15231/__init__.py +6 -0
  8. esphome/components/axs15231/touchscreen/__init__.py +36 -0
  9. esphome/components/axs15231/touchscreen/axs15231_touchscreen.cpp +64 -0
  10. esphome/components/axs15231/touchscreen/axs15231_touchscreen.h +27 -0
  11. esphome/components/bme68x_bsec2/__init__.py +1 -1
  12. esphome/components/bme68x_bsec2/bme68x_bsec2.cpp +50 -47
  13. esphome/components/bme68x_bsec2/bme68x_bsec2.h +0 -2
  14. esphome/components/bytebuffer/__init__.py +5 -0
  15. esphome/components/bytebuffer/bytebuffer.h +421 -0
  16. esphome/components/climate/__init__.py +14 -13
  17. esphome/components/datetime/__init__.py +3 -3
  18. esphome/components/debug/debug_esp32.cpp +16 -8
  19. esphome/components/dfplayer/dfplayer.cpp +132 -6
  20. esphome/components/dfplayer/dfplayer.h +19 -53
  21. esphome/components/display/display.cpp +142 -0
  22. esphome/components/display/display.h +7 -0
  23. esphome/components/es8311/__init__.py +0 -0
  24. esphome/components/es8311/audio_dac.py +70 -0
  25. esphome/components/es8311/es8311.cpp +227 -0
  26. esphome/components/es8311/es8311.h +135 -0
  27. esphome/components/es8311/es8311_const.h +195 -0
  28. esphome/components/esp32/boards.py +199 -1
  29. esphome/components/esp32/gpio.py +3 -1
  30. esphome/components/esp32_ble/const_esp32c6.h +7 -0
  31. esphome/components/esp32_ble_client/ble_client_base.h +1 -1
  32. esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +3 -0
  33. esphome/components/esp32_ble_tracker/esp32_ble_tracker.h +2 -1
  34. esphome/components/esp32_rmt_led_strip/led_strip.cpp +2 -2
  35. esphome/components/esp32_rmt_led_strip/led_strip.h +2 -0
  36. esphome/components/esp32_rmt_led_strip/light.py +3 -1
  37. esphome/components/esp8266/gpio.py +7 -5
  38. esphome/components/ethernet/__init__.py +55 -1
  39. esphome/components/ethernet/ethernet_component.cpp +14 -1
  40. esphome/components/ethernet/ethernet_component.h +7 -1
  41. esphome/components/font/__init__.py +213 -108
  42. esphome/components/gp8403/output/__init__.py +1 -1
  43. esphome/components/host/gpio.py +6 -4
  44. esphome/components/http_request/__init__.py +12 -0
  45. esphome/components/http_request/http_request.h +65 -3
  46. esphome/components/http_request/http_request_arduino.cpp +4 -3
  47. esphome/components/http_request/http_request_idf.cpp +12 -14
  48. esphome/components/http_request/ota/ota_http_request.cpp +1 -1
  49. esphome/components/http_request/update/http_request_update.cpp +1 -1
  50. esphome/components/i2c_device/__init__.py +26 -0
  51. esphome/components/i2c_device/i2c_device.cpp +17 -0
  52. esphome/components/i2c_device/i2c_device.h +18 -0
  53. esphome/components/i2s_audio/__init__.py +1 -3
  54. esphome/components/i2s_audio/speaker/__init__.py +12 -4
  55. esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +426 -200
  56. esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +92 -33
  57. esphome/components/ili9xxx/display.py +5 -1
  58. esphome/components/image/__init__.py +5 -8
  59. esphome/components/image/image.cpp +14 -14
  60. esphome/components/image/image.h +20 -24
  61. esphome/components/internal_temperature/internal_temperature.cpp +51 -2
  62. esphome/components/internal_temperature/internal_temperature.h +1 -0
  63. esphome/components/ld2420/ld2420.cpp +1 -1
  64. esphome/components/libretiny/gpio.py +4 -2
  65. esphome/components/light/__init__.py +32 -1
  66. esphome/components/light/automation.py +39 -32
  67. esphome/components/light/effects.py +36 -36
  68. esphome/components/light/light_state.cpp +6 -16
  69. esphome/components/light/light_state.h +34 -0
  70. esphome/components/light/types.py +3 -1
  71. esphome/components/logger/logger_esp32.cpp +15 -0
  72. esphome/components/lvgl/__init__.py +202 -95
  73. esphome/components/lvgl/automation.py +42 -40
  74. esphome/components/lvgl/binary_sensor/__init__.py +8 -15
  75. esphome/components/lvgl/defines.py +14 -8
  76. esphome/components/lvgl/encoders.py +11 -8
  77. esphome/components/lvgl/keypads.py +77 -0
  78. esphome/components/lvgl/light/__init__.py +6 -8
  79. esphome/components/lvgl/lv_validation.py +2 -4
  80. esphome/components/lvgl/lvcode.py +3 -9
  81. esphome/components/lvgl/lvgl_esphome.cpp +210 -89
  82. esphome/components/lvgl/lvgl_esphome.h +113 -30
  83. esphome/components/lvgl/lvgl_proxy.h +17 -0
  84. esphome/components/lvgl/number/__init__.py +10 -15
  85. esphome/components/lvgl/schemas.py +4 -2
  86. esphome/components/lvgl/select/__init__.py +12 -37
  87. esphome/components/lvgl/select/lvgl_select.h +27 -33
  88. esphome/components/lvgl/sensor/__init__.py +8 -14
  89. esphome/components/lvgl/styles.py +3 -4
  90. esphome/components/lvgl/switch/__init__.py +8 -13
  91. esphome/components/lvgl/text/__init__.py +5 -6
  92. esphome/components/lvgl/text_sensor/__init__.py +15 -15
  93. esphome/components/lvgl/touchscreens.py +2 -3
  94. esphome/components/lvgl/trigger.py +7 -9
  95. esphome/components/lvgl/types.py +9 -3
  96. esphome/components/lvgl/widgets/__init__.py +32 -21
  97. esphome/components/lvgl/widgets/animimg.py +4 -3
  98. esphome/components/lvgl/widgets/dropdown.py +22 -10
  99. esphome/components/lvgl/widgets/img.py +2 -0
  100. esphome/components/lvgl/widgets/msgbox.py +6 -5
  101. esphome/components/lvgl/widgets/obj.py +4 -2
  102. esphome/components/lvgl/widgets/page.py +3 -2
  103. esphome/components/lvgl/widgets/qrcode.py +54 -0
  104. esphome/components/lvgl/widgets/roller.py +21 -14
  105. esphome/components/lvgl/widgets/tileview.py +2 -1
  106. esphome/components/max17043/__init__.py +1 -0
  107. esphome/components/max17043/automation.h +20 -0
  108. esphome/components/max17043/max17043.cpp +98 -0
  109. esphome/components/max17043/max17043.h +29 -0
  110. esphome/components/max17043/sensor.py +77 -0
  111. esphome/components/media_player/__init__.py +11 -0
  112. esphome/components/media_player/automation.h +10 -0
  113. esphome/components/media_player/media_player.cpp +4 -0
  114. esphome/components/midea/air_conditioner.cpp +17 -1
  115. esphome/components/mlx90393/sensor.py +1 -1
  116. esphome/components/modbus/modbus.cpp +24 -12
  117. esphome/components/modbus_controller/__init__.py +31 -1
  118. esphome/components/modbus_controller/automation.h +16 -0
  119. esphome/components/modbus_controller/const.py +2 -0
  120. esphome/components/modbus_controller/modbus_controller.cpp +14 -2
  121. esphome/components/modbus_controller/modbus_controller.h +9 -0
  122. esphome/components/mopeka_pro_check/mopeka_pro_check.cpp +40 -21
  123. esphome/components/mopeka_pro_check/mopeka_pro_check.h +9 -2
  124. esphome/components/mopeka_pro_check/sensor.py +41 -0
  125. esphome/components/mqtt/__init__.py +36 -0
  126. esphome/components/mqtt/mqtt_client.cpp +27 -3
  127. esphome/components/mqtt/mqtt_client.h +27 -2
  128. esphome/components/mqtt/mqtt_climate.cpp +4 -2
  129. esphome/components/mqtt/mqtt_component.cpp +6 -0
  130. esphome/components/mqtt/mqtt_component.h +4 -0
  131. esphome/components/mqtt/mqtt_const.h +6 -0
  132. esphome/components/online_image/online_image.cpp +2 -8
  133. esphome/components/online_image/online_image.h +2 -6
  134. esphome/components/opentherm/__init__.py +35 -9
  135. esphome/components/opentherm/binary_sensor/__init__.py +33 -0
  136. esphome/components/opentherm/const.py +11 -0
  137. esphome/components/opentherm/generate.py +142 -0
  138. esphome/components/opentherm/hub.cpp +130 -24
  139. esphome/components/opentherm/hub.h +62 -9
  140. esphome/components/opentherm/input.h +18 -0
  141. esphome/components/opentherm/input.py +51 -0
  142. esphome/components/opentherm/number/__init__.py +74 -0
  143. esphome/components/opentherm/number/number.cpp +40 -0
  144. esphome/components/opentherm/number/number.h +31 -0
  145. esphome/components/opentherm/opentherm.cpp +30 -0
  146. esphome/components/opentherm/opentherm.h +34 -2
  147. esphome/components/opentherm/opentherm_macros.h +151 -0
  148. esphome/components/opentherm/output/__init__.py +47 -0
  149. esphome/components/opentherm/output/output.cpp +18 -0
  150. esphome/components/opentherm/output/output.h +33 -0
  151. esphome/components/opentherm/schema.py +814 -0
  152. esphome/components/opentherm/sensor/__init__.py +51 -0
  153. esphome/components/opentherm/switch/__init__.py +43 -0
  154. esphome/components/opentherm/switch/switch.cpp +28 -0
  155. esphome/components/opentherm/switch/switch.h +20 -0
  156. esphome/components/opentherm/validate.py +31 -0
  157. esphome/components/pcd8544/display.py +8 -4
  158. esphome/components/prometheus/prometheus_handler.cpp +176 -14
  159. esphome/components/prometheus/prometheus_handler.h +25 -7
  160. esphome/components/qspi_amoled/display.py +1 -141
  161. esphome/components/qspi_dbi/display.py +185 -0
  162. esphome/components/qspi_dbi/models.py +64 -0
  163. esphome/components/{qspi_amoled/qspi_amoled.cpp → qspi_dbi/qspi_dbi.cpp} +95 -46
  164. esphome/components/{qspi_amoled/qspi_amoled.h → qspi_dbi/qspi_dbi.h} +26 -15
  165. esphome/components/rp2040/__init__.py +6 -3
  166. esphome/components/rp2040/gpio.py +5 -3
  167. esphome/components/rpi_dpi_rgb/rpi_dpi_rgb.cpp +20 -0
  168. esphome/components/rpi_dpi_rgb/rpi_dpi_rgb.h +3 -2
  169. esphome/components/rtttl/rtttl.cpp +4 -1
  170. esphome/components/rtttl/rtttl.h +1 -0
  171. esphome/components/sdl/sdl_esphome.cpp +22 -5
  172. esphome/components/sdl/sdl_esphome.h +1 -0
  173. esphome/components/sdm_meter/sdm_meter.cpp +1 -1
  174. esphome/components/sensor/__init__.py +18 -8
  175. esphome/components/sensor/filter.cpp +19 -18
  176. esphome/components/sensor/filter.h +9 -10
  177. esphome/components/sgp4x/sgp4x.cpp +40 -74
  178. esphome/components/sgp4x/sgp4x.h +5 -3
  179. esphome/components/speaker/__init__.py +51 -5
  180. esphome/components/speaker/automation.h +25 -0
  181. esphome/components/speaker/speaker.h +72 -1
  182. esphome/components/spi/__init__.py +15 -14
  183. esphome/components/spi_device/__init__.py +4 -15
  184. esphome/components/ssd1306_spi/display.py +6 -2
  185. esphome/components/ssd1322_spi/display.py +6 -2
  186. esphome/components/ssd1325_spi/display.py +6 -2
  187. esphome/components/ssd1327_spi/display.py +6 -2
  188. esphome/components/ssd1331_spi/display.py +6 -2
  189. esphome/components/ssd1351_spi/display.py +6 -2
  190. esphome/components/st7567_spi/display.py +6 -2
  191. esphome/components/st7701s/display.py +5 -1
  192. esphome/components/st7735/display.py +10 -5
  193. esphome/components/st7789v/display.py +12 -7
  194. esphome/components/statsd/statsd.cpp +2 -0
  195. esphome/components/statsd/statsd.h +2 -0
  196. esphome/components/sun/sun.h +3 -0
  197. esphome/components/tc74/__init__.py +1 -0
  198. esphome/components/tc74/sensor.py +32 -0
  199. esphome/components/tc74/tc74.cpp +68 -0
  200. esphome/components/tc74/tc74.h +28 -0
  201. esphome/components/touchscreen/__init__.py +41 -50
  202. esphome/components/touchscreen/touchscreen.h +4 -8
  203. esphome/components/tuya/fan/tuya_fan.cpp +1 -1
  204. esphome/components/udp/udp_component.cpp +6 -3
  205. esphome/components/udp/udp_component.h +4 -2
  206. esphome/components/waveshare_epaper/display.py +6 -2
  207. esphome/components/web_server/web_server.cpp +22 -0
  208. esphome/components/web_server/web_server.h +3 -0
  209. esphome/components/weikai/weikai.h +2 -2
  210. esphome/components/wifi/wifi_component.cpp +2 -2
  211. esphome/components/wifi/wifi_component_esp32_arduino.cpp +4 -4
  212. esphome/components/wifi/wifi_component_esp8266.cpp +4 -4
  213. esphome/components/wifi/wifi_component_esp_idf.cpp +2 -2
  214. esphome/components/xpt2046/touchscreen/__init__.py +7 -32
  215. esphome/config_validation.py +3 -1
  216. esphome/const.py +9 -2
  217. esphome/core/defines.h +8 -2
  218. esphome/core/helpers.cpp +32 -17
  219. esphome/core/helpers.h +32 -16
  220. esphome/core/ring_buffer.cpp +2 -2
  221. esphome/core/ring_buffer.h +2 -2
  222. esphome/dashboard/core.py +25 -0
  223. esphome/dashboard/status/mdns.py +3 -4
  224. esphome/dashboard/web_server.py +54 -19
  225. esphome/espota2.py +36 -35
  226. esphome/helpers.py +68 -16
  227. esphome/mqtt.py +9 -2
  228. esphome/storage_json.py +4 -0
  229. esphome/writer.py +7 -18
  230. esphome/zeroconf.py +8 -6
  231. {esphome-2024.10.2.dist-info → esphome-2024.11.0.dist-info}/METADATA +7 -5
  232. {esphome-2024.10.2.dist-info → esphome-2024.11.0.dist-info}/RECORD +237 -191
  233. esphome/core/bytebuffer.cpp +0 -167
  234. esphome/core/bytebuffer.h +0 -144
  235. /esphome/components/{qspi_amoled → qspi_dbi}/__init__.py +0 -0
  236. {esphome-2024.10.2.dist-info → esphome-2024.11.0.dist-info}/LICENSE +0 -0
  237. {esphome-2024.10.2.dist-info → esphome-2024.11.0.dist-info}/WHEEL +0 -0
  238. {esphome-2024.10.2.dist-info → esphome-2024.11.0.dist-info}/entry_points.txt +0 -0
  239. {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 < 200 || container->status_code >= 300) {
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->end();
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
- auto is_ok = [](int code) { return code >= HttpStatus_Ok && code < HttpStatus_MultipleChoices; };
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
- if (is_ok(container->status_code)) {
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 url[256]{};
146
- if (esp_http_client_get_url(client, url, sizeof(url) - 1) == ESP_OK) {
147
- ESP_LOGV(TAG, "redirecting to url: %s", url);
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
- if (is_ok(container->status_code)) {
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
- esp_http_client_cleanup(client);
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
- CODEOWNERS = ["@jesserockz"]
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
- CONF_TIMEOUT, default="100ms"
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
- cg.add(var.set_timeout(config[CONF_TIMEOUT]))
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]))