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.
- 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/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.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 +2 -3
- esphome/components/http_request/http_request_idf.cpp +6 -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 +432 -197
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +91 -32
- 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/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/dropdown.py +22 -10
- 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_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/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/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/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 +8 -1
- 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.3.dist-info → esphome-2024.11.0b1.dist-info}/METADATA +7 -5
- {esphome-2024.10.3.dist-info → esphome-2024.11.0b1.dist-info}/RECORD +226 -180
- 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.3.dist-info → esphome-2024.11.0b1.dist-info}/LICENSE +0 -0
- {esphome-2024.10.3.dist-info → esphome-2024.11.0b1.dist-info}/WHEEL +0 -0
- {esphome-2024.10.3.dist-info → esphome-2024.11.0b1.dist-info}/entry_points.txt +0 -0
- {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
|
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
|
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 (
|
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
|
146
|
-
if (esp_http_client_get_url(client,
|
147
|
-
ESP_LOGV(TAG, "redirecting to url: %s",
|
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 (
|
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
|
-
|
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
|
-
|
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]))
|