mirror of
https://github.com/esphome/esphome.git
synced 2025-11-11 04:15:52 +00:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7dced7f55d | ||
|
|
36de644065 | ||
|
|
95292dbba1 | ||
|
|
86c9546362 | ||
|
|
f37a812e59 | ||
|
|
78a6509fb1 | ||
|
|
534c14e313 | ||
|
|
3fec8f9b53 | ||
|
|
b8b6462844 | ||
|
|
59e7c52341 | ||
|
|
ff7de4c971 | ||
|
|
978a676c7c | ||
|
|
33051906bd | ||
|
|
da56d333dc | ||
|
|
48a4e6bae9 | ||
|
|
41dc73d228 | ||
|
|
6ceefe08ab | ||
|
|
21e5806a73 | ||
|
|
4fd79fee2c | ||
|
|
4c8c4a2579 | ||
|
|
b68420b2cc | ||
|
|
7bce999bba | ||
|
|
dc0cc0b431 | ||
|
|
0990d0812e | ||
|
|
35388cf2a2 | ||
|
|
417e37d291 | ||
|
|
7dc35a1029 | ||
|
|
9202a30dc7 | ||
|
|
45f9f3d972 | ||
|
|
46310ff223 | ||
|
|
f5c99d1647 |
@@ -34,7 +34,7 @@ RUN \
|
|||||||
python3-wheel=0.38.4-2 \
|
python3-wheel=0.38.4-2 \
|
||||||
iputils-ping=3:20221126-1 \
|
iputils-ping=3:20221126-1 \
|
||||||
git=1:2.39.2-1.1 \
|
git=1:2.39.2-1.1 \
|
||||||
curl=7.88.1-10+deb12u4 \
|
curl=7.88.1-10+deb12u5 \
|
||||||
openssh-client=1:9.2p1-2+deb12u1 \
|
openssh-client=1:9.2p1-2+deb12u1 \
|
||||||
python3-cffi=1.15.1-5 \
|
python3-cffi=1.15.1-5 \
|
||||||
libcairo2=1.16.0-7 \
|
libcairo2=1.16.0-7 \
|
||||||
|
|||||||
@@ -118,7 +118,9 @@ void APIConnection::loop() {
|
|||||||
this->list_entities_iterator_.advance();
|
this->list_entities_iterator_.advance();
|
||||||
this->initial_state_iterator_.advance();
|
this->initial_state_iterator_.advance();
|
||||||
|
|
||||||
const uint32_t keepalive = 60000;
|
static uint32_t keepalive = 60000;
|
||||||
|
static uint8_t max_ping_retries = 60;
|
||||||
|
static uint16_t ping_retry_interval = 1000;
|
||||||
const uint32_t now = millis();
|
const uint32_t now = millis();
|
||||||
if (this->sent_ping_) {
|
if (this->sent_ping_) {
|
||||||
// Disconnect if not responded within 2.5*keepalive
|
// Disconnect if not responded within 2.5*keepalive
|
||||||
@@ -126,10 +128,24 @@ void APIConnection::loop() {
|
|||||||
on_fatal_error();
|
on_fatal_error();
|
||||||
ESP_LOGW(TAG, "%s didn't respond to ping request in time. Disconnecting...", this->client_combined_info_.c_str());
|
ESP_LOGW(TAG, "%s didn't respond to ping request in time. Disconnecting...", this->client_combined_info_.c_str());
|
||||||
}
|
}
|
||||||
} else if (now - this->last_traffic_ > keepalive) {
|
} else if (now - this->last_traffic_ > keepalive && now > this->next_ping_retry_) {
|
||||||
ESP_LOGVV(TAG, "Sending keepalive PING...");
|
ESP_LOGVV(TAG, "Sending keepalive PING...");
|
||||||
this->sent_ping_ = true;
|
this->sent_ping_ = this->send_ping_request(PingRequest());
|
||||||
this->send_ping_request(PingRequest());
|
if (!this->sent_ping_) {
|
||||||
|
this->next_ping_retry_ = now + ping_retry_interval;
|
||||||
|
this->ping_retries_++;
|
||||||
|
if (this->ping_retries_ >= max_ping_retries) {
|
||||||
|
on_fatal_error();
|
||||||
|
ESP_LOGE(TAG, "%s: Sending keepalive failed %d time(s). Disconnecting...", this->client_combined_info_.c_str(),
|
||||||
|
this->ping_retries_);
|
||||||
|
} else if (this->ping_retries_ >= 10) {
|
||||||
|
ESP_LOGW(TAG, "%s: Sending keepalive failed %d time(s), will retry in %d ms",
|
||||||
|
this->client_combined_info_.c_str(), this->ping_retries_, ping_retry_interval);
|
||||||
|
} else {
|
||||||
|
ESP_LOGD(TAG, "%s: Sending keepalive failed %d time(s), will retry in %d ms",
|
||||||
|
this->client_combined_info_.c_str(), this->ping_retries_, ping_retry_interval);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_ESP32_CAMERA
|
#ifdef USE_ESP32_CAMERA
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ class APIConnection : public APIServerConnection {
|
|||||||
void on_disconnect_response(const DisconnectResponse &value) override;
|
void on_disconnect_response(const DisconnectResponse &value) override;
|
||||||
void on_ping_response(const PingResponse &value) override {
|
void on_ping_response(const PingResponse &value) override {
|
||||||
// we initiated ping
|
// we initiated ping
|
||||||
|
this->ping_retries_ = 0;
|
||||||
this->sent_ping_ = false;
|
this->sent_ping_ = false;
|
||||||
}
|
}
|
||||||
void on_home_assistant_state_response(const HomeAssistantStateResponse &msg) override;
|
void on_home_assistant_state_response(const HomeAssistantStateResponse &msg) override;
|
||||||
@@ -217,6 +218,8 @@ class APIConnection : public APIServerConnection {
|
|||||||
bool state_subscription_{false};
|
bool state_subscription_{false};
|
||||||
int log_subscription_{ESPHOME_LOG_LEVEL_NONE};
|
int log_subscription_{ESPHOME_LOG_LEVEL_NONE};
|
||||||
uint32_t last_traffic_;
|
uint32_t last_traffic_;
|
||||||
|
uint32_t next_ping_retry_{0};
|
||||||
|
uint8_t ping_retries_{0};
|
||||||
bool sent_ping_{false};
|
bool sent_ping_{false};
|
||||||
bool service_call_subscription_{false};
|
bool service_call_subscription_{false};
|
||||||
bool next_close_ = false;
|
bool next_close_ = false;
|
||||||
|
|||||||
@@ -3848,6 +3848,7 @@ void ListEntitiesClimateResponse::dump_to(std::string &out) const {
|
|||||||
sprintf(buffer, "%g", this->visual_max_humidity);
|
sprintf(buffer, "%g", this->visual_max_humidity);
|
||||||
out.append(buffer);
|
out.append(buffer);
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
out.append("}");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
bool ClimateStateResponse::decode_varint(uint32_t field_id, ProtoVarInt value) {
|
bool ClimateStateResponse::decode_varint(uint32_t field_id, ProtoVarInt value) {
|
||||||
@@ -4015,6 +4016,7 @@ void ClimateStateResponse::dump_to(std::string &out) const {
|
|||||||
sprintf(buffer, "%g", this->target_humidity);
|
sprintf(buffer, "%g", this->target_humidity);
|
||||||
out.append(buffer);
|
out.append(buffer);
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
out.append("}");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
bool ClimateCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
|
bool ClimateCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ void APIServer::set_reboot_timeout(uint32_t reboot_timeout) { this->reboot_timeo
|
|||||||
#ifdef USE_HOMEASSISTANT_TIME
|
#ifdef USE_HOMEASSISTANT_TIME
|
||||||
void APIServer::request_time() {
|
void APIServer::request_time() {
|
||||||
for (auto &client : this->clients_) {
|
for (auto &client : this->clients_) {
|
||||||
if (!client->remove_ && client->connection_state_ == APIConnection::ConnectionState::CONNECTED)
|
if (!client->remove_ && client->is_authenticated())
|
||||||
client->send_time_request();
|
client->send_time_request();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ from esphome.const import (
|
|||||||
UNIT_KILOWATT_HOURS,
|
UNIT_KILOWATT_HOURS,
|
||||||
UNIT_VOLT,
|
UNIT_VOLT,
|
||||||
UNIT_WATT,
|
UNIT_WATT,
|
||||||
|
STATE_CLASS_TOTAL_INCREASING,
|
||||||
)
|
)
|
||||||
|
|
||||||
DEPENDENCIES = ["uart"]
|
DEPENDENCIES = ["uart"]
|
||||||
@@ -54,6 +55,7 @@ CONFIG_SCHEMA = (
|
|||||||
unit_of_measurement=UNIT_KILOWATT_HOURS,
|
unit_of_measurement=UNIT_KILOWATT_HOURS,
|
||||||
accuracy_decimals=0,
|
accuracy_decimals=0,
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
state_class=STATE_CLASS_TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_INTERNAL_TEMPERATURE): sensor.sensor_schema(
|
cv.Optional(CONF_INTERNAL_TEMPERATURE): sensor.sensor_schema(
|
||||||
unit_of_measurement=UNIT_CELSIUS,
|
unit_of_measurement=UNIT_CELSIUS,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from esphome.const import (
|
|||||||
UNIT_VOLT,
|
UNIT_VOLT,
|
||||||
UNIT_WATT,
|
UNIT_WATT,
|
||||||
UNIT_HERTZ,
|
UNIT_HERTZ,
|
||||||
|
STATE_CLASS_TOTAL_INCREASING,
|
||||||
)
|
)
|
||||||
|
|
||||||
DEPENDENCIES = ["uart"]
|
DEPENDENCIES = ["uart"]
|
||||||
@@ -52,6 +53,7 @@ CONFIG_SCHEMA = (
|
|||||||
unit_of_measurement=UNIT_KILOWATT_HOURS,
|
unit_of_measurement=UNIT_KILOWATT_HOURS,
|
||||||
accuracy_decimals=0,
|
accuracy_decimals=0,
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
state_class=STATE_CLASS_TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_FREQUENCY): sensor.sensor_schema(
|
cv.Optional(CONF_FREQUENCY): sensor.sensor_schema(
|
||||||
unit_of_measurement=UNIT_HERTZ,
|
unit_of_measurement=UNIT_HERTZ,
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ from esphome.core import coroutine_with_priority
|
|||||||
IS_PLATFORM_COMPONENT = True
|
IS_PLATFORM_COMPONENT = True
|
||||||
|
|
||||||
display_ns = cg.esphome_ns.namespace("display")
|
display_ns = cg.esphome_ns.namespace("display")
|
||||||
Display = display_ns.class_("Display")
|
Display = display_ns.class_("Display", cg.PollingComponent)
|
||||||
DisplayBuffer = display_ns.class_("DisplayBuffer")
|
DisplayBuffer = display_ns.class_("DisplayBuffer", Display)
|
||||||
DisplayPage = display_ns.class_("DisplayPage")
|
DisplayPage = display_ns.class_("DisplayPage")
|
||||||
DisplayPagePtr = DisplayPage.operator("ptr")
|
DisplayPagePtr = DisplayPage.operator("ptr")
|
||||||
DisplayRef = Display.operator("ref")
|
DisplayRef = Display.operator("ref")
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ namespace esp32_rmt_led_strip {
|
|||||||
|
|
||||||
static const char *const TAG = "esp32_rmt_led_strip";
|
static const char *const TAG = "esp32_rmt_led_strip";
|
||||||
|
|
||||||
|
static const uint32_t RMT_CLK_FREQ = 80000000;
|
||||||
|
|
||||||
static const uint8_t RMT_CLK_DIV = 2;
|
static const uint8_t RMT_CLK_DIV = 2;
|
||||||
|
|
||||||
void ESP32RMTLEDStripLightOutput::setup() {
|
void ESP32RMTLEDStripLightOutput::setup() {
|
||||||
@@ -65,7 +67,7 @@ void ESP32RMTLEDStripLightOutput::setup() {
|
|||||||
|
|
||||||
void ESP32RMTLEDStripLightOutput::set_led_params(uint32_t bit0_high, uint32_t bit0_low, uint32_t bit1_high,
|
void ESP32RMTLEDStripLightOutput::set_led_params(uint32_t bit0_high, uint32_t bit0_low, uint32_t bit1_high,
|
||||||
uint32_t bit1_low) {
|
uint32_t bit1_low) {
|
||||||
float ratio = (float) APB_CLK_FREQ / RMT_CLK_DIV / 1e09f;
|
float ratio = (float) RMT_CLK_FREQ / RMT_CLK_DIV / 1e09f;
|
||||||
|
|
||||||
// 0-bit
|
// 0-bit
|
||||||
this->bit0_.duration0 = (uint32_t) (ratio * bit0_high);
|
this->bit0_.duration0 = (uint32_t) (ratio * bit0_high);
|
||||||
|
|||||||
@@ -39,12 +39,14 @@ void HTU21DComponent::dump_config() {
|
|||||||
LOG_SENSOR(" ", "Humidity", this->humidity_);
|
LOG_SENSOR(" ", "Humidity", this->humidity_);
|
||||||
}
|
}
|
||||||
void HTU21DComponent::update() {
|
void HTU21DComponent::update() {
|
||||||
uint16_t raw_temperature;
|
|
||||||
if (this->write(&HTU21D_REGISTER_TEMPERATURE, 1) != i2c::ERROR_OK) {
|
if (this->write(&HTU21D_REGISTER_TEMPERATURE, 1) != i2c::ERROR_OK) {
|
||||||
this->status_set_warning();
|
this->status_set_warning();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
delay(50); // NOLINT
|
|
||||||
|
// According to the datasheet sht21 temperature readings can take up to 85ms
|
||||||
|
this->set_timeout(85, [this]() {
|
||||||
|
uint16_t raw_temperature;
|
||||||
if (this->read(reinterpret_cast<uint8_t *>(&raw_temperature), 2) != i2c::ERROR_OK) {
|
if (this->read(reinterpret_cast<uint8_t *>(&raw_temperature), 2) != i2c::ERROR_OK) {
|
||||||
this->status_set_warning();
|
this->status_set_warning();
|
||||||
return;
|
return;
|
||||||
@@ -53,12 +55,19 @@ void HTU21DComponent::update() {
|
|||||||
|
|
||||||
float temperature = (float(raw_temperature & 0xFFFC)) * 175.72f / 65536.0f - 46.85f;
|
float temperature = (float(raw_temperature & 0xFFFC)) * 175.72f / 65536.0f - 46.85f;
|
||||||
|
|
||||||
uint16_t raw_humidity;
|
ESP_LOGD(TAG, "Got Temperature=%.1f°C", temperature);
|
||||||
|
|
||||||
|
if (this->temperature_ != nullptr)
|
||||||
|
this->temperature_->publish_state(temperature);
|
||||||
|
this->status_clear_warning();
|
||||||
|
|
||||||
if (this->write(&HTU21D_REGISTER_HUMIDITY, 1) != i2c::ERROR_OK) {
|
if (this->write(&HTU21D_REGISTER_HUMIDITY, 1) != i2c::ERROR_OK) {
|
||||||
this->status_set_warning();
|
this->status_set_warning();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
delay(50); // NOLINT
|
|
||||||
|
this->set_timeout(50, [this]() {
|
||||||
|
uint16_t raw_humidity;
|
||||||
if (this->read(reinterpret_cast<uint8_t *>(&raw_humidity), 2) != i2c::ERROR_OK) {
|
if (this->read(reinterpret_cast<uint8_t *>(&raw_humidity), 2) != i2c::ERROR_OK) {
|
||||||
this->status_set_warning();
|
this->status_set_warning();
|
||||||
return;
|
return;
|
||||||
@@ -69,15 +78,15 @@ void HTU21DComponent::update() {
|
|||||||
|
|
||||||
int8_t heater_level = this->get_heater_level();
|
int8_t heater_level = this->get_heater_level();
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Got Temperature=%.1f°C Humidity=%.1f%% Heater Level=%d", temperature, humidity, heater_level);
|
ESP_LOGD(TAG, "Got Humidity=%.1f%% Heater Level=%d", humidity, heater_level);
|
||||||
|
|
||||||
if (this->temperature_ != nullptr)
|
|
||||||
this->temperature_->publish_state(temperature);
|
|
||||||
if (this->humidity_ != nullptr)
|
if (this->humidity_ != nullptr)
|
||||||
this->humidity_->publish_state(humidity);
|
this->humidity_->publish_state(humidity);
|
||||||
if (this->heater_ != nullptr)
|
if (this->heater_ != nullptr)
|
||||||
this->heater_->publish_state(heater_level);
|
this->heater_->publish_state(heater_level);
|
||||||
this->status_clear_warning();
|
this->status_clear_warning();
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HTU21DComponent::is_heater_enabled() {
|
bool HTU21DComponent::is_heater_enabled() {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ optional<uint8_t> ImprovSerialComponent::read_byte_() {
|
|||||||
size_t available;
|
size_t available;
|
||||||
uart_get_buffered_data_len(this->uart_num_, &available);
|
uart_get_buffered_data_len(this->uart_num_, &available);
|
||||||
if (available) {
|
if (available) {
|
||||||
uart_read_bytes(this->uart_num_, &data, 1, 20 / portTICK_PERIOD_MS);
|
uart_read_bytes(this->uart_num_, &data, 1, 0);
|
||||||
byte = data;
|
byte = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ optional<uint8_t> ImprovSerialComponent::read_byte_() {
|
|||||||
#endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3
|
#endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3
|
||||||
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32S3)
|
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32S3)
|
||||||
case logger::UART_SELECTION_USB_SERIAL_JTAG: {
|
case logger::UART_SELECTION_USB_SERIAL_JTAG: {
|
||||||
if (usb_serial_jtag_read_bytes((char *) &data, 1, 20 / portTICK_PERIOD_MS)) {
|
if (usb_serial_jtag_read_bytes((char *) &data, 1, 0)) {
|
||||||
byte = data;
|
byte = data;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ void Inkplate6::setup() {
|
|||||||
this->wakeup_pin_->digital_write(false);
|
this->wakeup_pin_->digital_write(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allocate buffers. May be called after setup to re-initialise if e.g. greyscale is changed.
|
||||||
|
*/
|
||||||
void Inkplate6::initialize_() {
|
void Inkplate6::initialize_() {
|
||||||
ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE);
|
ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE);
|
||||||
ExternalRAMAllocator<uint32_t> allocator32(ExternalRAMAllocator<uint32_t>::ALLOW_FAILURE);
|
ExternalRAMAllocator<uint32_t> allocator32(ExternalRAMAllocator<uint32_t>::ALLOW_FAILURE);
|
||||||
|
|||||||
@@ -68,8 +68,9 @@ class Inkplate6 : public display::DisplayBuffer, public i2c::I2CDevice {
|
|||||||
|
|
||||||
void set_greyscale(bool greyscale) {
|
void set_greyscale(bool greyscale) {
|
||||||
this->greyscale_ = greyscale;
|
this->greyscale_ = greyscale;
|
||||||
this->initialize_();
|
|
||||||
this->block_partial_ = true;
|
this->block_partial_ = true;
|
||||||
|
if (this->is_ready())
|
||||||
|
this->initialize_();
|
||||||
}
|
}
|
||||||
void set_partial_updating(bool partial_updating) { this->partial_updating_ = partial_updating; }
|
void set_partial_updating(bool partial_updating) { this->partial_updating_ = partial_updating; }
|
||||||
void set_full_update_every(uint32_t full_update_every) { this->full_update_every_ = full_update_every; }
|
void set_full_update_every(uint32_t full_update_every) { this->full_update_every_ = full_update_every; }
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ async def component_to_code(config):
|
|||||||
lt_options["LT_UART_SILENT_ENABLED"] = 0
|
lt_options["LT_UART_SILENT_ENABLED"] = 0
|
||||||
lt_options["LT_UART_SILENT_ALL"] = 0
|
lt_options["LT_UART_SILENT_ALL"] = 0
|
||||||
# set default UART port
|
# set default UART port
|
||||||
if uart_port := framework.get(CONF_UART_PORT, None) is not None:
|
if (uart_port := framework.get(CONF_UART_PORT, None)) is not None:
|
||||||
lt_options["LT_UART_DEFAULT_PORT"] = uart_port
|
lt_options["LT_UART_DEFAULT_PORT"] = uart_port
|
||||||
# add custom options
|
# add custom options
|
||||||
lt_options.update(framework[CONF_OPTIONS])
|
lt_options.update(framework[CONF_OPTIONS])
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ UART_SELECTION_ESP32 = {
|
|||||||
VARIANT_ESP32: [UART0, UART1, UART2],
|
VARIANT_ESP32: [UART0, UART1, UART2],
|
||||||
VARIANT_ESP32S2: [UART0, UART1, USB_CDC],
|
VARIANT_ESP32S2: [UART0, UART1, USB_CDC],
|
||||||
VARIANT_ESP32S3: [UART0, UART1, USB_CDC, USB_SERIAL_JTAG],
|
VARIANT_ESP32S3: [UART0, UART1, USB_CDC, USB_SERIAL_JTAG],
|
||||||
VARIANT_ESP32C3: [UART0, UART1, USB_SERIAL_JTAG],
|
VARIANT_ESP32C3: [UART0, UART1, USB_CDC, USB_SERIAL_JTAG],
|
||||||
VARIANT_ESP32C2: [UART0, UART1],
|
VARIANT_ESP32C2: [UART0, UART1],
|
||||||
VARIANT_ESP32C6: [UART0, UART1, USB_CDC, USB_SERIAL_JTAG],
|
VARIANT_ESP32C6: [UART0, UART1, USB_CDC, USB_SERIAL_JTAG],
|
||||||
VARIANT_ESP32H2: [UART0, UART1, USB_CDC, USB_SERIAL_JTAG],
|
VARIANT_ESP32H2: [UART0, UART1, USB_CDC, USB_SERIAL_JTAG],
|
||||||
@@ -172,9 +172,10 @@ CONFIG_SCHEMA = cv.All(
|
|||||||
esp8266=UART0,
|
esp8266=UART0,
|
||||||
esp32=UART0,
|
esp32=UART0,
|
||||||
esp32_s2=USB_CDC,
|
esp32_s2=USB_CDC,
|
||||||
esp32_s3_idf=USB_SERIAL_JTAG,
|
|
||||||
esp32_c3_idf=USB_SERIAL_JTAG,
|
|
||||||
esp32_s3_arduino=USB_CDC,
|
esp32_s3_arduino=USB_CDC,
|
||||||
|
esp32_s3_idf=USB_SERIAL_JTAG,
|
||||||
|
esp32_c3_arduino=USB_CDC,
|
||||||
|
esp32_c3_idf=USB_SERIAL_JTAG,
|
||||||
rp2040=USB_CDC,
|
rp2040=USB_CDC,
|
||||||
bk72xx=DEFAULT,
|
bk72xx=DEFAULT,
|
||||||
rtl87xx=DEFAULT,
|
rtl87xx=DEFAULT,
|
||||||
@@ -265,6 +266,8 @@ async def to_code(config):
|
|||||||
if CORE.using_arduino:
|
if CORE.using_arduino:
|
||||||
if config[CONF_HARDWARE_UART] == USB_CDC:
|
if config[CONF_HARDWARE_UART] == USB_CDC:
|
||||||
cg.add_build_flag("-DARDUINO_USB_CDC_ON_BOOT=1")
|
cg.add_build_flag("-DARDUINO_USB_CDC_ON_BOOT=1")
|
||||||
|
if CORE.is_esp32 and get_esp32_variant() == VARIANT_ESP32C3:
|
||||||
|
cg.add_build_flag("-DARDUINO_USB_MODE=1")
|
||||||
|
|
||||||
if CORE.using_esp_idf:
|
if CORE.using_esp_idf:
|
||||||
if config[CONF_HARDWARE_UART] == USB_CDC:
|
if config[CONF_HARDWARE_UART] == USB_CDC:
|
||||||
|
|||||||
@@ -272,17 +272,13 @@ void Logger::pre_setup() {
|
|||||||
#endif
|
#endif
|
||||||
#if defined(USE_ESP32) && \
|
#if defined(USE_ESP32) && \
|
||||||
(defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32C3))
|
(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)
|
#if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32C3)
|
||||||
case UART_SELECTION_USB_CDC:
|
case UART_SELECTION_USB_CDC:
|
||||||
#endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3
|
#endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3 || USE_ESP32_VARIANT_ESP32C3
|
||||||
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S3)
|
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S3)
|
||||||
case UART_SELECTION_USB_SERIAL_JTAG:
|
case UART_SELECTION_USB_SERIAL_JTAG:
|
||||||
#endif // USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32S3
|
#endif // USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32S3
|
||||||
#ifdef USE_ESP32_VARIANT_ESP32C3
|
#if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || defined(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
|
#if ARDUINO_USB_CDC_ON_BOOT
|
||||||
this->hw_serial_ = &Serial;
|
this->hw_serial_ = &Serial;
|
||||||
Serial.setTxTimeoutMs(0); // workaround for 2.0.9 crash when there's no data connection
|
Serial.setTxTimeoutMs(0); // workaround for 2.0.9 crash when there's no data connection
|
||||||
@@ -291,7 +287,7 @@ void Logger::pre_setup() {
|
|||||||
this->hw_serial_ = &Serial;
|
this->hw_serial_ = &Serial;
|
||||||
Serial.begin(this->baud_rate_);
|
Serial.begin(this->baud_rate_);
|
||||||
#endif // ARDUINO_USB_CDC_ON_BOOT
|
#endif // ARDUINO_USB_CDC_ON_BOOT
|
||||||
#endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3
|
#endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3 || USE_ESP32_VARIANT_ESP32C3
|
||||||
break;
|
break;
|
||||||
#endif // USE_ESP32 && (USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3 || USE_ESP32_VARIANT_ESP32C3)
|
#endif // USE_ESP32 && (USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3 || USE_ESP32_VARIANT_ESP32C3)
|
||||||
#ifdef USE_RP2040
|
#ifdef USE_RP2040
|
||||||
|
|||||||
@@ -45,9 +45,10 @@ enum UARTSelection {
|
|||||||
UART_SELECTION_UART2,
|
UART_SELECTION_UART2,
|
||||||
#endif // !USE_ESP32_VARIANT_ESP32C3 && !USE_ESP32_VARIANT_ESP32C6 && !USE_ESP32_VARIANT_ESP32S2 &&
|
#endif // !USE_ESP32_VARIANT_ESP32C3 && !USE_ESP32_VARIANT_ESP32C6 && !USE_ESP32_VARIANT_ESP32S2 &&
|
||||||
// !USE_ESP32_VARIANT_ESP32S3 && !USE_ESP32_VARIANT_ESP32H2
|
// !USE_ESP32_VARIANT_ESP32S3 && !USE_ESP32_VARIANT_ESP32H2
|
||||||
#if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3)
|
#if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || \
|
||||||
|
(defined(USE_ESP32_VARIANT_ESP32C3) && defined(USE_ARDUINO))
|
||||||
UART_SELECTION_USB_CDC,
|
UART_SELECTION_USB_CDC,
|
||||||
#endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3
|
#endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3 || USE_ESP32_VARIANT_ESP32C3
|
||||||
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32S3) || \
|
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32S3) || \
|
||||||
defined(USE_ESP32_VARIANT_ESP32H2)
|
defined(USE_ESP32_VARIANT_ESP32H2)
|
||||||
UART_SELECTION_USB_SERIAL_JTAG,
|
UART_SELECTION_USB_SERIAL_JTAG,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ PylontechComponent = pylontech_ns.class_(
|
|||||||
)
|
)
|
||||||
PylontechBattery = pylontech_ns.class_("PylontechBattery")
|
PylontechBattery = pylontech_ns.class_("PylontechBattery")
|
||||||
|
|
||||||
CV_NUM_BATTERIES = cv.int_range(1, 6)
|
CV_NUM_BATTERIES = cv.int_range(1, 16)
|
||||||
|
|
||||||
PYLONTECH_COMPONENT_SCHEMA = cv.Schema(
|
PYLONTECH_COMPONENT_SCHEMA = cv.Schema(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "pylontech.h"
|
#include "pylontech.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
#include "esphome/core/helpers.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace pylontech {
|
namespace pylontech {
|
||||||
@@ -34,13 +35,15 @@ void PylontechComponent::setup() {
|
|||||||
void PylontechComponent::update() { this->write_str("pwr\n"); }
|
void PylontechComponent::update() { this->write_str("pwr\n"); }
|
||||||
|
|
||||||
void PylontechComponent::loop() {
|
void PylontechComponent::loop() {
|
||||||
uint8_t data;
|
if (this->available() > 0) {
|
||||||
|
|
||||||
// pylontech sends a lot of data very suddenly
|
// pylontech sends a lot of data very suddenly
|
||||||
// we need to quickly put it all into our own buffer, otherwise the uart's buffer will overflow
|
// we need to quickly put it all into our own buffer, otherwise the uart's buffer will overflow
|
||||||
|
uint8_t data;
|
||||||
|
int recv = 0;
|
||||||
while (this->available() > 0) {
|
while (this->available() > 0) {
|
||||||
if (this->read_byte(&data)) {
|
if (this->read_byte(&data)) {
|
||||||
buffer_[buffer_index_write_] += (char) data;
|
buffer_[buffer_index_write_] += (char) data;
|
||||||
|
recv++;
|
||||||
if (buffer_[buffer_index_write_].back() == static_cast<char>(ASCII_LF) ||
|
if (buffer_[buffer_index_write_].back() == static_cast<char>(ASCII_LF) ||
|
||||||
buffer_[buffer_index_write_].length() >= MAX_DATA_LENGTH_BYTES) {
|
buffer_[buffer_index_write_].length() >= MAX_DATA_LENGTH_BYTES) {
|
||||||
// complete line received
|
// complete line received
|
||||||
@@ -48,13 +51,15 @@ void PylontechComponent::loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ESP_LOGV(TAG, "received %d bytes", recv);
|
||||||
|
} else {
|
||||||
// only process one line per call of loop() to not block esphome for too long
|
// only process one line per call of loop() to not block esphome for too long
|
||||||
if (buffer_index_read_ != buffer_index_write_) {
|
if (buffer_index_read_ != buffer_index_write_) {
|
||||||
this->process_line_(buffer_[buffer_index_read_]);
|
this->process_line_(buffer_[buffer_index_read_]);
|
||||||
buffer_[buffer_index_read_].clear();
|
buffer_[buffer_index_read_].clear();
|
||||||
buffer_index_read_ = (buffer_index_read_ + 1) % NUM_BUFFERS;
|
buffer_index_read_ = (buffer_index_read_ + 1) % NUM_BUFFERS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PylontechComponent::process_line_(std::string &buffer) {
|
void PylontechComponent::process_line_(std::string &buffer) {
|
||||||
@@ -66,10 +71,11 @@ void PylontechComponent::process_line_(std::string &buffer) {
|
|||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
PylontechListener::LineContents l{};
|
PylontechListener::LineContents l{};
|
||||||
|
char mostempr_s[6];
|
||||||
const int parsed = sscanf( // NOLINT
|
const int parsed = sscanf( // NOLINT
|
||||||
buffer.c_str(), "%d %d %d %d %d %d %d %d %7s %7s %7s %7s %d%% %*d-%*d-%*d %*d:%*d:%*d %*s %*s %d %*s", // NOLINT
|
buffer.c_str(), "%d %d %d %d %d %d %d %d %7s %7s %7s %7s %d%% %*d-%*d-%*d %*d:%*d:%*d %*s %*s %5s %*s", // NOLINT
|
||||||
&l.bat_num, &l.volt, &l.curr, &l.tempr, &l.tlow, &l.thigh, &l.vlow, &l.vhigh, l.base_st, l.volt_st, // NOLINT
|
&l.bat_num, &l.volt, &l.curr, &l.tempr, &l.tlow, &l.thigh, &l.vlow, &l.vhigh, l.base_st, l.volt_st, // NOLINT
|
||||||
l.curr_st, l.temp_st, &l.coulomb, &l.mostempr); // NOLINT
|
l.curr_st, l.temp_st, &l.coulomb, mostempr_s); // NOLINT
|
||||||
|
|
||||||
if (l.bat_num <= 0) {
|
if (l.bat_num <= 0) {
|
||||||
ESP_LOGD(TAG, "invalid bat_num in line %s", buffer.substr(0, buffer.size() - 2).c_str());
|
ESP_LOGD(TAG, "invalid bat_num in line %s", buffer.substr(0, buffer.size() - 2).c_str());
|
||||||
@@ -79,6 +85,13 @@ void PylontechComponent::process_line_(std::string &buffer) {
|
|||||||
ESP_LOGW(TAG, "invalid line: found only %d items in %s", parsed, buffer.substr(0, buffer.size() - 2).c_str());
|
ESP_LOGW(TAG, "invalid line: found only %d items in %s", parsed, buffer.substr(0, buffer.size() - 2).c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
auto mostempr_parsed = parse_number<int>(mostempr_s);
|
||||||
|
if (mostempr_parsed.has_value()) {
|
||||||
|
l.mostempr = mostempr_parsed.value();
|
||||||
|
} else {
|
||||||
|
l.mostempr = -300;
|
||||||
|
ESP_LOGW(TAG, "bat_num %d: received no mostempr", l.bat_num);
|
||||||
|
}
|
||||||
|
|
||||||
for (PylontechListener *listener : this->listeners_) {
|
for (PylontechListener *listener : this->listeners_) {
|
||||||
listener->on_line_read(&l);
|
listener->on_line_read(&l);
|
||||||
|
|||||||
@@ -227,16 +227,17 @@ optional<ProntoData> ProntoProtocol::decode(RemoteReceiveData src) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ProntoProtocol::dump(const ProntoData &data) {
|
void ProntoProtocol::dump(const ProntoData &data) {
|
||||||
std::string first, rest;
|
std::string rest;
|
||||||
if (data.data.size() < 230) {
|
|
||||||
first = data.data;
|
rest = data.data;
|
||||||
|
ESP_LOGI(TAG, "Received Pronto: data=");
|
||||||
|
while (true) {
|
||||||
|
ESP_LOGI(TAG, "%s", rest.substr(0, 230).c_str());
|
||||||
|
if (rest.size() > 230) {
|
||||||
|
rest = rest.substr(230);
|
||||||
} else {
|
} else {
|
||||||
first = data.data.substr(0, 229);
|
break;
|
||||||
rest = data.data.substr(230);
|
|
||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "Received Pronto: data=%s", first.c_str());
|
|
||||||
if (!rest.empty()) {
|
|
||||||
ESP_LOGI(TAG, "%s", rest.c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,9 @@ void TT21100Touchscreen::setup() {
|
|||||||
// Update display dimensions if they were updated during display setup
|
// Update display dimensions if they were updated during display setup
|
||||||
this->x_raw_max_ = this->get_width_();
|
this->x_raw_max_ = this->get_width_();
|
||||||
this->y_raw_max_ = this->get_height_();
|
this->y_raw_max_ = this->get_height_();
|
||||||
|
|
||||||
|
// Trigger initial read to activate the interrupt
|
||||||
|
this->store_.touched = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TT21100Touchscreen::update_touches() {
|
void TT21100Touchscreen::update_touches() {
|
||||||
|
|||||||
@@ -86,14 +86,14 @@ void VoiceAssistant::setup() {
|
|||||||
|
|
||||||
#ifdef USE_ESP_ADF
|
#ifdef USE_ESP_ADF
|
||||||
this->vad_instance_ = vad_create(VAD_MODE_4);
|
this->vad_instance_ = vad_create(VAD_MODE_4);
|
||||||
|
#endif
|
||||||
|
|
||||||
this->ring_buffer_ = rb_create(BUFFER_SIZE, sizeof(int16_t));
|
this->ring_buffer_ = RingBuffer::create(BUFFER_SIZE * sizeof(int16_t));
|
||||||
if (this->ring_buffer_ == nullptr) {
|
if (this->ring_buffer_ == nullptr) {
|
||||||
ESP_LOGW(TAG, "Could not allocate ring buffer");
|
ESP_LOGW(TAG, "Could not allocate ring buffer");
|
||||||
this->mark_failed();
|
this->mark_failed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
ExternalRAMAllocator<uint8_t> send_allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE);
|
ExternalRAMAllocator<uint8_t> send_allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE);
|
||||||
this->send_buffer_ = send_allocator.allocate(SEND_BUFFER_SIZE);
|
this->send_buffer_ = send_allocator.allocate(SEND_BUFFER_SIZE);
|
||||||
@@ -112,14 +112,8 @@ int VoiceAssistant::read_microphone_() {
|
|||||||
memset(this->input_buffer_, 0, INPUT_BUFFER_SIZE * sizeof(int16_t));
|
memset(this->input_buffer_, 0, INPUT_BUFFER_SIZE * sizeof(int16_t));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#ifdef USE_ESP_ADF
|
|
||||||
// Write audio into ring buffer
|
// Write audio into ring buffer
|
||||||
int available = rb_bytes_available(this->ring_buffer_);
|
this->ring_buffer_->write((void *) this->input_buffer_, bytes_read);
|
||||||
if (available < bytes_read) {
|
|
||||||
rb_read(this->ring_buffer_, nullptr, bytes_read - available, 0);
|
|
||||||
}
|
|
||||||
rb_write(this->ring_buffer_, (char *) this->input_buffer_, bytes_read, 0);
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "microphone not running");
|
ESP_LOGD(TAG, "microphone not running");
|
||||||
}
|
}
|
||||||
@@ -141,9 +135,9 @@ void VoiceAssistant::loop() {
|
|||||||
switch (this->state_) {
|
switch (this->state_) {
|
||||||
case State::IDLE: {
|
case State::IDLE: {
|
||||||
if (this->continuous_ && this->desired_state_ == State::IDLE) {
|
if (this->continuous_ && this->desired_state_ == State::IDLE) {
|
||||||
|
this->ring_buffer_->reset();
|
||||||
#ifdef USE_ESP_ADF
|
#ifdef USE_ESP_ADF
|
||||||
if (this->use_wake_word_) {
|
if (this->use_wake_word_) {
|
||||||
rb_reset(this->ring_buffer_);
|
|
||||||
this->set_state_(State::START_MICROPHONE, State::WAIT_FOR_VAD);
|
this->set_state_(State::START_MICROPHONE, State::WAIT_FOR_VAD);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
@@ -236,19 +230,13 @@ void VoiceAssistant::loop() {
|
|||||||
break; // State changed when udp server port received
|
break; // State changed when udp server port received
|
||||||
}
|
}
|
||||||
case State::STREAMING_MICROPHONE: {
|
case State::STREAMING_MICROPHONE: {
|
||||||
size_t bytes_read = this->read_microphone_();
|
this->read_microphone_();
|
||||||
#ifdef USE_ESP_ADF
|
if (this->ring_buffer_->available() >= SEND_BUFFER_SIZE) {
|
||||||
if (rb_bytes_filled(this->ring_buffer_) >= SEND_BUFFER_SIZE) {
|
this->ring_buffer_->read((void *) this->send_buffer_, SEND_BUFFER_SIZE, 0);
|
||||||
rb_read(this->ring_buffer_, (char *) this->send_buffer_, SEND_BUFFER_SIZE, 0);
|
|
||||||
this->socket_->sendto(this->send_buffer_, SEND_BUFFER_SIZE, 0, (struct sockaddr *) &this->dest_addr_,
|
this->socket_->sendto(this->send_buffer_, SEND_BUFFER_SIZE, 0, (struct sockaddr *) &this->dest_addr_,
|
||||||
sizeof(this->dest_addr_));
|
sizeof(this->dest_addr_));
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (bytes_read > 0) {
|
|
||||||
this->socket_->sendto(this->input_buffer_, bytes_read, 0, (struct sockaddr *) &this->dest_addr_,
|
|
||||||
sizeof(this->dest_addr_));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case State::STOP_MICROPHONE: {
|
case State::STOP_MICROPHONE: {
|
||||||
@@ -473,9 +461,9 @@ void VoiceAssistant::request_start(bool continuous, bool silence_detection) {
|
|||||||
if (this->state_ == State::IDLE) {
|
if (this->state_ == State::IDLE) {
|
||||||
this->continuous_ = continuous;
|
this->continuous_ = continuous;
|
||||||
this->silence_detection_ = silence_detection;
|
this->silence_detection_ = silence_detection;
|
||||||
|
this->ring_buffer_->reset();
|
||||||
#ifdef USE_ESP_ADF
|
#ifdef USE_ESP_ADF
|
||||||
if (this->use_wake_word_) {
|
if (this->use_wake_word_) {
|
||||||
rb_reset(this->ring_buffer_);
|
|
||||||
this->set_state_(State::START_MICROPHONE, State::WAIT_FOR_VAD);
|
this->set_state_(State::START_MICROPHONE, State::WAIT_FOR_VAD);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
@@ -618,9 +606,9 @@ void VoiceAssistant::on_event(const api::VoiceAssistantEventResponse &msg) {
|
|||||||
case api::enums::VOICE_ASSISTANT_RUN_END: {
|
case api::enums::VOICE_ASSISTANT_RUN_END: {
|
||||||
ESP_LOGD(TAG, "Assist Pipeline ended");
|
ESP_LOGD(TAG, "Assist Pipeline ended");
|
||||||
if (this->state_ == State::STREAMING_MICROPHONE) {
|
if (this->state_ == State::STREAMING_MICROPHONE) {
|
||||||
|
this->ring_buffer_->reset();
|
||||||
#ifdef USE_ESP_ADF
|
#ifdef USE_ESP_ADF
|
||||||
if (this->use_wake_word_) {
|
if (this->use_wake_word_) {
|
||||||
rb_reset(this->ring_buffer_);
|
|
||||||
// No need to stop the microphone since we didn't use the speaker
|
// No need to stop the microphone since we didn't use the speaker
|
||||||
this->set_state_(State::WAIT_FOR_VAD, State::WAITING_FOR_VAD);
|
this->set_state_(State::WAIT_FOR_VAD, State::WAITING_FOR_VAD);
|
||||||
} else
|
} else
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "esphome/core/automation.h"
|
#include "esphome/core/automation.h"
|
||||||
#include "esphome/core/component.h"
|
#include "esphome/core/component.h"
|
||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
|
#include "esphome/core/ring_buffer.h"
|
||||||
|
|
||||||
#include "esphome/components/api/api_connection.h"
|
#include "esphome/components/api/api_connection.h"
|
||||||
#include "esphome/components/api/api_pb2.h"
|
#include "esphome/components/api/api_pb2.h"
|
||||||
@@ -21,7 +22,6 @@
|
|||||||
|
|
||||||
#ifdef USE_ESP_ADF
|
#ifdef USE_ESP_ADF
|
||||||
#include <esp_vad.h>
|
#include <esp_vad.h>
|
||||||
#include <ringbuf.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
@@ -177,10 +177,10 @@ class VoiceAssistant : public Component {
|
|||||||
|
|
||||||
#ifdef USE_ESP_ADF
|
#ifdef USE_ESP_ADF
|
||||||
vad_handle_t vad_instance_;
|
vad_handle_t vad_instance_;
|
||||||
ringbuf_handle_t ring_buffer_;
|
|
||||||
uint8_t vad_threshold_{5};
|
uint8_t vad_threshold_{5};
|
||||||
uint8_t vad_counter_{0};
|
uint8_t vad_counter_{0};
|
||||||
#endif
|
#endif
|
||||||
|
std::unique_ptr<RingBuffer> ring_buffer_;
|
||||||
|
|
||||||
bool use_wake_word_;
|
bool use_wake_word_;
|
||||||
uint8_t noise_suppression_level_;
|
uint8_t noise_suppression_level_;
|
||||||
|
|||||||
@@ -315,7 +315,11 @@ class LoadValidationStep(ConfigValidationStep):
|
|||||||
return
|
return
|
||||||
result.add_output_path([self.domain], self.domain)
|
result.add_output_path([self.domain], self.domain)
|
||||||
component = get_component(self.domain)
|
component = get_component(self.domain)
|
||||||
if component.multi_conf_no_default and isinstance(self.conf, core.AutoLoad):
|
if (
|
||||||
|
component is not None
|
||||||
|
and component.multi_conf_no_default
|
||||||
|
and isinstance(self.conf, core.AutoLoad)
|
||||||
|
):
|
||||||
self.conf = []
|
self.conf = []
|
||||||
result[self.domain] = self.conf
|
result[self.domain] = self.conf
|
||||||
path = [self.domain]
|
path = [self.domain]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""Constants used by esphome."""
|
"""Constants used by esphome."""
|
||||||
|
|
||||||
__version__ = "2023.12.2"
|
__version__ = "2023.12.7"
|
||||||
|
|
||||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||||
VALID_SUBSTITUTIONS_CHARACTERS = (
|
VALID_SUBSTITUTIONS_CHARACTERS = (
|
||||||
|
|||||||
49
esphome/core/ring_buffer.cpp
Normal file
49
esphome/core/ring_buffer.cpp
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#include "ring_buffer.h"
|
||||||
|
|
||||||
|
#include "esphome/core/helpers.h"
|
||||||
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
|
#ifdef USE_ESP32
|
||||||
|
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
|
||||||
|
static const char *const TAG = "ring_buffer";
|
||||||
|
|
||||||
|
std::unique_ptr<RingBuffer> RingBuffer::create(size_t len) {
|
||||||
|
std::unique_ptr<RingBuffer> rb = make_unique<RingBuffer>();
|
||||||
|
|
||||||
|
ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE);
|
||||||
|
rb->storage_ = allocator.allocate(len);
|
||||||
|
if (rb->storage_ == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
rb->handle_ = xStreamBufferCreateStatic(len, 0, rb->storage_, &rb->structure_);
|
||||||
|
return rb;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RingBuffer::read(void *data, size_t size, TickType_t ticks_to_wait) {
|
||||||
|
return xStreamBufferReceive(this->handle_, data, size, ticks_to_wait);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RingBuffer::write(void *data, size_t len) {
|
||||||
|
size_t free = this->free();
|
||||||
|
if (free < len) {
|
||||||
|
size_t needed = len - free;
|
||||||
|
uint8_t discard[needed];
|
||||||
|
xStreamBufferReceive(this->handle_, discard, needed, 0);
|
||||||
|
}
|
||||||
|
return xStreamBufferSend(this->handle_, data, len, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RingBuffer::available() const { return xStreamBufferBytesAvailable(this->handle_); }
|
||||||
|
|
||||||
|
size_t RingBuffer::free() const { return xStreamBufferSpacesAvailable(this->handle_); }
|
||||||
|
|
||||||
|
BaseType_t RingBuffer::reset() { return xStreamBufferReset(this->handle_); }
|
||||||
|
|
||||||
|
} // namespace esphome
|
||||||
|
|
||||||
|
#endif
|
||||||
34
esphome/core/ring_buffer.h
Normal file
34
esphome/core/ring_buffer.h
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef USE_ESP32
|
||||||
|
|
||||||
|
#include <freertos/FreeRTOS.h>
|
||||||
|
#include <freertos/stream_buffer.h>
|
||||||
|
|
||||||
|
#include <cinttypes>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
|
||||||
|
class RingBuffer {
|
||||||
|
public:
|
||||||
|
size_t read(void *data, size_t size, TickType_t ticks_to_wait = 0);
|
||||||
|
|
||||||
|
size_t write(void *data, size_t len);
|
||||||
|
|
||||||
|
size_t available() const;
|
||||||
|
size_t free() const;
|
||||||
|
|
||||||
|
BaseType_t reset();
|
||||||
|
|
||||||
|
static std::unique_ptr<RingBuffer> create(size_t len);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
StreamBufferHandle_t handle_;
|
||||||
|
StaticStreamBuffer_t structure_;
|
||||||
|
uint8_t *storage_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace esphome
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -31,6 +31,7 @@ class PingStatus:
|
|||||||
while not dashboard.stop_event.is_set():
|
while not dashboard.stop_event.is_set():
|
||||||
# Only ping if the dashboard is open
|
# Only ping if the dashboard is open
|
||||||
await dashboard.ping_request.wait()
|
await dashboard.ping_request.wait()
|
||||||
|
dashboard.ping_request.clear()
|
||||||
current_entries = dashboard.entries.async_all()
|
current_entries = dashboard.entries.async_all()
|
||||||
to_ping: list[DashboardEntry] = [
|
to_ping: list[DashboardEntry] = [
|
||||||
entry for entry in current_entries if entry.address is not None
|
entry for entry in current_entries if entry.address is not None
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ def write_file(
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
tmp_filename = ""
|
tmp_filename = ""
|
||||||
|
missing_fchmod = False
|
||||||
try:
|
try:
|
||||||
# Modern versions of Python tempfile create this file with mode 0o600
|
# Modern versions of Python tempfile create this file with mode 0o600
|
||||||
with tempfile.NamedTemporaryFile(
|
with tempfile.NamedTemporaryFile(
|
||||||
@@ -38,8 +39,15 @@ def write_file(
|
|||||||
fdesc.write(utf8_data)
|
fdesc.write(utf8_data)
|
||||||
tmp_filename = fdesc.name
|
tmp_filename = fdesc.name
|
||||||
if not private:
|
if not private:
|
||||||
|
try:
|
||||||
os.fchmod(fdesc.fileno(), 0o644)
|
os.fchmod(fdesc.fileno(), 0o644)
|
||||||
|
except AttributeError:
|
||||||
|
# os.fchmod is not available on Windows
|
||||||
|
missing_fchmod = True
|
||||||
|
|
||||||
os.replace(tmp_filename, filename)
|
os.replace(tmp_filename, filename)
|
||||||
|
if missing_fchmod:
|
||||||
|
os.chmod(filename, 0o644)
|
||||||
finally:
|
finally:
|
||||||
if os.path.exists(tmp_filename):
|
if os.path.exists(tmp_filename):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -301,11 +301,16 @@ class EsphomePortCommandWebSocket(EsphomeCommandWebSocket):
|
|||||||
config_file = settings.rel_path(configuration)
|
config_file = settings.rel_path(configuration)
|
||||||
port = json_message["port"]
|
port = json_message["port"]
|
||||||
if (
|
if (
|
||||||
port == "OTA"
|
port == "OTA" # pylint: disable=too-many-boolean-expressions
|
||||||
and (mdns := dashboard.mdns_status)
|
and (mdns := dashboard.mdns_status)
|
||||||
and (entry := entries.get(config_file))
|
and (entry := entries.get(config_file))
|
||||||
|
and entry.loaded_integrations
|
||||||
|
and "api" in entry.loaded_integrations
|
||||||
and (address := await mdns.async_resolve_host(entry.name))
|
and (address := await mdns.async_resolve_host(entry.name))
|
||||||
):
|
):
|
||||||
|
# Use the IP address if available but only
|
||||||
|
# if the API is loaded and the device is online
|
||||||
|
# since MQTT logging will not work otherwise
|
||||||
port = address
|
port = address
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -1,36 +1,37 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import functools
|
import functools
|
||||||
import inspect
|
import inspect
|
||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
import yaml.constructor
|
import yaml.constructor
|
||||||
|
from yaml import SafeLoader as PurePythonLoader
|
||||||
|
|
||||||
|
try:
|
||||||
|
from yaml import CSafeLoader as FastestAvailableSafeLoader
|
||||||
|
except ImportError:
|
||||||
|
FastestAvailableSafeLoader = PurePythonLoader
|
||||||
|
|
||||||
from esphome import core
|
from esphome import core
|
||||||
from esphome.config_helpers import read_config_file, Extend, Remove
|
from esphome.config_helpers import Extend, Remove, read_config_file
|
||||||
from esphome.core import (
|
from esphome.core import (
|
||||||
|
CORE,
|
||||||
|
DocumentRange,
|
||||||
EsphomeError,
|
EsphomeError,
|
||||||
IPAddress,
|
IPAddress,
|
||||||
Lambda,
|
Lambda,
|
||||||
MACAddress,
|
MACAddress,
|
||||||
TimePeriod,
|
TimePeriod,
|
||||||
DocumentRange,
|
|
||||||
CORE,
|
|
||||||
)
|
)
|
||||||
from esphome.helpers import add_class_to_obj
|
from esphome.helpers import add_class_to_obj
|
||||||
from esphome.util import OrderedDict, filter_yaml_files
|
from esphome.util import OrderedDict, filter_yaml_files
|
||||||
|
|
||||||
try:
|
|
||||||
from yaml import CSafeLoader as FastestAvailableSafeLoader
|
|
||||||
except ImportError:
|
|
||||||
from yaml import ( # type: ignore[assignment]
|
|
||||||
SafeLoader as FastestAvailableSafeLoader,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Mostly copied from Home Assistant because that code works fine and
|
# Mostly copied from Home Assistant because that code works fine and
|
||||||
@@ -97,7 +98,7 @@ def _add_data_ref(fn):
|
|||||||
return wrapped
|
return wrapped
|
||||||
|
|
||||||
|
|
||||||
class ESPHomeLoader(FastestAvailableSafeLoader):
|
class ESPHomeLoaderMixin:
|
||||||
"""Loader class that keeps track of line numbers."""
|
"""Loader class that keeps track of line numbers."""
|
||||||
|
|
||||||
@_add_data_ref
|
@_add_data_ref
|
||||||
@@ -282,8 +283,8 @@ class ESPHomeLoader(FastestAvailableSafeLoader):
|
|||||||
return file, vars
|
return file, vars
|
||||||
|
|
||||||
def substitute_vars(config, vars):
|
def substitute_vars(config, vars):
|
||||||
from esphome.const import CONF_SUBSTITUTIONS
|
|
||||||
from esphome.components import substitutions
|
from esphome.components import substitutions
|
||||||
|
from esphome.const import CONF_SUBSTITUTIONS
|
||||||
|
|
||||||
org_subs = None
|
org_subs = None
|
||||||
result = config
|
result = config
|
||||||
@@ -367,50 +368,64 @@ class ESPHomeLoader(FastestAvailableSafeLoader):
|
|||||||
return Remove(str(node.value))
|
return Remove(str(node.value))
|
||||||
|
|
||||||
|
|
||||||
ESPHomeLoader.add_constructor("tag:yaml.org,2002:int", ESPHomeLoader.construct_yaml_int)
|
class ESPHomeLoader(ESPHomeLoaderMixin, FastestAvailableSafeLoader):
|
||||||
ESPHomeLoader.add_constructor(
|
"""Loader class that keeps track of line numbers."""
|
||||||
"tag:yaml.org,2002:float", ESPHomeLoader.construct_yaml_float
|
|
||||||
)
|
|
||||||
ESPHomeLoader.add_constructor(
|
|
||||||
"tag:yaml.org,2002:binary", ESPHomeLoader.construct_yaml_binary
|
|
||||||
)
|
|
||||||
ESPHomeLoader.add_constructor(
|
|
||||||
"tag:yaml.org,2002:omap", ESPHomeLoader.construct_yaml_omap
|
|
||||||
)
|
|
||||||
ESPHomeLoader.add_constructor("tag:yaml.org,2002:str", ESPHomeLoader.construct_yaml_str)
|
|
||||||
ESPHomeLoader.add_constructor("tag:yaml.org,2002:seq", ESPHomeLoader.construct_yaml_seq)
|
|
||||||
ESPHomeLoader.add_constructor("tag:yaml.org,2002:map", ESPHomeLoader.construct_yaml_map)
|
|
||||||
ESPHomeLoader.add_constructor("!env_var", ESPHomeLoader.construct_env_var)
|
|
||||||
ESPHomeLoader.add_constructor("!secret", ESPHomeLoader.construct_secret)
|
|
||||||
ESPHomeLoader.add_constructor("!include", ESPHomeLoader.construct_include)
|
|
||||||
ESPHomeLoader.add_constructor(
|
|
||||||
"!include_dir_list", ESPHomeLoader.construct_include_dir_list
|
|
||||||
)
|
|
||||||
ESPHomeLoader.add_constructor(
|
|
||||||
"!include_dir_merge_list", ESPHomeLoader.construct_include_dir_merge_list
|
|
||||||
)
|
|
||||||
ESPHomeLoader.add_constructor(
|
|
||||||
"!include_dir_named", ESPHomeLoader.construct_include_dir_named
|
|
||||||
)
|
|
||||||
ESPHomeLoader.add_constructor(
|
|
||||||
"!include_dir_merge_named", ESPHomeLoader.construct_include_dir_merge_named
|
|
||||||
)
|
|
||||||
ESPHomeLoader.add_constructor("!lambda", ESPHomeLoader.construct_lambda)
|
|
||||||
ESPHomeLoader.add_constructor("!force", ESPHomeLoader.construct_force)
|
|
||||||
ESPHomeLoader.add_constructor("!extend", ESPHomeLoader.construct_extend)
|
|
||||||
ESPHomeLoader.add_constructor("!remove", ESPHomeLoader.construct_remove)
|
|
||||||
|
|
||||||
|
|
||||||
def load_yaml(fname, clear_secrets=True):
|
class ESPHomePurePythonLoader(ESPHomeLoaderMixin, PurePythonLoader):
|
||||||
|
"""Loader class that keeps track of line numbers."""
|
||||||
|
|
||||||
|
|
||||||
|
for _loader in (ESPHomeLoader, ESPHomePurePythonLoader):
|
||||||
|
_loader.add_constructor("tag:yaml.org,2002:int", _loader.construct_yaml_int)
|
||||||
|
_loader.add_constructor("tag:yaml.org,2002:float", _loader.construct_yaml_float)
|
||||||
|
_loader.add_constructor("tag:yaml.org,2002:binary", _loader.construct_yaml_binary)
|
||||||
|
_loader.add_constructor("tag:yaml.org,2002:omap", _loader.construct_yaml_omap)
|
||||||
|
_loader.add_constructor("tag:yaml.org,2002:str", _loader.construct_yaml_str)
|
||||||
|
_loader.add_constructor("tag:yaml.org,2002:seq", _loader.construct_yaml_seq)
|
||||||
|
_loader.add_constructor("tag:yaml.org,2002:map", _loader.construct_yaml_map)
|
||||||
|
_loader.add_constructor("!env_var", _loader.construct_env_var)
|
||||||
|
_loader.add_constructor("!secret", _loader.construct_secret)
|
||||||
|
_loader.add_constructor("!include", _loader.construct_include)
|
||||||
|
_loader.add_constructor("!include_dir_list", _loader.construct_include_dir_list)
|
||||||
|
_loader.add_constructor(
|
||||||
|
"!include_dir_merge_list", _loader.construct_include_dir_merge_list
|
||||||
|
)
|
||||||
|
_loader.add_constructor("!include_dir_named", _loader.construct_include_dir_named)
|
||||||
|
_loader.add_constructor(
|
||||||
|
"!include_dir_merge_named", _loader.construct_include_dir_merge_named
|
||||||
|
)
|
||||||
|
_loader.add_constructor("!lambda", _loader.construct_lambda)
|
||||||
|
_loader.add_constructor("!force", _loader.construct_force)
|
||||||
|
_loader.add_constructor("!extend", _loader.construct_extend)
|
||||||
|
_loader.add_constructor("!remove", _loader.construct_remove)
|
||||||
|
|
||||||
|
|
||||||
|
def load_yaml(fname: str, clear_secrets: bool = True) -> Any:
|
||||||
if clear_secrets:
|
if clear_secrets:
|
||||||
_SECRET_VALUES.clear()
|
_SECRET_VALUES.clear()
|
||||||
_SECRET_CACHE.clear()
|
_SECRET_CACHE.clear()
|
||||||
return _load_yaml_internal(fname)
|
return _load_yaml_internal(fname)
|
||||||
|
|
||||||
|
|
||||||
def _load_yaml_internal(fname):
|
def _load_yaml_internal(fname: str) -> Any:
|
||||||
|
"""Load a YAML file."""
|
||||||
content = read_config_file(fname)
|
content = read_config_file(fname)
|
||||||
loader = ESPHomeLoader(content)
|
try:
|
||||||
|
return _load_yaml_internal_with_type(ESPHomeLoader, fname, content)
|
||||||
|
except EsphomeError:
|
||||||
|
# Loading failed, so we now load with the Python loader which has more
|
||||||
|
# readable exceptions
|
||||||
|
return _load_yaml_internal_with_type(ESPHomePurePythonLoader, fname, content)
|
||||||
|
|
||||||
|
|
||||||
|
def _load_yaml_internal_with_type(
|
||||||
|
loader_type: type[ESPHomeLoader] | type[ESPHomePurePythonLoader],
|
||||||
|
fname: str,
|
||||||
|
content: str,
|
||||||
|
) -> Any:
|
||||||
|
"""Load a YAML file."""
|
||||||
|
loader = loader_type(content)
|
||||||
loader.name = fname
|
loader.name = fname
|
||||||
try:
|
try:
|
||||||
return loader.get_single_data() or OrderedDict()
|
return loader.get_single_data() or OrderedDict()
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ def test_write_utf8_file(tmp_path: Path) -> None:
|
|||||||
assert tmp_path.joinpath("foo.txt").read_text() == "foo"
|
assert tmp_path.joinpath("foo.txt").read_text() == "foo"
|
||||||
|
|
||||||
with pytest.raises(OSError):
|
with pytest.raises(OSError):
|
||||||
write_utf8_file(Path("/not-writable"), "bar")
|
write_utf8_file(Path("/dev/not-writable"), "bar")
|
||||||
|
|
||||||
|
|
||||||
def test_write_file(tmp_path: Path) -> None:
|
def test_write_file(tmp_path: Path) -> None:
|
||||||
|
|||||||
18
tests/unit_tests/fixtures/yaml_util/broken_includetest.yaml
Normal file
18
tests/unit_tests/fixtures/yaml_util/broken_includetest.yaml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
substitutions:
|
||||||
|
name: original
|
||||||
|
|
||||||
|
wifi: !include
|
||||||
|
file: includes/broken_included.yaml.txt
|
||||||
|
vars:
|
||||||
|
name: my_custom_ssid
|
||||||
|
|
||||||
|
esphome:
|
||||||
|
# should be substituted as 'original',
|
||||||
|
# not overwritten by vars in the !include above
|
||||||
|
name: ${name}
|
||||||
|
name_add_mac_suffix: true
|
||||||
|
platform: esp8266
|
||||||
|
board: !include {file: includes/scalar.yaml, vars: {var1: nodemcu}}
|
||||||
|
|
||||||
|
libraries: !include {file: includes/list.yaml, vars: {var1: Wire}}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
# yamllint disable-line
|
||||||
|
ssid: ${name}
|
||||||
|
# yamllint disable-line
|
||||||
|
fdf: error
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
from esphome import yaml_util
|
from esphome import yaml_util
|
||||||
from esphome.components import substitutions
|
from esphome.components import substitutions
|
||||||
|
from esphome.core import EsphomeError
|
||||||
|
|
||||||
|
|
||||||
def test_include_with_vars(fixture_path):
|
def test_include_with_vars(fixture_path):
|
||||||
@@ -11,3 +12,13 @@ def test_include_with_vars(fixture_path):
|
|||||||
assert actual["esphome"]["libraries"][0] == "Wire"
|
assert actual["esphome"]["libraries"][0] == "Wire"
|
||||||
assert actual["esphome"]["board"] == "nodemcu"
|
assert actual["esphome"]["board"] == "nodemcu"
|
||||||
assert actual["wifi"]["ssid"] == "my_custom_ssid"
|
assert actual["wifi"]["ssid"] == "my_custom_ssid"
|
||||||
|
|
||||||
|
|
||||||
|
def test_loading_a_broken_yaml_file(fixture_path):
|
||||||
|
"""Ensure we fallback to pure python to give good errors."""
|
||||||
|
yaml_file = fixture_path / "yaml_util" / "broken_includetest.yaml"
|
||||||
|
|
||||||
|
try:
|
||||||
|
yaml_util.load_yaml(yaml_file)
|
||||||
|
except EsphomeError as err:
|
||||||
|
assert "broken_included.yaml" in str(err)
|
||||||
|
|||||||
Reference in New Issue
Block a user