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