1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-01 15:41:52 +00:00

Compare commits

...

17 Commits

Author SHA1 Message Date
Jesse Hills
b59666c512 Merge pull request #5958 from esphome/bump-2023.12.0b3
2023.12.0b3
2023-12-18 17:32:02 +09:00
Jesse Hills
dbfa77cb4b Bump version to 2023.12.0b3 2023-12-18 16:51:11 +09:00
Keith Burzinski
ab22a3da34 Use the correct UART/Serial when CDC is enabled (#5957) 2023-12-18 16:51:11 +09:00
Jean Louis-Guerin
eefa1cd3ab Revert pure virtual functions in UART component from #5920 (#5932)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
2023-12-18 16:51:10 +09:00
dentra
d0df73769d web_server_idf: fix call with hardcoded http code (#5942) 2023-12-18 16:51:10 +09:00
Alex Hermann
e8ce780482 esp32_camera: Set framebuffer task prio to 1 (#5943) 2023-12-18 16:51:10 +09:00
Alex Hermann
168e704130 i2s_audio: Set player_task's prio to 1 (#5945) 2023-12-18 16:51:10 +09:00
Grant Le Roux
2309f15ce0 Fix - Tuya Fan - Allow integer speed datapoint (#5948)
Co-authored-by: Cram42 <5396871+cram42@users.noreply.github.com>
2023-12-18 16:51:10 +09:00
Edward Firmo
917e0f93ed UARTComponent inline doc (#5930) 2023-12-18 16:51:10 +09:00
dependabot[bot]
70dac54113 Bump zeroconf from 0.128.4 to 0.130.0 (#5950)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-18 16:51:10 +09:00
Jesse Hills
2270c3050e Merge pull request #5940 from esphome/bump-2023.12.0b2
2023.12.0b2
2023-12-15 15:26:30 +09:00
Jesse Hills
514db8b26e Bump version to 2023.12.0b2 2023-12-15 15:02:47 +09:00
mrtoy-me
e030c0fc45 Update ENS160 TVOC device_class and AQI units to match required by HA (#5939) 2023-12-15 15:02:46 +09:00
Jesse Hills
6b5eb7e656 Fix SplitDefault with variants (#5928) 2023-12-15 15:02:46 +09:00
jochenvg
f28cf9348e Support toggle action for template cover (#5917) 2023-12-15 15:02:46 +09:00
Fabian
3e475c21ff [Logger] ESP32 S3 serial logger (#4853)
* Add support for ESP32 S3 logger.

* fix default

* Remove cpp & h changes to combine with PR #4658

* Not enough attention to details.

* Add build flag

* Validation fix

* Fix validation for real this time

---------

Co-authored-by: Your Name <you@example.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
2023-12-15 15:02:46 +09:00
Jesse Hills
3c3ac92038 Allow use of CDC/JTAG loggers on esp32 variants with Arduino (#4658)
* Allow use of CDC/JTAG loggers on esp32 variants with Arduino

* Only on s2/s3

* Separate C3 from S2/S3

* C code builds & runs correctly, still needs work though

* Works on S2

* It works!

* Remove unnecessary header

---------

Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
2023-12-15 15:02:46 +09:00
16 changed files with 220 additions and 32 deletions

View File

@@ -9,7 +9,7 @@ from esphome.const import (
CONF_TVOC,
DEVICE_CLASS_AQI,
DEVICE_CLASS_CARBON_DIOXIDE,
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
ICON_CHEMICAL_WEAPON,
ICON_MOLECULE_CO2,
ICON_RADIATOR,
@@ -45,11 +45,10 @@ CONFIG_SCHEMA = (
unit_of_measurement=UNIT_PARTS_PER_BILLION,
icon=ICON_RADIATOR,
accuracy_decimals=0,
device_class=DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
device_class=DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
state_class=STATE_CLASS_MEASUREMENT,
),
cv.Required(CONF_AQI): sensor.sensor_schema(
unit_of_measurement=UNIT_INDEX,
icon=ICON_CHEMICAL_WEAPON,
accuracy_decimals=0,
device_class=DEVICE_CLASS_AQI,

View File

@@ -37,7 +37,7 @@ void ESP32Camera::setup() {
"framebuffer_task", // name
1024, // stack size
nullptr, // task pv params
0, // priority
1, // priority
nullptr, // handle
1 // core
);

View File

@@ -29,7 +29,7 @@ void I2SAudioSpeaker::start_() {
}
this->state_ = speaker::STATE_RUNNING;
xTaskCreate(I2SAudioSpeaker::player_task, "speaker_task", 8192, (void *) this, 0, &this->player_task_handle_);
xTaskCreate(I2SAudioSpeaker::player_task, "speaker_task", 8192, (void *) this, 1, &this->player_task_handle_);
}
void I2SAudioSpeaker::player_task(void *params) {

View File

@@ -97,7 +97,7 @@ UART_SELECTION_LIBRETINY = {
COMPONENT_RTL87XX: [DEFAULT, UART0, UART1, UART2],
}
ESP_IDF_UARTS = [USB_CDC, USB_SERIAL_JTAG]
ESP_ARDUINO_UNSUPPORTED_USB_UARTS = [USB_SERIAL_JTAG]
UART_SELECTION_RP2040 = [USB_CDC, UART0, UART1]
@@ -124,8 +124,8 @@ is_log_level = cv.one_of(*LOG_LEVELS, upper=True)
def uart_selection(value):
if CORE.is_esp32:
if value.upper() in ESP_IDF_UARTS and not CORE.using_esp_idf:
raise cv.Invalid(f"Only esp-idf framework supports {value}.")
if CORE.using_arduino and value.upper() in ESP_ARDUINO_UNSUPPORTED_USB_UARTS:
raise cv.Invalid(f"Arduino framework does not support {value}.")
variant = get_esp32_variant()
if variant in UART_SELECTION_ESP32:
return cv.one_of(*UART_SELECTION_ESP32[variant], upper=True)(value)
@@ -171,6 +171,8 @@ CONFIG_SCHEMA = cv.All(
CONF_HARDWARE_UART,
esp8266=UART0,
esp32=UART0,
esp32_s2=USB_CDC,
esp32_s3=USB_CDC,
rp2040=USB_CDC,
bk72xx=DEFAULT,
rtl87xx=DEFAULT,
@@ -258,6 +260,10 @@ async def to_code(config):
if config.get(CONF_ESP8266_STORE_LOG_STRINGS_IN_FLASH):
cg.add_build_flag("-DUSE_STORE_LOG_STR_IN_FLASH")
if CORE.using_arduino:
if config[CONF_HARDWARE_UART] == USB_CDC:
cg.add_build_flag("-DARDUINO_USB_CDC_ON_BOOT=1")
if CORE.using_esp_idf:
if config[CONF_HARDWARE_UART] == USB_CDC:
add_idf_sdkconfig_option("CONFIG_ESP_CONSOLE_USB_CDC", True)

View File

@@ -235,10 +235,15 @@ void Logger::pre_setup() {
#ifdef USE_RP2040
this->hw_serial_ = &Serial1;
Serial1.begin(this->baud_rate_);
#else
#if ARDUINO_USB_CDC_ON_BOOT
this->hw_serial_ = &Serial0;
Serial0.begin(this->baud_rate_);
#else
this->hw_serial_ = &Serial;
Serial.begin(this->baud_rate_);
#endif
#endif
#ifdef USE_ESP8266
if (this->uart_ == UART_SELECTION_UART0_SWAP) {
Serial.swap();
@@ -265,12 +270,35 @@ void Logger::pre_setup() {
Serial2.begin(this->baud_rate_);
break;
#endif
#if defined(USE_ESP32) && \
(defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32C3))
#if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3)
case UART_SELECTION_USB_CDC:
#endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S3)
case UART_SELECTION_USB_SERIAL_JTAG:
#endif // USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32S3
#ifdef USE_ESP32_VARIANT_ESP32C3
this->hw_serial_ = &Serial;
Serial.begin(this->baud_rate_);
#endif // USE_ESP32_VARIANT_ESP32C3
#if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3)
#if ARDUINO_USB_CDC_ON_BOOT
this->hw_serial_ = &Serial;
Serial.begin(this->baud_rate_);
#else
this->hw_serial_ = &Serial;
Serial.begin(this->baud_rate_);
#endif // ARDUINO_USB_CDC_ON_BOOT
#endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3
break;
#endif // USE_ESP32 && (USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3 || USE_ESP32_VARIANT_ESP32C3)
#ifdef USE_RP2040
case UART_SELECTION_USB_CDC:
this->hw_serial_ = &Serial;
Serial.begin(this->baud_rate_);
break;
#endif
#endif // USE_RP2040
}
#endif // USE_ARDUINO
#ifdef USE_ESP_IDF
@@ -393,14 +421,12 @@ const char *const UART_SELECTIONS[] = {
"UART2",
#endif // !USE_ESP32_VARIANT_ESP32C3 && !USE_ESP32_VARINT_ESP32C6 && !USE_ESP32_VARIANT_ESP32S2 &&
// !USE_ESP32_VARIANT_ESP32S3 && !USE_ESP32_VARIANT_ESP32H2
#if defined(USE_ESP_IDF)
#if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3)
"USB_CDC",
#endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S3)
"USB_SERIAL_JTAG",
#endif // USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32S3
#endif // USE_ESP_IDF
};
#endif // USE_ESP32
#ifdef USE_ESP8266

View File

@@ -45,7 +45,6 @@ enum UARTSelection {
UART_SELECTION_UART2,
#endif // !USE_ESP32_VARIANT_ESP32C3 && !USE_ESP32_VARIANT_ESP32C6 && !USE_ESP32_VARIANT_ESP32S2 &&
// !USE_ESP32_VARIANT_ESP32S3 && !USE_ESP32_VARIANT_ESP32H2
#ifdef USE_ESP_IDF
#if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3)
UART_SELECTION_USB_CDC,
#endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3
@@ -54,7 +53,6 @@ enum UARTSelection {
UART_SELECTION_USB_SERIAL_JTAG,
#endif // USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32C6 || USE_ESP32_VARIANT_ESP32S3 ||
// USE_ESP32_VARIANT_ESP32H2
#endif // USE_ESP_IDF
#endif // USE_ESP32
#ifdef USE_ESP8266
UART_SELECTION_UART0_SWAP,

View File

@@ -31,6 +31,7 @@ RESTORE_MODES = {
}
CONF_HAS_POSITION = "has_position"
CONF_TOGGLE_ACTION = "toggle_action"
CONFIG_SCHEMA = cover.COVER_SCHEMA.extend(
{
@@ -44,6 +45,7 @@ CONFIG_SCHEMA = cover.COVER_SCHEMA.extend(
cv.Optional(CONF_STOP_ACTION): automation.validate_automation(single=True),
cv.Optional(CONF_TILT_ACTION): automation.validate_automation(single=True),
cv.Optional(CONF_TILT_LAMBDA): cv.returning_lambda,
cv.Optional(CONF_TOGGLE_ACTION): automation.validate_automation(single=True),
cv.Optional(CONF_POSITION_ACTION): automation.validate_automation(single=True),
cv.Optional(CONF_RESTORE_MODE, default="RESTORE"): cv.enum(
RESTORE_MODES, upper=True
@@ -74,6 +76,11 @@ async def to_code(config):
var.get_stop_trigger(), [], config[CONF_STOP_ACTION]
)
cg.add(var.set_has_stop(True))
if CONF_TOGGLE_ACTION in config:
await automation.build_automation(
var.get_toggle_trigger(), [], config[CONF_TOGGLE_ACTION]
)
cg.add(var.set_has_toggle(True))
if CONF_TILT_ACTION in config:
await automation.build_automation(
var.get_tilt_trigger(), [(float, "tilt")], config[CONF_TILT_ACTION]

View File

@@ -12,6 +12,7 @@ TemplateCover::TemplateCover()
: open_trigger_(new Trigger<>()),
close_trigger_(new Trigger<>),
stop_trigger_(new Trigger<>()),
toggle_trigger_(new Trigger<>()),
position_trigger_(new Trigger<float>()),
tilt_trigger_(new Trigger<float>()) {}
void TemplateCover::setup() {
@@ -68,6 +69,7 @@ float TemplateCover::get_setup_priority() const { return setup_priority::HARDWAR
Trigger<> *TemplateCover::get_open_trigger() const { return this->open_trigger_; }
Trigger<> *TemplateCover::get_close_trigger() const { return this->close_trigger_; }
Trigger<> *TemplateCover::get_stop_trigger() const { return this->stop_trigger_; }
Trigger<> *TemplateCover::get_toggle_trigger() const { return this->toggle_trigger_; }
void TemplateCover::dump_config() { LOG_COVER("", "Template Cover", this); }
void TemplateCover::control(const CoverCall &call) {
if (call.get_stop()) {
@@ -76,6 +78,12 @@ void TemplateCover::control(const CoverCall &call) {
this->prev_command_trigger_ = this->stop_trigger_;
this->publish_state();
}
if (call.get_toggle().has_value()) {
this->stop_prev_trigger_();
this->toggle_trigger_->trigger();
this->prev_command_trigger_ = this->toggle_trigger_;
this->publish_state();
}
if (call.get_position().has_value()) {
auto pos = *call.get_position();
this->stop_prev_trigger_();
@@ -110,6 +118,7 @@ CoverTraits TemplateCover::get_traits() {
auto traits = CoverTraits();
traits.set_is_assumed_state(this->assumed_state_);
traits.set_supports_stop(this->has_stop_);
traits.set_supports_toggle(this->has_toggle_);
traits.set_supports_position(this->has_position_);
traits.set_supports_tilt(this->has_tilt_);
return traits;
@@ -118,6 +127,7 @@ Trigger<float> *TemplateCover::get_position_trigger() const { return this->posit
Trigger<float> *TemplateCover::get_tilt_trigger() const { return this->tilt_trigger_; }
void TemplateCover::set_tilt_lambda(std::function<optional<float>()> &&tilt_f) { this->tilt_f_ = tilt_f; }
void TemplateCover::set_has_stop(bool has_stop) { this->has_stop_ = has_stop; }
void TemplateCover::set_has_toggle(bool has_toggle) { this->has_toggle_ = has_toggle; }
void TemplateCover::set_has_position(bool has_position) { this->has_position_ = has_position; }
void TemplateCover::set_has_tilt(bool has_tilt) { this->has_tilt_ = has_tilt; }
void TemplateCover::stop_prev_trigger_() {

View File

@@ -21,6 +21,7 @@ class TemplateCover : public cover::Cover, public Component {
Trigger<> *get_open_trigger() const;
Trigger<> *get_close_trigger() const;
Trigger<> *get_stop_trigger() const;
Trigger<> *get_toggle_trigger() const;
Trigger<float> *get_position_trigger() const;
Trigger<float> *get_tilt_trigger() const;
void set_optimistic(bool optimistic);
@@ -29,6 +30,7 @@ class TemplateCover : public cover::Cover, public Component {
void set_has_stop(bool has_stop);
void set_has_position(bool has_position);
void set_has_tilt(bool has_tilt);
void set_has_toggle(bool has_toggle);
void set_restore_mode(TemplateCoverRestoreMode restore_mode) { restore_mode_ = restore_mode; }
void setup() override;
@@ -50,7 +52,9 @@ class TemplateCover : public cover::Cover, public Component {
Trigger<> *open_trigger_;
Trigger<> *close_trigger_;
bool has_stop_{false};
bool has_toggle_{false};
Trigger<> *stop_trigger_;
Trigger<> *toggle_trigger_;
Trigger<> *prev_command_trigger_{nullptr};
Trigger<float> *position_trigger_;
bool has_position_{false};

View File

@@ -9,13 +9,20 @@ static const char *const TAG = "tuya.fan";
void TuyaFan::setup() {
if (this->speed_id_.has_value()) {
this->parent_->register_listener(*this->speed_id_, [this](const TuyaDatapoint &datapoint) {
ESP_LOGV(TAG, "MCU reported speed of: %d", datapoint.value_enum);
if (datapoint.value_enum >= this->speed_count_) {
ESP_LOGE(TAG, "Speed has invalid value %d", datapoint.value_enum);
} else {
this->speed = datapoint.value_enum + 1;
if (datapoint.type == TuyaDatapointType::ENUM) {
ESP_LOGV(TAG, "MCU reported speed of: %d", datapoint.value_enum);
if (datapoint.value_enum >= this->speed_count_) {
ESP_LOGE(TAG, "Speed has invalid value %d", datapoint.value_enum);
} else {
this->speed = datapoint.value_enum + 1;
this->publish_state();
}
} else if (datapoint.type == TuyaDatapointType::INTEGER) {
ESP_LOGV(TAG, "MCU reported speed of: %d", datapoint.value_int);
this->speed = datapoint.value_int;
this->publish_state();
}
this->speed_type_ = datapoint.type;
});
}
if (this->switch_id_.has_value()) {
@@ -80,7 +87,11 @@ void TuyaFan::control(const fan::FanCall &call) {
this->parent_->set_enum_datapoint_value(*this->direction_id_, enable);
}
if (this->speed_id_.has_value() && call.get_speed().has_value()) {
this->parent_->set_enum_datapoint_value(*this->speed_id_, *call.get_speed() - 1);
if (this->speed_type_ == TuyaDatapointType::ENUM) {
this->parent_->set_enum_datapoint_value(*this->speed_id_, *call.get_speed() - 1);
} else if (this->speed_type_ == TuyaDatapointType::INTEGER) {
this->parent_->set_integer_datapoint_value(*this->speed_id_, *call.get_speed());
}
}
}

View File

@@ -28,6 +28,7 @@ class TuyaFan : public Component, public fan::Fan {
optional<uint8_t> oscillation_id_{};
optional<uint8_t> direction_id_{};
int speed_count_{};
TuyaDatapointType speed_type_{};
};
} // namespace tuya

View File

@@ -31,40 +31,122 @@ const LogString *parity_to_str(UARTParityOptions parity);
class UARTComponent {
public:
// Writes an array of bytes to the UART bus.
// @param data A vector of bytes to be written.
void write_array(const std::vector<uint8_t> &data) { this->write_array(&data[0], data.size()); }
// Writes a single byte to the UART bus.
// @param data The byte to be written.
void write_byte(uint8_t data) { this->write_array(&data, 1); };
// Writes a null-terminated string to the UART bus.
// @param str Pointer to the null-terminated string.
void write_str(const char *str) {
const auto *data = reinterpret_cast<const uint8_t *>(str);
this->write_array(data, strlen(str));
};
// Pure virtual method to write an array of bytes to the UART bus.
// @param data Pointer to the array of bytes.
// @param len Length of the array.
virtual void write_array(const uint8_t *data, size_t len) = 0;
// Reads a single byte from the UART bus.
// @param data Pointer to the byte where the read data will be stored.
// @return True if a byte was successfully read, false otherwise.
bool read_byte(uint8_t *data) { return this->read_array(data, 1); };
// Pure virtual method to peek the next byte in the UART buffer without removing it.
// @param data Pointer to the byte where the peeked data will be stored.
// @return True if a byte is available to peek, false otherwise.
virtual bool peek_byte(uint8_t *data) = 0;
// Pure virtual method to read an array of bytes from the UART bus.
// @param data Pointer to the array where the read data will be stored.
// @param len Number of bytes to read.
// @return True if the specified number of bytes were successfully read, false otherwise.
virtual bool read_array(uint8_t *data, size_t len) = 0;
/// Return available number of bytes.
// Pure virtual method to return the number of bytes available for reading.
// @return Number of available bytes.
virtual int available() = 0;
/// Block until all bytes have been written to the UART bus.
// Pure virtual method to block until all bytes have been written to the UART bus.
virtual void flush() = 0;
// Sets the TX (transmit) pin for the UART bus.
// @param tx_pin Pointer to the internal GPIO pin used for transmission.
void set_tx_pin(InternalGPIOPin *tx_pin) { this->tx_pin_ = tx_pin; }
// Sets the RX (receive) pin for the UART bus.
// @param rx_pin Pointer to the internal GPIO pin used for reception.
void set_rx_pin(InternalGPIOPin *rx_pin) { this->rx_pin_ = rx_pin; }
// Sets the size of the RX buffer.
// @param rx_buffer_size Size of the RX buffer in bytes.
void set_rx_buffer_size(size_t rx_buffer_size) { this->rx_buffer_size_ = rx_buffer_size; }
// Gets the size of the RX buffer.
// @return Size of the RX buffer in bytes.
size_t get_rx_buffer_size() { return this->rx_buffer_size_; }
// Sets the number of stop bits used in UART communication.
// @param stop_bits Number of stop bits.
void set_stop_bits(uint8_t stop_bits) { this->stop_bits_ = stop_bits; }
// Gets the number of stop bits used in UART communication.
// @return Number of stop bits.
uint8_t get_stop_bits() const { return this->stop_bits_; }
// Set the number of data bits used in UART communication.
// @param data_bits Number of data bits.
void set_data_bits(uint8_t data_bits) { this->data_bits_ = data_bits; }
// Get the number of data bits used in UART communication.
// @return Number of data bits.
uint8_t get_data_bits() const { return this->data_bits_; }
// Set the parity used in UART communication.
// @param parity Parity option.
void set_parity(UARTParityOptions parity) { this->parity_ = parity; }
// Get the parity used in UART communication.
// @return Parity option.
UARTParityOptions get_parity() const { return this->parity_; }
// Set the baud rate for UART communication.
// @param baud_rate Baud rate in bits per second.
void set_baud_rate(uint32_t baud_rate) { baud_rate_ = baud_rate; }
// Get the baud rate for UART communication.
// @return Baud rate in bits per second.
uint32_t get_baud_rate() const { return baud_rate_; }
#ifdef USE_ESP32
virtual void load_settings() = 0;
virtual void load_settings(bool dump_config) = 0;
/**
* Load the UART settings.
* @param dump_config If true (default), output the new settings to logs; otherwise, change settings quietly.
*
* Example:
* ```cpp
* id(uart1).load_settings(false);
* ```
*
* This will load the current UART interface with the latest settings (baud_rate, parity, etc).
*/
virtual void load_settings(bool dump_config){};
/**
* Load the UART settings.
*
* Example:
* ```cpp
* id(uart1).load_settings();
* ```
*
* This will load the current UART interface with the latest settings (baud_rate, parity, etc).
*/
virtual void load_settings(){};
#endif // USE_ESP32
#ifdef USE_UART_DEBUGGER

View File

@@ -117,7 +117,7 @@ class AsyncWebServerRequest {
// NOLINTNEXTLINE(readability-identifier-naming)
AsyncWebServerResponse *beginResponse(int code, const char *content_type) {
auto *res = new AsyncWebServerResponseEmpty(this); // NOLINT(cppcoreguidelines-owning-memory)
this->init_response_(res, 200, content_type);
this->init_response_(res, code, content_type);
return res;
}
// NOLINTNEXTLINE(readability-identifier-naming)

View File

@@ -1518,6 +1518,13 @@ class GenerateID(Optional):
super().__init__(key, default=lambda: None)
def _get_priority_default(*args):
for arg in args:
if arg is not vol.UNDEFINED:
return arg
return vol.UNDEFINED
class SplitDefault(Optional):
"""Mark this key to have a split default for ESP8266/ESP32."""
@@ -1528,6 +1535,12 @@ class SplitDefault(Optional):
esp32=vol.UNDEFINED,
esp32_arduino=vol.UNDEFINED,
esp32_idf=vol.UNDEFINED,
esp32_s2=vol.UNDEFINED,
esp32_s2_arduino=vol.UNDEFINED,
esp32_s2_idf=vol.UNDEFINED,
esp32_s3=vol.UNDEFINED,
esp32_s3_arduino=vol.UNDEFINED,
esp32_s3_idf=vol.UNDEFINED,
rp2040=vol.UNDEFINED,
bk72xx=vol.UNDEFINED,
rtl87xx=vol.UNDEFINED,
@@ -1536,10 +1549,22 @@ class SplitDefault(Optional):
super().__init__(key)
self._esp8266_default = vol.default_factory(esp8266)
self._esp32_arduino_default = vol.default_factory(
esp32_arduino if esp32 is vol.UNDEFINED else esp32
_get_priority_default(esp32, esp32_arduino)
)
self._esp32_idf_default = vol.default_factory(
esp32_idf if esp32 is vol.UNDEFINED else esp32
_get_priority_default(esp32, esp32_idf)
)
self._esp32_s2_arduino_default = vol.default_factory(
_get_priority_default(esp32_s2, esp32, esp32_s2_arduino, esp32_arduino)
)
self._esp32_s2_idf_default = vol.default_factory(
_get_priority_default(esp32_s2, esp32, esp32_s2_idf, esp32_idf)
)
self._esp32_s3_arduino_default = vol.default_factory(
_get_priority_default(esp32_s3, esp32, esp32_s3_arduino, esp32_arduino)
)
self._esp32_s3_idf_default = vol.default_factory(
_get_priority_default(esp32_s3, esp32, esp32_s3_idf, esp32_idf)
)
self._rp2040_default = vol.default_factory(rp2040)
self._bk72xx_default = vol.default_factory(bk72xx)
@@ -1550,10 +1575,29 @@ class SplitDefault(Optional):
def default(self):
if CORE.is_esp8266:
return self._esp8266_default
if CORE.is_esp32 and CORE.using_arduino:
return self._esp32_arduino_default
if CORE.is_esp32 and CORE.using_esp_idf:
return self._esp32_idf_default
if CORE.is_esp32:
from esphome.components.esp32 import get_esp32_variant
from esphome.components.esp32.const import (
VARIANT_ESP32S2,
VARIANT_ESP32S3,
)
variant = get_esp32_variant()
if variant == VARIANT_ESP32S2:
if CORE.using_arduino:
return self._esp32_s2_arduino_default
if CORE.using_esp_idf:
return self._esp32_s2_idf_default
elif variant == VARIANT_ESP32S3:
if CORE.using_arduino:
return self._esp32_s3_arduino_default
if CORE.using_esp_idf:
return self._esp32_s3_idf_default
else:
if CORE.using_arduino:
return self._esp32_arduino_default
if CORE.using_esp_idf:
return self._esp32_idf_default
if CORE.is_rp2040:
return self._rp2040_default
if CORE.is_bk72xx:

View File

@@ -1,6 +1,6 @@
"""Constants used by esphome."""
__version__ = "2023.12.0b1"
__version__ = "2023.12.0b3"
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
VALID_SUBSTITUTIONS_CHARACTERS = (

View File

@@ -11,7 +11,7 @@ esptool==4.6.2
click==8.1.7
esphome-dashboard==20231107.0
aioesphomeapi==21.0.0
zeroconf==0.128.4
zeroconf==0.130.0
python-magic==0.4.27
# esp-idf requires this, but doesn't bundle it by default