Compare commits

...

15 Commits

Author SHA1 Message Date
J. Nick Koston
595ee4da39 add bluetooth proxy stats 2025-05-29 12:13:48 -05:00
Keith Burzinski
4031077f6d [dht] Clean-up, shorten some log messages (#8949) 2025-05-29 21:37:41 +12:00
J. Nick Koston
fd72a64053 Redundant Log Messages Cleanup (#8944)
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
2025-05-29 09:36:23 +00:00
Jesse Hills
959a8b91bd [demo] FIx some of the entities (#8943) 2025-05-29 03:22:46 -05:00
Keith Burzinski
44f1ff10e6 Introduce "communication failed" log macro (#8939) 2025-05-29 01:59:38 -05:00
Jesse Hills
64e4589f4e [esp32] Regenerate boards from recommended platform version (#8938) 2025-05-29 05:21:05 +00:00
Kuba Szczodrzyński
20aba45cbe [rp2040] Allow changing watchdog timeout (#8868) 2025-05-29 17:15:26 +12:00
gotnone
0b1c5b825e [modbus] [modbus_controller] Fix server role read coil 0x1 crc (#8859)
Co-authored-by: Stanley Pinchak <stanley.pinchak@gmail.com>
2025-05-29 17:12:58 +12:00
Leicas
455624105b Add flip X and Y on inkplate6 component (#7904)
Co-authored-by: Antoine Weill--Duflos <antoine@haply.co>
Co-authored-by: David Sichau <sichau@inf.ethz.ch>
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
Co-authored-by: David Sichau <DavidSichau@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-05-29 17:10:06 +12:00
Jonathan Swoboda
7ac5746e0d Fix colors in update all (#8854) 2025-05-29 15:00:27 +12:00
Thomas Rupprecht
12997451f6 particle matter improvements (#8846) 2025-05-29 14:57:20 +12:00
J. Nick Koston
8c77e40695 Fix select() logging flood in very verbose mode (#8942) 2025-05-29 02:29:37 +00:00
Nate Clark
2ddd91acf2 [alarm_control_panel] BYPASS_AUTO option for Template Alarm Control Panel sensors left open when armed (#8795) 2025-05-29 14:22:26 +12:00
Keith Burzinski
729e49cdc3 [gcja5] Remove unused setup() method (#8935) 2025-05-29 14:01:00 +12:00
J. Nick Koston
d64b49cc13 Optimize plaintext API header reading to reduce system calls (#8941)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-05-28 20:46:23 -05:00
154 changed files with 903 additions and 466 deletions

View File

@@ -593,15 +593,20 @@ def command_update_all(args):
middle_text = f" {middle_text} "
width = len(click.unstyle(middle_text))
half_line = "=" * ((twidth - width) // 2)
click.echo(f"{half_line}{middle_text}{half_line}")
safe_print(f"{half_line}{middle_text}{half_line}")
for f in files:
print(f"Updating {color(AnsiFore.CYAN, f)}")
print("-" * twidth)
print()
rc = run_external_process(
"esphome", "--dashboard", "run", f, "--no-logs", "--device", "OTA"
)
safe_print(f"Updating {color(AnsiFore.CYAN, f)}")
safe_print("-" * twidth)
safe_print()
if CORE.dashboard:
rc = run_external_process(
"esphome", "--dashboard", "run", f, "--no-logs", "--device", "OTA"
)
else:
rc = run_external_process(
"esphome", "run", f, "--no-logs", "--device", "OTA"
)
if rc == 0:
print_bar(f"[{color(AnsiFore.BOLD_GREEN, 'SUCCESS')}] {f}")
success[f] = True
@@ -609,17 +614,17 @@ def command_update_all(args):
print_bar(f"[{color(AnsiFore.BOLD_RED, 'ERROR')}] {f}")
success[f] = False
print()
print()
print()
safe_print()
safe_print()
safe_print()
print_bar(f"[{color(AnsiFore.BOLD_WHITE, 'SUMMARY')}]")
failed = 0
for f in files:
if success[f]:
print(f" - {f}: {color(AnsiFore.GREEN, 'SUCCESS')}")
safe_print(f" - {f}: {color(AnsiFore.GREEN, 'SUCCESS')}")
else:
print(f" - {f}: {color(AnsiFore.BOLD_RED, 'FAILED')}")
safe_print(f" - {f}: {color(AnsiFore.BOLD_RED, 'FAILED')}")
failed += 1
return failed

View File

@@ -17,8 +17,6 @@ void ADS1115Component::setup() {
return;
}
ESP_LOGCONFIG(TAG, "Configuring ADS1115...");
uint16_t config = 0;
// Clear single-shot bit
// 0b0xxxxxxxxxxxxxxx
@@ -71,7 +69,7 @@ void ADS1115Component::dump_config() {
ESP_LOGCONFIG(TAG, "ADS1115:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with ADS1115 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}
float ADS1115Component::request_measurement(ADS1115Multiplexer multiplexer, ADS1115Gain gain,

View File

@@ -65,7 +65,7 @@ void AGS10Component::dump_config() {
case NONE:
break;
case COMMUNICATION_FAILED:
ESP_LOGE(TAG, "Communication with AGS10 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
break;
case CRC_CHECK_FAILED:
ESP_LOGE(TAG, "The crc check failed");

View File

@@ -55,7 +55,7 @@ void AHT10Component::setup() {
break;
}
if (error_code != i2c::ERROR_OK) {
ESP_LOGE(TAG, "Communication failed");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
this->mark_failed();
return;
}
@@ -64,7 +64,7 @@ void AHT10Component::setup() {
while (data & AHT10_STATUS_BUSY) {
delay(AHT10_DEFAULT_DELAY);
if (this->read(&data, 1) != i2c::ERROR_OK) {
ESP_LOGE(TAG, "Communication failed");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
this->mark_failed();
return;
}
@@ -117,7 +117,7 @@ void AHT10Component::read_data_() {
} else {
ESP_LOGD(TAG, "Invalid humidity, retrying...");
if (this->write(AHT10_MEASURE_CMD, sizeof(AHT10_MEASURE_CMD)) != i2c::ERROR_OK) {
this->status_set_warning("Communication failed");
this->status_set_warning(ESP_LOG_MSG_COMM_FAIL);
}
this->restart_read_();
return;
@@ -148,7 +148,7 @@ void AHT10Component::update() {
return;
this->start_time_ = millis();
if (this->write(AHT10_MEASURE_CMD, sizeof(AHT10_MEASURE_CMD)) != i2c::ERROR_OK) {
this->status_set_warning("Communication failed");
this->status_set_warning(ESP_LOG_MSG_COMM_FAIL);
return;
}
this->restart_read_();
@@ -160,7 +160,7 @@ void AHT10Component::dump_config() {
ESP_LOGCONFIG(TAG, "AHT10:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication failed");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);

View File

@@ -113,7 +113,7 @@ void AIC3204::dump_config() {
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with AIC3204 failed");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}

View File

@@ -188,7 +188,7 @@ void AM2315C::dump_config() {
ESP_LOGCONFIG(TAG, "AM2315C:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with AM2315C failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);

View File

@@ -47,7 +47,7 @@ void AM2320Component::dump_config() {
ESP_LOGD(TAG, "AM2320:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with AM2320 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);

View File

@@ -97,7 +97,7 @@ void APDS9306::dump_config() {
if (this->is_failed()) {
switch (this->error_code_) {
case COMMUNICATION_FAILED:
ESP_LOGE(TAG, "Communication with APDS9306 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
break;
case WRONG_ID:
ESP_LOGE(TAG, "APDS9306 has invalid id!");

View File

@@ -141,7 +141,7 @@ void APDS9960::dump_config() {
if (this->is_failed()) {
switch (this->error_code_) {
case COMMUNICATION_FAILED:
ESP_LOGE(TAG, "Communication with APDS9960 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
break;
case WRONG_ID:
ESP_LOGE(TAG, "APDS9960 has invalid id!");

View File

@@ -831,12 +831,15 @@ APIError APIPlaintextFrameHelper::try_read_frame_(ParsedFrame *frame) {
// read header
while (!rx_header_parsed_) {
uint8_t data;
// Reading one byte at a time is fastest in practice for ESP32 when
// there is no data on the wire (which is the common case).
// This results in faster failure detection compared to
// attempting to read multiple bytes at once.
ssize_t received = this->socket_->read(&data, 1);
// Now that we know when the socket is ready, we can read up to 3 bytes
// into the rx_header_buf_ before we have to switch back to reading
// one byte at a time to ensure we don't read past the message and
// into the next one.
// Read directly into rx_header_buf_ at the current position
// Try to get to at least 3 bytes total (indicator + 2 varint bytes), then read one byte at a time
ssize_t received =
this->socket_->read(&rx_header_buf_[rx_header_buf_pos_], rx_header_buf_pos_ < 3 ? 3 - rx_header_buf_pos_ : 1);
if (received == -1) {
if (errno == EWOULDBLOCK || errno == EAGAIN) {
return APIError::WOULD_BLOCK;
@@ -850,51 +853,46 @@ APIError APIPlaintextFrameHelper::try_read_frame_(ParsedFrame *frame) {
return APIError::CONNECTION_CLOSED;
}
// Successfully read a byte
// Process byte according to current buffer position
if (rx_header_buf_pos_ == 0) { // Case 1: First byte (indicator byte)
if (data != 0x00) {
// If this was the first read, validate the indicator byte
if (rx_header_buf_pos_ == 0 && received > 0) {
if (rx_header_buf_[0] != 0x00) {
state_ = State::FAILED;
HELPER_LOG("Bad indicator byte %u", data);
HELPER_LOG("Bad indicator byte %u", rx_header_buf_[0]);
return APIError::BAD_INDICATOR;
}
// We don't store the indicator byte, just increment position
rx_header_buf_pos_ = 1; // Set to 1 directly
continue; // Need more bytes before we can parse
}
// Check buffer overflow before storing
if (rx_header_buf_pos_ == 5) { // Case 2: Buffer would overflow (5 bytes is max allowed)
rx_header_buf_pos_ += received;
// Check for buffer overflow
if (rx_header_buf_pos_ >= sizeof(rx_header_buf_)) {
state_ = State::FAILED;
HELPER_LOG("Header buffer overflow");
return APIError::BAD_DATA_PACKET;
}
// Store byte in buffer (adjust index to account for skipped indicator byte)
rx_header_buf_[rx_header_buf_pos_ - 1] = data;
// Increment position after storing
rx_header_buf_pos_++;
// Case 3: If we only have one varint byte, we need more
if (rx_header_buf_pos_ == 2) { // Have read indicator + 1 byte
continue; // Need more bytes before we can parse
// Need at least 3 bytes total (indicator + 2 varint bytes) before trying to parse
if (rx_header_buf_pos_ < 3) {
continue;
}
// At this point, we have at least 3 bytes total:
// - Validated indicator byte (0x00) but not stored
// - Validated indicator byte (0x00) stored at position 0
// - At least 2 bytes in the buffer for the varints
// Buffer layout:
// First 1-3 bytes: Message size varint (variable length)
// [0]: indicator byte (0x00)
// [1-3]: Message size varint (variable length)
// - 2 bytes would only allow up to 16383, which is less than noise's UINT16_MAX (65535)
// - 3 bytes allows up to 2097151, ensuring we support at least as much as noise
// Remaining 1-2 bytes: Message type varint (variable length)
// [2-5]: Message type varint (variable length)
// We now attempt to parse both varints. If either is incomplete,
// we'll continue reading more bytes.
// Skip indicator byte at position 0
uint8_t varint_pos = 1;
uint32_t consumed = 0;
auto msg_size_varint = ProtoVarInt::parse(&rx_header_buf_[0], rx_header_buf_pos_ - 1, &consumed);
auto msg_size_varint = ProtoVarInt::parse(&rx_header_buf_[varint_pos], rx_header_buf_pos_ - varint_pos, &consumed);
if (!msg_size_varint.has_value()) {
// not enough data there yet
continue;
@@ -908,7 +906,10 @@ APIError APIPlaintextFrameHelper::try_read_frame_(ParsedFrame *frame) {
}
rx_header_parsed_len_ = msg_size_varint->as_uint16();
auto msg_type_varint = ProtoVarInt::parse(&rx_header_buf_[consumed], rx_header_buf_pos_ - 1 - consumed, &consumed);
// Move to next varint position
varint_pos += consumed;
auto msg_type_varint = ProtoVarInt::parse(&rx_header_buf_[varint_pos], rx_header_buf_pos_ - varint_pos, &consumed);
if (!msg_type_varint.has_value()) {
// not enough data there yet
continue;

View File

@@ -233,14 +233,14 @@ class APIPlaintextFrameHelper : public APIFrameHelper {
protected:
APIError try_read_frame_(ParsedFrame *frame);
// Fixed-size header buffer for plaintext protocol:
// We only need space for the two varints since we validate the indicator byte separately.
// We now store the indicator byte + the two varints.
// To match noise protocol's maximum message size (UINT16_MAX = 65535), we need:
// 3 bytes for message size varint (supports up to 2097151) + 2 bytes for message type varint
// 1 byte for indicator + 3 bytes for message size varint (supports up to 2097151) + 2 bytes for message type varint
//
// While varints could theoretically be up to 10 bytes each for 64-bit values,
// attempting to process messages with headers that large would likely crash the
// ESP32 due to memory constraints.
uint8_t rx_header_buf_[5]; // 5 bytes for varints (3 for size + 2 for type)
uint8_t rx_header_buf_[6]; // 1 byte indicator + 5 bytes for varints (3 for size + 2 for type)
uint8_t rx_header_buf_pos_ = 0;
bool rx_header_parsed_ = false;
uint16_t rx_header_parsed_type_ = 0;

View File

@@ -157,7 +157,7 @@ void APIServer::loop() {
const uint32_t now = millis();
if (!this->is_connected()) {
if (now - this->last_connected_ > this->reboot_timeout_) {
ESP_LOGE(TAG, "No client connected to API. Rebooting...");
ESP_LOGE(TAG, "No client connected; rebooting");
App.reboot();
}
this->status_set_warning();

View File

@@ -91,7 +91,7 @@ void AS5600Component::dump_config() {
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with AS5600 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
return;
}

View File

@@ -38,7 +38,7 @@ void AS7341Component::dump_config() {
ESP_LOGCONFIG(TAG, "AS7341:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with AS7341 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
ESP_LOGCONFIG(TAG, " Gain: %u", get_gain());

View File

@@ -135,7 +135,7 @@ void ATM90E26Component::dump_config() {
ESP_LOGCONFIG("", "ATM90E26:");
LOG_PIN(" CS Pin: ", this->cs_);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with ATM90E26 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
LOG_SENSOR(" ", "Voltage A", this->voltage_sensor_);

View File

@@ -217,7 +217,7 @@ void ATM90E32Component::dump_config() {
ESP_LOGCONFIG("", "ATM90E32:");
LOG_PIN(" CS Pin: ", this->cs_);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with ATM90E32 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
LOG_SENSOR(" ", "Voltage A", this->phase_[PHASEA].voltage_sensor_);

View File

@@ -118,7 +118,7 @@ void BH1750Sensor::dump_config() {
LOG_SENSOR("", "BH1750", this);
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with BH1750 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL_FOR, this->get_name().c_str());
}
LOG_UPDATE_INTERVAL(this);

View File

@@ -4,6 +4,9 @@
#include "esphome/core/macros.h"
#include "esphome/core/application.h"
#include <algorithm>
#include <cinttypes>
#ifdef USE_ESP32
namespace esphome {
@@ -46,9 +49,16 @@ bool BluetoothProxy::parse_device(const esp32_ble_tracker::ESPBTDevice &device)
if (!api::global_api_server->is_connected() || this->api_connection_ == nullptr || this->raw_advertisements_)
return false;
// Measure time for processing single device
const uint32_t start_time = millis();
ESP_LOGV(TAG, "Proxying packet from %s - %s. RSSI: %d dB", device.get_name().c_str(), device.address_str().c_str(),
device.get_rssi());
this->send_api_packet_(device);
const uint32_t duration = millis() - start_time;
this->section_stats_["parse_device"].record_time(duration);
return true;
}
@@ -62,6 +72,9 @@ bool BluetoothProxy::parse_devices(esp_ble_gap_cb_param_t::ble_scan_result_evt_p
if (!api::global_api_server->is_connected() || this->api_connection_ == nullptr || !this->raw_advertisements_)
return false;
// Measure time for processing batch of devices
const uint32_t start_time = millis();
// Get the batch buffer reference
auto &batch_buffer = get_batch_buffer();
@@ -93,6 +106,9 @@ bool BluetoothProxy::parse_devices(esp_ble_gap_cb_param_t::ble_scan_result_evt_p
this->flush_pending_advertisements();
}
const uint32_t duration = millis() - start_time;
this->section_stats_["parse_devices"].record_time(duration);
return true;
}
@@ -101,12 +117,52 @@ void BluetoothProxy::flush_pending_advertisements() {
if (batch_buffer.empty() || !api::global_api_server->is_connected() || this->api_connection_ == nullptr)
return;
// Measure time for flushing advertisements
const uint32_t start_time = millis();
// Track the batch size for analysis
size_t batch_size = batch_buffer.size();
// Measure swap operation
uint32_t swap_start = millis();
api::BluetoothLERawAdvertisementsResponse resp;
resp.advertisements.swap(batch_buffer);
uint32_t swap_duration = millis() - swap_start;
if (swap_duration > 0) {
this->section_stats_["flush_swap"].record_time(swap_duration);
}
// Measure API send operation
uint32_t send_start = millis();
this->api_connection_->send_bluetooth_le_raw_advertisements_response(resp);
uint32_t send_duration = millis() - send_start;
this->section_stats_["flush_api_send"].record_time(send_duration);
const uint32_t duration = millis() - start_time;
this->section_stats_["flush_advertisements"].record_time(duration);
// Log if this was a particularly slow flush
if (duration > 10) {
ESP_LOGW(TAG, "Slow flush: %dms for %d advertisements", duration, batch_size);
}
// Track average advertisements per flush
static uint32_t total_ads_flushed = 0;
static uint32_t total_flushes = 0;
total_ads_flushed += batch_size;
total_flushes++;
if (total_flushes % 100 == 0) {
float avg_ads_per_flush = static_cast<float>(total_ads_flushed) / total_flushes;
ESP_LOGD(TAG, "Avg advertisements per flush: %.2f (total: %d ads in %d flushes)", avg_ads_per_flush,
total_ads_flushed, total_flushes);
}
}
void BluetoothProxy::send_api_packet_(const esp32_ble_tracker::ESPBTDevice &device) {
// Measure time for sending API packet
const uint32_t start_time = millis();
api::BluetoothLEAdvertisementResponse resp;
resp.address = device.address_uint64();
resp.address_type = device.get_address_type();
@@ -142,6 +198,9 @@ void BluetoothProxy::send_api_packet_(const esp32_ble_tracker::ESPBTDevice &devi
}
this->api_connection_->send_bluetooth_le_advertisement(resp);
const uint32_t duration = millis() - start_time;
this->section_stats_["send_api_packet"].record_time(duration);
}
void BluetoothProxy::dump_config() {
@@ -149,6 +208,8 @@ void BluetoothProxy::dump_config() {
ESP_LOGCONFIG(TAG, " Active: %s", YESNO(this->active_));
ESP_LOGCONFIG(TAG, " Connections: %d", this->connections_.size());
ESP_LOGCONFIG(TAG, " Raw advertisements: %s", YESNO(this->raw_advertisements_));
ESP_LOGCONFIG(TAG, " Stats enabled: %s", YESNO(this->stats_enabled_));
ESP_LOGCONFIG(TAG, " Stats interval: %" PRIu32 "ms", this->stats_log_interval_);
}
int BluetoothProxy::get_bluetooth_connections_free() {
@@ -166,6 +227,9 @@ int BluetoothProxy::get_bluetooth_connections_free() {
}
void BluetoothProxy::loop() {
// Measure total time for entire loop function
const uint32_t loop_start_time = millis();
if (!api::global_api_server->is_connected() || this->api_connection_ == nullptr) {
for (auto *connection : this->connections_) {
if (connection->get_address() != 0) {
@@ -175,17 +239,28 @@ void BluetoothProxy::loop() {
return;
}
// Flush any pending BLE advertisements that have been accumulated but not yet sent
const uint32_t now = millis();
uint32_t start_time;
uint32_t duration;
// Section: Flush advertisements
if (this->raw_advertisements_) {
static uint32_t last_flush_time = 0;
uint32_t now = App.get_loop_component_start_time();
uint32_t app_time = App.get_loop_component_start_time();
// Flush accumulated advertisements every 100ms
if (now - last_flush_time >= 100) {
if (app_time - last_flush_time >= 100) {
start_time = millis();
this->flush_pending_advertisements();
last_flush_time = now;
duration = millis() - start_time;
this->section_stats_["loop_flush_ads"].record_time(duration);
last_flush_time = app_time;
}
}
// Section: Service discovery
start_time = millis();
bool did_service_discovery = false;
for (auto *connection : this->connections_) {
if (connection->send_service_ == connection->service_count_) {
connection->send_service_ = DONE_SENDING_SERVICES;
@@ -194,7 +269,9 @@ void BluetoothProxy::loop() {
connection->connection_type_ == espbt::ConnectionType::V3_WITHOUT_CACHE) {
connection->release_services();
}
did_service_discovery = true;
} else if (connection->send_service_ >= 0) {
did_service_discovery = true;
esp_gattc_service_elem_t service_result;
uint16_t service_count = 1;
esp_gatt_status_t service_status =
@@ -303,6 +380,27 @@ void BluetoothProxy::loop() {
this->api_connection_->send_bluetooth_gatt_get_services_response(resp);
}
}
if (did_service_discovery) {
duration = millis() - start_time;
this->section_stats_["service_discovery"].record_time(duration);
}
// Log stats periodically
if (this->stats_enabled_) {
// If next_stats_log_ is 0, initialize it
if (this->next_stats_log_ == 0) {
this->next_stats_log_ = now + this->stats_log_interval_;
} else if (now >= this->next_stats_log_) {
this->log_section_stats_();
this->reset_section_stats_();
this->next_stats_log_ = now + this->stats_log_interval_;
}
}
// Record total loop execution time
const uint32_t total_loop_duration = millis() - loop_start_time;
this->section_stats_["total_loop"].record_time(total_loop_duration);
}
esp32_ble_tracker::AdvertisementParserType BluetoothProxy::get_advertisement_parser_type() {
@@ -337,6 +435,9 @@ BluetoothConnection *BluetoothProxy::get_connection_(uint64_t address, bool rese
}
void BluetoothProxy::bluetooth_device_request(const api::BluetoothDeviceRequest &msg) {
// Measure time for processing device requests
const uint32_t start_time = millis();
switch (msg.request_type) {
case api::enums::BLUETOOTH_DEVICE_REQUEST_TYPE_CONNECT_V3_WITH_CACHE:
case api::enums::BLUETOOTH_DEVICE_REQUEST_TYPE_CONNECT_V3_WITHOUT_CACHE:
@@ -458,6 +559,9 @@ void BluetoothProxy::bluetooth_device_request(const api::BluetoothDeviceRequest
break;
}
}
const uint32_t duration = millis() - start_time;
this->section_stats_["device_request"].record_time(duration);
}
void BluetoothProxy::bluetooth_gatt_read(const api::BluetoothGATTReadRequest &msg) {
@@ -640,6 +744,74 @@ void BluetoothProxy::bluetooth_scanner_set_mode(bool active) {
true); // Set this to true to automatically start scanning again when it has cleaned up.
}
void BluetoothProxy::log_section_stats_() {
const char *STATS_TAG = "bluetooth_proxy.stats";
ESP_LOGI(STATS_TAG,
"Logging Bluetooth Proxy section stats now (current time: %" PRIu32 ", scheduled time: %" PRIu32 ")",
millis(), this->next_stats_log_);
ESP_LOGI(STATS_TAG, "Stats collection status: enabled=%d, sections=%zu", this->stats_enabled_,
this->section_stats_.size());
// Check if we have minimal data
bool has_data = false;
for (const auto &it : this->section_stats_) {
if (it.second.get_period_count() > 0) {
has_data = true;
break;
}
}
if (!has_data) {
ESP_LOGI(STATS_TAG, "No stats data collected in this period");
return;
}
ESP_LOGI(STATS_TAG, "Bluetooth Proxy Section Runtime Statistics");
ESP_LOGI(STATS_TAG, "Period stats (last %" PRIu32 "ms):", this->stats_log_interval_);
// First collect stats we want to display
std::vector<std::pair<std::string, const BluetoothProxySectionStats *>> stats_to_display;
for (const auto &it : this->section_stats_) {
const BluetoothProxySectionStats &stats = it.second;
if (stats.get_period_count() > 0) {
stats_to_display.push_back({it.first, &stats});
}
}
// Sort by period runtime (descending)
std::sort(stats_to_display.begin(), stats_to_display.end(), [](const auto &a, const auto &b) {
return a.second->get_period_time_ms() > b.second->get_period_time_ms();
});
// Log top sections by period runtime
for (const auto &it : stats_to_display) {
const std::string &section_name = it.first;
const BluetoothProxySectionStats &stats = *it.second;
ESP_LOGI(STATS_TAG, " %-25s: count=%-6" PRIu32 " runtime=%-8" PRIu32 "ms avg=%-6.2fms max=%-6" PRIu32 "ms",
section_name.c_str(), stats.get_period_count(), stats.get_period_time_ms(), stats.get_period_avg_time_ms(),
stats.get_period_max_time_ms());
}
// Log total accumulated stats
ESP_LOGI(STATS_TAG, "Total accumulated stats:");
for (const auto &it : stats_to_display) {
const std::string &section_name = it.first;
const BluetoothProxySectionStats &stats = *it.second;
ESP_LOGI(STATS_TAG, " %-25s: count=%-8" PRIu32 " runtime=%-10" PRIu32 "ms avg=%-6.2fms max=%-6" PRIu32 "ms",
section_name.c_str(), stats.get_total_count(), stats.get_total_time_ms(), stats.get_total_avg_time_ms(),
stats.get_total_max_time_ms());
}
}
void BluetoothProxy::reset_section_stats_() {
for (auto &it : this->section_stats_) {
it.second.reset_period_stats();
}
}
BluetoothProxy *global_bluetooth_proxy = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
} // namespace bluetooth_proxy

View File

@@ -4,6 +4,7 @@
#include <map>
#include <vector>
#include <string>
#include "esphome/components/api/api_connection.h"
#include "esphome/components/api/api_pb2.h"
@@ -12,6 +13,8 @@
#include "esphome/core/automation.h"
#include "esphome/core/component.h"
#include "esphome/core/defines.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
#include "bluetooth_connection.h"
@@ -25,6 +28,62 @@ static const esp_err_t ESP_GATT_NOT_CONNECTED = -1;
using namespace esp32_ble_client;
// Stats class for tracking section performance
class BluetoothProxySectionStats {
public:
BluetoothProxySectionStats()
: period_count_(0),
total_count_(0),
period_time_ms_(0),
total_time_ms_(0),
period_max_time_ms_(0),
total_max_time_ms_(0) {}
void record_time(uint32_t duration_ms) {
// Update period counters
this->period_count_++;
this->period_time_ms_ += duration_ms;
if (duration_ms > this->period_max_time_ms_)
this->period_max_time_ms_ = duration_ms;
// Update total counters
this->total_count_++;
this->total_time_ms_ += duration_ms;
if (duration_ms > this->total_max_time_ms_)
this->total_max_time_ms_ = duration_ms;
}
void reset_period_stats() {
this->period_count_ = 0;
this->period_time_ms_ = 0;
this->period_max_time_ms_ = 0;
}
// Getters for period stats
uint32_t get_period_count() const { return this->period_count_; }
uint32_t get_period_time_ms() const { return this->period_time_ms_; }
uint32_t get_period_max_time_ms() const { return this->period_max_time_ms_; }
float get_period_avg_time_ms() const {
return this->period_count_ > 0 ? static_cast<float>(this->period_time_ms_) / this->period_count_ : 0.0f;
}
// Getters for total stats
uint32_t get_total_count() const { return this->total_count_; }
uint32_t get_total_time_ms() const { return this->total_time_ms_; }
uint32_t get_total_max_time_ms() const { return this->total_max_time_ms_; }
float get_total_avg_time_ms() const {
return this->total_count_ > 0 ? static_cast<float>(this->total_time_ms_) / this->total_count_ : 0.0f;
}
private:
uint32_t period_count_;
uint32_t total_count_;
uint32_t period_time_ms_;
uint32_t total_time_ms_;
uint32_t period_max_time_ms_;
uint32_t total_max_time_ms_;
};
// Legacy versions:
// Version 1: Initial version without active connections
// Version 2: Support for active connections
@@ -139,6 +198,14 @@ class BluetoothProxy : public esp32_ble_tracker::ESPBTDeviceListener, public Com
std::vector<BluetoothConnection *> connections_{};
api::APIConnection *api_connection_{nullptr};
bool raw_advertisements_{false};
// Performance statistics tracking
std::map<std::string, BluetoothProxySectionStats> section_stats_;
uint32_t stats_log_interval_{60000}; // 60 seconds default
uint32_t next_stats_log_{0};
bool stats_enabled_{true};
void log_section_stats_();
void reset_section_stats_();
};
extern BluetoothProxy *global_bluetooth_proxy; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)

View File

@@ -182,7 +182,7 @@ void BME280Component::dump_config() {
ESP_LOGCONFIG(TAG, "BME280:");
switch (this->error_code_) {
case COMMUNICATION_FAILED:
ESP_LOGE(TAG, "Communication with BME280 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
break;
case WRONG_CHIP_ID:
ESP_LOGE(TAG, "BME280 has wrong chip ID! Is it a BME280?");

View File

@@ -215,7 +215,7 @@ void BME680Component::dump_config() {
ESP_LOGCONFIG(TAG, "BME680:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with BME680 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
ESP_LOGCONFIG(TAG, " IIR Filter: %s", iir_filter_to_str(this->iir_filter_));
LOG_UPDATE_INTERVAL(this);
@@ -307,7 +307,7 @@ void BME680Component::read_data_() {
this->humidity_sensor_->publish_state(NAN);
if (this->gas_resistance_sensor_ != nullptr)
this->gas_resistance_sensor_->publish_state(NAN);
ESP_LOGW(TAG, "Communication with BME680 failed!");
ESP_LOGW(TAG, ESP_LOG_MSG_COMM_FAIL);
this->status_set_warning();
return;
}

View File

@@ -189,7 +189,7 @@ void BMI160Component::dump_config() {
ESP_LOGCONFIG(TAG, "BMI160:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with BMI160 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
LOG_SENSOR(" ", "Acceleration X", this->accel_x_sensor_);

View File

@@ -132,7 +132,7 @@ void BMP280Component::dump_config() {
ESP_LOGCONFIG(TAG, "BMP280:");
switch (this->error_code_) {
case COMMUNICATION_FAILED:
ESP_LOGE(TAG, "Communication with BMP280 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
break;
case WRONG_CHIP_ID:
ESP_LOGE(TAG, "BMP280 has wrong chip ID! Is it a BME280?");

View File

@@ -154,7 +154,7 @@ void BMP3XXComponent::dump_config() {
case NONE:
break;
case ERROR_COMMUNICATION_FAILED:
ESP_LOGE(TAG, "Communication with BMP3XX failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
break;
case ERROR_WRONG_CHIP_ID:
ESP_LOGE(

View File

@@ -29,7 +29,7 @@ void CaptivePortal::handle_config(AsyncWebServerRequest *request) {
void CaptivePortal::handle_wifisave(AsyncWebServerRequest *request) {
std::string ssid = request->arg("ssid").c_str();
std::string psk = request->arg("psk").c_str();
ESP_LOGI(TAG, "Captive Portal Requested WiFi Settings Change:");
ESP_LOGI(TAG, "Requested WiFi Settings Change:");
ESP_LOGI(TAG, " SSID='%s'", ssid.c_str());
ESP_LOGI(TAG, " Password=" LOG_SECRET("'%s'"), psk.c_str());
wifi::global_wifi_component->save_wifi_sta(ssid, psk);

View File

@@ -163,7 +163,7 @@ void CCS811Component::dump_config() {
if (this->is_failed()) {
switch (this->error_code_) {
case COMMUNICATION_FAILED:
ESP_LOGW(TAG, "Communication failed! Is the sensor connected?");
ESP_LOGW(TAG, ESP_LOG_MSG_COMM_FAIL);
break;
case INVALID_ID:
ESP_LOGW(TAG, "Sensor reported an invalid ID. Is this a CCS811?");

View File

@@ -37,7 +37,7 @@ void CH422GComponent::dump_config() {
ESP_LOGCONFIG(TAG, "CH422G:");
LOG_I2C_DEVICE(this)
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with CH422G failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}

View File

@@ -23,7 +23,7 @@ void CM1106Component::setup() {
ESP_LOGCONFIG(TAG, "Running setup");
uint8_t response[8] = {0};
if (!this->cm1106_write_command_(C_M1106_CMD_GET_CO2, sizeof(C_M1106_CMD_GET_CO2), response, sizeof(response))) {
ESP_LOGE(TAG, "Communication with CM1106 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
this->mark_failed();
return;
}
@@ -104,7 +104,7 @@ void CM1106Component::dump_config() {
LOG_SENSOR(" ", "CO2", this->co2_sensor_);
this->check_uart_settings(9600);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with CM1106 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}

View File

@@ -57,7 +57,7 @@ void CSE7761Component::setup() {
void CSE7761Component::dump_config() {
ESP_LOGCONFIG(TAG, "CSE7761:");
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with CSE7761 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
this->check_uart_settings(38400, 1, uart::UART_CONFIG_PARITY_EVEN, 8);

View File

@@ -15,10 +15,10 @@ void DeepSleepComponent::setup() {
const optional<uint32_t> run_duration = get_run_duration_();
if (run_duration.has_value()) {
ESP_LOGI(TAG, "Scheduling Deep Sleep to start in %" PRIu32 " ms", *run_duration);
ESP_LOGI(TAG, "Scheduling in %" PRIu32 " ms", *run_duration);
this->set_timeout(*run_duration, [this]() { this->begin_sleep(); });
} else {
ESP_LOGD(TAG, "Not scheduling Deep Sleep, as no run duration is configured.");
ESP_LOGD(TAG, "Not scheduling; no run duration configured");
}
}
@@ -57,7 +57,7 @@ void DeepSleepComponent::begin_sleep(bool manual) {
return;
}
ESP_LOGI(TAG, "Beginning Deep Sleep");
ESP_LOGI(TAG, "Beginning sleep");
if (this->sleep_duration_.has_value()) {
ESP_LOGI(TAG, "Sleeping for %" PRId64 "us", *this->sleep_duration_);
}

View File

@@ -59,7 +59,7 @@ bool DeepSleepComponent::prepare_to_sleep_() {
// Defer deep sleep until inactive
if (!this->next_enter_deep_sleep_) {
this->status_set_warning();
ESP_LOGW(TAG, "Waiting wakeup pin state change to enter deep sleep...");
ESP_LOGW(TAG, "Waiting for wakeup pin state change");
}
this->next_enter_deep_sleep_ = true;
return false;

View File

@@ -154,10 +154,6 @@ NUMBER_TYPES = {
2: DemoNumberType.TYPE_2,
3: DemoNumberType.TYPE_3,
}
SELECT_TYPES = {
1: DemoSelectType.TYPE_1,
2: DemoSelectType.TYPE_2,
}
TEXT_TYPES = {
1: DemoTextType.TYPE_1,
2: DemoTextType.TYPE_2,
@@ -439,18 +435,15 @@ CONFIG_SCHEMA = cv.Schema(
{
CONF_NAME: "Demo Select 1",
CONF_OPTIONS: ["Option 1", "Option 2", "Option 3"],
CONF_TYPE: 1,
},
{
CONF_NAME: "Demo Select 2",
CONF_OPTIONS: ["Option A", "Option B", "Option C"],
CONF_TYPE: 2,
},
],
): [
select.select_schema(DemoSelect).extend(
{
cv.Required(CONF_TYPE): cv.enum(SELECT_TYPES, int=True),
cv.Required(CONF_OPTIONS): cv.ensure_list(cv.string_strict),
}
)
@@ -560,6 +553,7 @@ CONFIG_SCHEMA = cv.Schema(
async def to_code(config):
for conf in config[CONF_ALARM_CONTROL_PANELS]:
var = await alarm_control_panel.new_alarm_control_panel(conf)
cg.add(var.set_type(conf[CONF_TYPE]))
await cg.register_component(var, conf)
for conf in config[CONF_BINARY_SENSORS]:

View File

@@ -27,19 +27,23 @@ class DemoValve : public valve::Valve {
protected:
void control(const valve::ValveCall &call) override {
if (call.get_position().has_value()) {
this->publish_state(*call.get_position());
this->position = *call.get_position();
this->publish_state();
return;
} else if (call.get_toggle().has_value()) {
if (call.get_toggle().value()) {
if (this->position == valve::VALVE_OPEN) {
this->publish_state(valve::VALVE_CLOSED);
this->position = valve::VALVE_CLOSED;
this->publish_state();
} else {
this->publish_state(valve::VALVE_OPEN);
this->position = valve::VALVE_OPEN;
this->publish_state();
}
}
return;
} else if (call.get_stop()) {
this->publish_state(this->position); // Keep the current position
this->current_operation = valve::VALVE_OPERATION_IDLE;
this->publish_state(); // Keep the current position
return;
}
}

View File

@@ -13,20 +13,14 @@ void DHT::setup() {
this->pin_->setup();
this->pin_->digital_write(true);
}
void DHT::dump_config() {
ESP_LOGCONFIG(TAG, "DHT:");
LOG_PIN(" Pin: ", this->pin_);
if (this->is_auto_detect_) {
ESP_LOGCONFIG(TAG, " Auto-detected model: %s", this->model_ == DHT_MODEL_DHT11 ? "DHT11" : "DHT22");
} else if (this->model_ == DHT_MODEL_DHT11) {
ESP_LOGCONFIG(TAG, " Model: DHT11");
} else {
ESP_LOGCONFIG(TAG, " Model: DHT22 (or equivalent)");
}
ESP_LOGCONFIG(TAG, " Internal Pull-up: %s", ONOFF(this->pin_->get_flags() & gpio::FLAG_PULLUP));
ESP_LOGCONFIG(TAG, " %sModel: %s", this->is_auto_detect_ ? "Auto-detected " : "",
this->model_ == DHT_MODEL_DHT11 ? "DHT11" : "DHT22 or equivalent");
ESP_LOGCONFIG(TAG, " Internal pull-up: %s", ONOFF(this->pin_->get_flags() & gpio::FLAG_PULLUP));
LOG_UPDATE_INTERVAL(this);
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);
}
@@ -46,7 +40,7 @@ void DHT::update() {
}
if (success) {
ESP_LOGD(TAG, "Got Temperature=%.1f°C Humidity=%.1f%%", temperature, humidity);
ESP_LOGD(TAG, "Temperature %.1f°C Humidity %.1f%%", temperature, humidity);
if (this->temperature_sensor_ != nullptr)
this->temperature_sensor_->publish_state(temperature);
@@ -54,11 +48,8 @@ void DHT::update() {
this->humidity_sensor_->publish_state(humidity);
this->status_clear_warning();
} else {
const char *str = "";
if (this->is_auto_detect_) {
str = " and consider manually specifying the DHT model using the model option";
}
ESP_LOGW(TAG, "Invalid readings! Please check your wiring (pull-up resistor, pin number)%s.", str);
ESP_LOGW(TAG, "Invalid readings! Check pin number and pull-up resistor%s.",
this->is_auto_detect_ ? " and try manually specifying the model" : "");
if (this->temperature_sensor_ != nullptr)
this->temperature_sensor_->publish_state(NAN);
if (this->humidity_sensor_ != nullptr)
@@ -68,10 +59,12 @@ void DHT::update() {
}
float DHT::get_setup_priority() const { return setup_priority::DATA; }
void DHT::set_dht_model(DHTModel model) {
this->model_ = model;
this->is_auto_detect_ = model == DHT_MODEL_AUTO_DETECT;
}
bool HOT IRAM_ATTR DHT::read_sensor_(float *temperature, float *humidity, bool report_errors) {
*humidity = NAN;
*temperature = NAN;
@@ -121,9 +114,9 @@ bool HOT IRAM_ATTR DHT::read_sensor_(float *temperature, float *humidity, bool r
while (!this->pin_->digital_read()) {
if (micros() - start_time > 90) {
if (i < 0) {
error_code = 1;
error_code = 1; // line didn't clear
} else {
error_code = 2;
error_code = 2; // rising edge for bit i timeout
}
break;
}
@@ -139,9 +132,9 @@ bool HOT IRAM_ATTR DHT::read_sensor_(float *temperature, float *humidity, bool r
end_time = micros();
if (end_time - start_time > 90) {
if (i < 0) {
error_code = 3;
error_code = 3; // requesting data failed
} else {
error_code = 4;
error_code = 4; // falling edge for bit i timeout
}
break;
}
@@ -166,22 +159,9 @@ bool HOT IRAM_ATTR DHT::read_sensor_(float *temperature, float *humidity, bool r
if (!report_errors && error_code != 0)
return false;
switch (error_code) {
case 1:
ESP_LOGW(TAG, "Waiting for DHT communication to clear failed!");
return false;
case 2:
ESP_LOGW(TAG, "Rising edge for bit %d failed!", i);
return false;
case 3:
ESP_LOGW(TAG, "Requesting data from DHT failed!");
return false;
case 4:
ESP_LOGW(TAG, "Falling edge for bit %d failed!", i);
return false;
case 0:
default:
break;
if (error_code) {
ESP_LOGW(TAG, ESP_LOG_MSG_COMM_FAIL);
return false;
}
ESP_LOGVV(TAG,
@@ -206,15 +186,15 @@ bool HOT IRAM_ATTR DHT::read_sensor_(float *temperature, float *humidity, bool r
if (checksum_a == data[4]) {
// Data format: 8bit integral RH data + 8bit decimal RH data + 8bit integral T data + 8bit decimal T data + 8bit
// check sum - some models always have 0 in the decimal part
const uint16_t raw_temperature = uint16_t(data[2]) * 10 + (data[3] & 0x7F);
*temperature = raw_temperature / 10.0f;
const uint16_t raw_temperature = static_cast<uint16_t>(data[2]) * 10 + (data[3] & 0x7F);
*temperature = static_cast<float>(raw_temperature) / 10.0f;
if ((data[3] & 0x80) != 0) {
// negative
*temperature *= -1;
}
const uint16_t raw_humidity = uint16_t(data[0]) * 10 + data[1];
*humidity = raw_humidity / 10.0f;
const uint16_t raw_humidity = static_cast<uint16_t>(data[0]) * 10 + data[1];
*humidity = static_cast<float>(raw_humidity) / 10.0f;
} else {
// For compatibility with DHT11 models which might only use 2 bytes checksums, only use the data from these two
// bytes
@@ -222,8 +202,8 @@ bool HOT IRAM_ATTR DHT::read_sensor_(float *temperature, float *humidity, bool r
*humidity = data[0];
}
} else {
uint16_t raw_humidity = (uint16_t(data[0] & 0xFF) << 8) | (data[1] & 0xFF);
uint16_t raw_temperature = (uint16_t(data[2] & 0xFF) << 8) | (data[3] & 0xFF);
uint16_t raw_humidity = encode_uint16(data[0], data[1]);
uint16_t raw_temperature = encode_uint16(data[2], data[3]);
if (raw_temperature & 0x8000) {
if (!(raw_temperature & 0x4000))
@@ -234,24 +214,23 @@ bool HOT IRAM_ATTR DHT::read_sensor_(float *temperature, float *humidity, bool r
if (raw_temperature == 1 && raw_humidity == 10) {
if (report_errors) {
ESP_LOGW(TAG, "Invalid temperature+humidity! Sensor reported 1°C and 1%% Hum");
ESP_LOGW(TAG, "Invalid data");
}
return false;
}
*humidity = raw_humidity * 0.1f;
if (*humidity > 100)
*humidity = static_cast<float>(raw_humidity) * 0.1f;
if (*humidity > 100.0f)
*humidity = NAN;
*temperature = int16_t(raw_temperature) * 0.1f;
*temperature = static_cast<int16_t>(raw_temperature) * 0.1f;
}
if (*temperature == 0.0f && (*humidity == 1.0f || *humidity == 2.0f)) {
if (report_errors) {
ESP_LOGW(TAG, "DHT reports invalid data. Is the update interval too high or the sensor damaged?");
ESP_LOGW(TAG, "Invalid data");
}
return false;
}
return true;
}

View File

@@ -45,7 +45,7 @@ void DHT12Component::dump_config() {
ESP_LOGD(TAG, "DHT12:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with DHT12 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);

View File

@@ -91,7 +91,7 @@ void DPS310Component::dump_config() {
ESP_LOGCONFIG(TAG, " Revision ID: %u", (this->prod_rev_id_ >> 4) & 0x0F);
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with DPS310 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);

View File

@@ -22,7 +22,7 @@ void DS1307Component::dump_config() {
ESP_LOGCONFIG(TAG, "DS1307:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with DS1307 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
ESP_LOGCONFIG(TAG, " Timezone: '%s'", this->timezone_.c_str());
}

View File

@@ -35,7 +35,7 @@ void EE895Component::dump_config() {
LOG_I2C_DEVICE(this);
switch (this->error_code_) {
case COMMUNICATION_FAILED:
ESP_LOGE(TAG, "Communication with EE895 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
break;
case CRC_CHECK_FAILED:
ESP_LOGE(TAG, "The crc check failed");

View File

@@ -94,7 +94,7 @@ void Emc2101Component::dump_config() {
ESP_LOGCONFIG(TAG, "Emc2101 component:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with EMC2101 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
ESP_LOGCONFIG(TAG, " Mode: %s", this->dac_mode_ ? "DAC" : "PWM");
if (this->dac_mode_) {
@@ -110,7 +110,7 @@ void Emc2101Component::set_duty_cycle(float value) {
uint8_t duty_cycle = remap(value, 0.0f, 1.0f, (uint8_t) 0, this->max_output_value_);
ESP_LOGD(TAG, "Setting duty fan setting to %02X", duty_cycle);
if (!this->write_byte(EMC2101_REGISTER_FAN_SETTING, duty_cycle)) {
ESP_LOGE(TAG, "Communication with EMC2101 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
this->status_set_warning();
return;
}
@@ -119,7 +119,7 @@ void Emc2101Component::set_duty_cycle(float value) {
float Emc2101Component::get_duty_cycle() {
uint8_t duty_cycle;
if (!this->read_byte(EMC2101_REGISTER_FAN_SETTING, &duty_cycle)) {
ESP_LOGE(TAG, "Communication with EMC2101 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
this->status_set_warning();
return NAN;
}
@@ -129,7 +129,7 @@ float Emc2101Component::get_duty_cycle() {
float Emc2101Component::get_internal_temperature() {
uint8_t temperature;
if (!this->read_byte(EMC2101_REGISTER_INTERNAL_TEMP, &temperature)) {
ESP_LOGE(TAG, "Communication with EMC2101 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
this->status_set_warning();
return NAN;
}
@@ -141,7 +141,7 @@ float Emc2101Component::get_external_temperature() {
uint8_t lsb, msb;
if (!this->read_byte(EMC2101_REGISTER_EXTERNAL_TEMP_MSB, &msb) ||
!this->read_byte(EMC2101_REGISTER_EXTERNAL_TEMP_LSB, &lsb)) {
ESP_LOGE(TAG, "Communication with EMC2101 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
this->status_set_warning();
return NAN;
}
@@ -155,7 +155,7 @@ float Emc2101Component::get_speed() {
// Read **LSB** first to match 'Data Read Interlock' behavior from 6.1 of datasheet
uint8_t lsb, msb;
if (!this->read_byte(EMC2101_REGISTER_TACH_LSB, &lsb) || !this->read_byte(EMC2101_REGISTER_TACH_MSB, &msb)) {
ESP_LOGE(TAG, "Communication with EMC2101 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
this->status_set_warning();
return NAN;
}

View File

@@ -279,7 +279,7 @@ void ENS160Component::dump_config() {
switch (this->error_code_) {
case COMMUNICATION_FAILED:
ESP_LOGE(TAG, "Communication failed! Is the sensor connected?");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
break;
case READ_FAILED:
ESP_LOGE(TAG, "Error reading from register");

View File

@@ -163,7 +163,7 @@ void ENS210Component::update() {
// Read T_VAL and H_VAL
if (!this->read_bytes(ENS210_REGISTER_T_VAL, data, 6)) {
ESP_LOGE(TAG, "Communication with ENS210 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
this->status_set_warning();
return;
}

View File

@@ -2,7 +2,6 @@ from .const import (
VARIANT_ESP32,
VARIANT_ESP32C2,
VARIANT_ESP32C3,
VARIANT_ESP32C5,
VARIANT_ESP32C6,
VARIANT_ESP32H2,
VARIANT_ESP32P4,
@@ -1340,17 +1339,7 @@ ESP32_BOARD_PINS = {
}
"""
BOARDS generated with:
git clone https://github.com/platformio/platform-espressif32
for x in platform-espressif32/boards/*.json; do
mcu=$(jq -r .build.mcu <"$x");
name=$(jq -r .name <"$x");
fname=$(basename "$x")
board="${fname%.*}"
variant=$(echo "$mcu" | tr '[:lower:]' '[:upper:]')
echo " \"$board\": {\"name\": \"$name\", \"variant\": VARIANT_${variant},},"
done | sort
BOARDS generated with script/generate-esp32-boards.py
"""
BOARDS = {
@@ -1362,6 +1351,10 @@ BOARDS = {
"name": "Adafruit pyCamera S3",
"variant": VARIANT_ESP32S3,
},
"adafruit_feather_esp32_v2": {
"name": "Adafruit Feather ESP32 V2",
"variant": VARIANT_ESP32,
},
"adafruit_feather_esp32c6": {
"name": "Adafruit Feather ESP32-C6",
"variant": VARIANT_ESP32C6,
@@ -1394,10 +1387,6 @@ BOARDS = {
"name": "Adafruit Feather ESP32-S3 TFT",
"variant": VARIANT_ESP32S3,
},
"adafruit_feather_esp32_v2": {
"name": "Adafruit Feather ESP32 V2",
"variant": VARIANT_ESP32,
},
"adafruit_funhouse_esp32s2": {
"name": "Adafruit FunHouse",
"variant": VARIANT_ESP32S2,
@@ -1422,14 +1411,14 @@ BOARDS = {
"name": "Adafruit Metro ESP32-S3",
"variant": VARIANT_ESP32S3,
},
"adafruit_qtpy_esp32c3": {
"name": "Adafruit QT Py ESP32-C3",
"variant": VARIANT_ESP32C3,
},
"adafruit_qtpy_esp32": {
"name": "Adafruit QT Py ESP32",
"variant": VARIANT_ESP32,
},
"adafruit_qtpy_esp32c3": {
"name": "Adafruit QT Py ESP32-C3",
"variant": VARIANT_ESP32C3,
},
"adafruit_qtpy_esp32s2": {
"name": "Adafruit QT Py ESP32-S2",
"variant": VARIANT_ESP32S2,
@@ -1478,14 +1467,14 @@ BOARDS = {
"name": "Smart Bee Data Logger",
"variant": VARIANT_ESP32S3,
},
"bee_motion_mini": {
"name": "Smart Bee Motion Mini",
"variant": VARIANT_ESP32C3,
},
"bee_motion": {
"name": "Smart Bee Motion",
"variant": VARIANT_ESP32S2,
},
"bee_motion_mini": {
"name": "Smart Bee Motion Mini",
"variant": VARIANT_ESP32C3,
},
"bee_motion_s3": {
"name": "Smart Bee Motion S3",
"variant": VARIANT_ESP32S3,
@@ -1518,6 +1507,10 @@ BOARDS = {
"name": "D-duino-32",
"variant": VARIANT_ESP32,
},
"deneyapkart": {
"name": "Deneyap Kart",
"variant": VARIANT_ESP32,
},
"deneyapkart1A": {
"name": "Deneyap Kart 1A",
"variant": VARIANT_ESP32,
@@ -1530,10 +1523,6 @@ BOARDS = {
"name": "Deneyap Kart G",
"variant": VARIANT_ESP32C3,
},
"deneyapkart": {
"name": "Deneyap Kart",
"variant": VARIANT_ESP32,
},
"deneyapmini": {
"name": "Deneyap Mini",
"variant": VARIANT_ESP32S2,
@@ -1574,8 +1563,8 @@ BOARDS = {
"name": "Seeed Studio Edgebox-ESP-100",
"variant": VARIANT_ESP32S3,
},
"esp320": {
"name": "Electronic SweetPeas ESP320",
"esp-wrover-kit": {
"name": "Espressif ESP-WROVER-KIT",
"variant": VARIANT_ESP32,
},
"esp32-c2-devkitm-1": {
@@ -1594,10 +1583,6 @@ BOARDS = {
"name": "Ai-Thinker ESP-C3-M1-I-Kit",
"variant": VARIANT_ESP32C3,
},
"esp32-c5-devkitc-1": {
"name": "Espressif ESP32-C5-DevKitC-1",
"variant": VARIANT_ESP32C5,
},
"esp32-c6-devkitc-1": {
"name": "Espressif ESP32-C6-DevKitC-1",
"variant": VARIANT_ESP32C6,
@@ -1606,26 +1591,10 @@ BOARDS = {
"name": "Espressif ESP32-C6-DevKitM-1",
"variant": VARIANT_ESP32C6,
},
"esp32cam": {
"name": "AI Thinker ESP32-CAM",
"variant": VARIANT_ESP32,
},
"esp32-devkitlipo": {
"name": "OLIMEX ESP32-DevKit-LiPo",
"variant": VARIANT_ESP32,
},
"esp32dev": {
"name": "Espressif ESP32 Dev Module",
"variant": VARIANT_ESP32,
},
"esp32doit-devkit-v1": {
"name": "DOIT ESP32 DEVKIT V1",
"variant": VARIANT_ESP32,
},
"esp32doit-espduino": {
"name": "DOIT ESPduino32",
"variant": VARIANT_ESP32,
},
"esp32-evb": {
"name": "OLIMEX ESP32-EVB",
"variant": VARIANT_ESP32,
@@ -1650,14 +1619,14 @@ BOARDS = {
"name": "Espressif ESP32-PICO-DevKitM-2",
"variant": VARIANT_ESP32,
},
"esp32-poe-iso": {
"name": "OLIMEX ESP32-PoE-ISO",
"variant": VARIANT_ESP32,
},
"esp32-poe": {
"name": "OLIMEX ESP32-PoE",
"variant": VARIANT_ESP32,
},
"esp32-poe-iso": {
"name": "OLIMEX ESP32-PoE-ISO",
"variant": VARIANT_ESP32,
},
"esp32-pro": {
"name": "OLIMEX ESP32-PRO",
"variant": VARIANT_ESP32,
@@ -1674,14 +1643,6 @@ BOARDS = {
"name": "Espressif ESP32-S2-Saola-1",
"variant": VARIANT_ESP32S2,
},
"esp32s3box": {
"name": "Espressif ESP32-S3-Box",
"variant": VARIANT_ESP32S3,
},
"esp32s3camlcd": {
"name": "ESP32S3 CAM LCD",
"variant": VARIANT_ESP32S3,
},
"esp32-s3-devkitc-1": {
"name": "Espressif ESP32-S3-DevKitC-1-N8 (8 MB QD, No PSRAM)",
"variant": VARIANT_ESP32S3,
@@ -1690,18 +1651,50 @@ BOARDS = {
"name": "Espressif ESP32-S3-DevKitM-1",
"variant": VARIANT_ESP32S3,
},
"esp32-solo1": {
"name": "Espressif Generic ESP32-solo1 4M Flash",
"variant": VARIANT_ESP32,
},
"esp320": {
"name": "Electronic SweetPeas ESP320",
"variant": VARIANT_ESP32,
},
"esp32cam": {
"name": "AI Thinker ESP32-CAM",
"variant": VARIANT_ESP32,
},
"esp32dev": {
"name": "Espressif ESP32 Dev Module",
"variant": VARIANT_ESP32,
},
"esp32doit-devkit-v1": {
"name": "DOIT ESP32 DEVKIT V1",
"variant": VARIANT_ESP32,
},
"esp32doit-espduino": {
"name": "DOIT ESPduino32",
"variant": VARIANT_ESP32,
},
"esp32s3_120_16_8-qio_opi": {
"name": "ESP32-S3 16MB QIO, 8MB OPI PSRAM",
"variant": VARIANT_ESP32S3,
},
"esp32s3_powerfeather": {
"name": "ESP32-S3 PowerFeather",
"variant": VARIANT_ESP32S3,
},
"esp32s3box": {
"name": "Espressif ESP32-S3-Box",
"variant": VARIANT_ESP32S3,
},
"esp32s3camlcd": {
"name": "ESP32S3 CAM LCD",
"variant": VARIANT_ESP32S3,
},
"esp32s3usbotg": {
"name": "Espressif ESP32-S3-USB-OTG",
"variant": VARIANT_ESP32S3,
},
"esp32-solo1": {
"name": "Espressif Generic ESP32-solo1 4M Flash",
"variant": VARIANT_ESP32,
},
"esp32thing": {
"name": "SparkFun ESP32 Thing",
"variant": VARIANT_ESP32,
@@ -1726,10 +1719,6 @@ BOARDS = {
"name": "ESPino32",
"variant": VARIANT_ESP32,
},
"esp-wrover-kit": {
"name": "Espressif ESP-WROVER-KIT",
"variant": VARIANT_ESP32,
},
"etboard": {
"name": "ETBoard",
"variant": VARIANT_ESP32,
@@ -1758,6 +1747,14 @@ BOARDS = {
"name": "Franzininho WiFi MSC",
"variant": VARIANT_ESP32S2,
},
"freenove_esp32_s3_wroom": {
"name": "Freenove ESP32-S3 WROOM N8R8 (8MB Flash / 8MB PSRAM)",
"variant": VARIANT_ESP32S3,
},
"freenove_esp32_wrover": {
"name": "Freenove ESP32-Wrover",
"variant": VARIANT_ESP32,
},
"frogboard": {
"name": "Frog Board ESP32",
"variant": VARIANT_ESP32,
@@ -1774,6 +1771,10 @@ BOARDS = {
"name": "Heltec WiFi Kit 32 (V3)",
"variant": VARIANT_ESP32S3,
},
"heltec_wifi_kit_32_v2": {
"name": "Heltec WiFi Kit 32 (V2)",
"variant": VARIANT_ESP32,
},
"heltec_wifi_lora_32": {
"name": "Heltec WiFi LoRa 32",
"variant": VARIANT_ESP32,
@@ -1786,14 +1787,14 @@ BOARDS = {
"name": "Heltec WiFi LoRa 32 (V3)",
"variant": VARIANT_ESP32S3,
},
"heltec_wireless_stick_lite": {
"name": "Heltec Wireless Stick Lite",
"variant": VARIANT_ESP32,
},
"heltec_wireless_stick": {
"name": "Heltec Wireless Stick",
"variant": VARIANT_ESP32,
},
"heltec_wireless_stick_lite": {
"name": "Heltec Wireless Stick Lite",
"variant": VARIANT_ESP32,
},
"honeylemon": {
"name": "HONEYLemon",
"variant": VARIANT_ESP32,
@@ -1806,6 +1807,14 @@ BOARDS = {
"name": "Hornbill ESP32 Minima",
"variant": VARIANT_ESP32,
},
"huidu_hd_wf2": {
"name": "Huidu HD-WF2",
"variant": VARIANT_ESP32S3,
},
"huidu_hd_wf4": {
"name": "Huidu HD-WF4",
"variant": VARIANT_ESP32S3,
},
"imbrios-logsens-v1p1": {
"name": "Imbrios LogSens V1P1",
"variant": VARIANT_ESP32,
@@ -1838,6 +1847,10 @@ BOARDS = {
"name": "ArtronShop IOXESP32PS",
"variant": VARIANT_ESP32,
},
"jczn_2432s028r": {
"name": "ESP32-2432S028R CYD",
"variant": VARIANT_ESP32,
},
"kb32-ft": {
"name": "MakerAsia KB32-FT",
"variant": VARIANT_ESP32,
@@ -1862,6 +1875,10 @@ BOARDS = {
"name": "LilyGo T-Display-S3",
"variant": VARIANT_ESP32S3,
},
"lilygo-t3-s3": {
"name": "LilyGo T3-S3",
"variant": VARIANT_ESP32S3,
},
"lionbit": {
"name": "Lion:Bit Dev Board",
"variant": VARIANT_ESP32,
@@ -1870,14 +1887,14 @@ BOARDS = {
"name": "Lion:Bit S3 STEM Dev Board",
"variant": VARIANT_ESP32S3,
},
"lolin32_lite": {
"name": "WEMOS LOLIN32 Lite",
"variant": VARIANT_ESP32,
},
"lolin32": {
"name": "WEMOS LOLIN32",
"variant": VARIANT_ESP32,
},
"lolin32_lite": {
"name": "WEMOS LOLIN32 Lite",
"variant": VARIANT_ESP32,
},
"lolin_c3_mini": {
"name": "WEMOS LOLIN C3 Mini",
"variant": VARIANT_ESP32C3,
@@ -1898,26 +1915,30 @@ BOARDS = {
"name": "WEMOS LOLIN S2 PICO",
"variant": VARIANT_ESP32S2,
},
"lolin_s3": {
"name": "WEMOS LOLIN S3",
"variant": VARIANT_ESP32S3,
},
"lolin_s3_mini": {
"name": "WEMOS LOLIN S3 Mini",
"variant": VARIANT_ESP32S3,
},
"lolin_s3": {
"name": "WEMOS LOLIN S3",
"lolin_s3_mini_pro": {
"name": "WEMOS LOLIN S3 Mini Pro",
"variant": VARIANT_ESP32S3,
},
"lolin_s3_pro": {
"name": "WEMOS LOLIN S3 PRO",
"variant": VARIANT_ESP32S3,
},
"lopy4": {
"name": "Pycom LoPy4",
"variant": VARIANT_ESP32,
},
"lopy": {
"name": "Pycom LoPy",
"variant": VARIANT_ESP32,
},
"lopy4": {
"name": "Pycom LoPy4",
"variant": VARIANT_ESP32,
},
"m5stack-atom": {
"name": "M5Stack-ATOM",
"variant": VARIANT_ESP32,
@@ -1926,16 +1947,16 @@ BOARDS = {
"name": "M5Stack AtomS3",
"variant": VARIANT_ESP32S3,
},
"m5stack-core2": {
"name": "M5Stack Core2",
"m5stack-core-esp32": {
"name": "M5Stack Core ESP32",
"variant": VARIANT_ESP32,
},
"m5stack-core-esp32-16M": {
"name": "M5Stack Core ESP32 16M",
"variant": VARIANT_ESP32,
},
"m5stack-core-esp32": {
"name": "M5Stack Core ESP32",
"m5stack-core2": {
"name": "M5Stack Core2",
"variant": VARIANT_ESP32,
},
"m5stack-coreink": {
@@ -1954,10 +1975,6 @@ BOARDS = {
"name": "M5Stack GREY ESP32",
"variant": VARIANT_ESP32,
},
"m5stack_paper": {
"name": "M5Stack Paper",
"variant": VARIANT_ESP32,
},
"m5stack-stamps3": {
"name": "M5Stack StampS3",
"variant": VARIANT_ESP32S3,
@@ -1970,6 +1987,10 @@ BOARDS = {
"name": "M5Stack Timer CAM",
"variant": VARIANT_ESP32,
},
"m5stack_paper": {
"name": "M5Stack Paper",
"variant": VARIANT_ESP32,
},
"m5stamp-pico": {
"name": "M5Stamp-Pico",
"variant": VARIANT_ESP32,
@@ -2038,14 +2059,14 @@ BOARDS = {
"name": "Node32s",
"variant": VARIANT_ESP32,
},
"nodemcu-32s2": {
"name": "Ai-Thinker NodeMCU-32S2 (ESP-12K)",
"variant": VARIANT_ESP32S2,
},
"nodemcu-32s": {
"name": "NodeMCU-32S",
"variant": VARIANT_ESP32,
},
"nodemcu-32s2": {
"name": "Ai-Thinker NodeMCU-32S2 (ESP-12K)",
"variant": VARIANT_ESP32S2,
},
"nscreen-32": {
"name": "YeaCreate NSCREEN-32",
"variant": VARIANT_ESP32,
@@ -2094,10 +2115,22 @@ BOARDS = {
"name": "RoboHeart Hercules",
"variant": VARIANT_ESP32,
},
"rymcu-esp32-s3-devkitc-1": {
"name": "RYMCU ESP32-S3-DevKitC-1-N8R2 (8 MB QD, 2 MB PSRAM)",
"variant": VARIANT_ESP32S3,
},
"s_odi_ultra": {
"name": "S.ODI Ultra v1",
"variant": VARIANT_ESP32,
},
"seeed_xiao_esp32c3": {
"name": "Seeed Studio XIAO ESP32C3",
"variant": VARIANT_ESP32C3,
},
"seeed_xiao_esp32c6": {
"name": "Seeed Studio XIAO ESP32C6",
"variant": VARIANT_ESP32C6,
},
"seeed_xiao_esp32s3": {
"name": "Seeed Studio XIAO ESP32S3",
"variant": VARIANT_ESP32S3,
@@ -2114,34 +2147,38 @@ BOARDS = {
"name": "SG-O AirMon",
"variant": VARIANT_ESP32,
},
"s_odi_ultra": {
"name": "S.ODI Ultra v1",
"sparkfun_esp32_iot_redboard": {
"name": "SparkFun ESP32 IoT RedBoard",
"variant": VARIANT_ESP32,
},
"sparkfun_esp32c6_thing_plus": {
"name": "Sparkfun ESP32-C6 Thing Plus",
"variant": VARIANT_ESP32C6,
},
"sparkfun_esp32_iot_redboard": {
"name": "SparkFun ESP32 IoT RedBoard",
"variant": VARIANT_ESP32,
},
"sparkfun_esp32micromod": {
"name": "SparkFun ESP32 MicroMod",
"variant": VARIANT_ESP32,
},
"sparkfun_esp32s2_thing_plus_c": {
"name": "SparkFun ESP32 Thing Plus C",
"variant": VARIANT_ESP32,
},
"sparkfun_esp32s2_thing_plus": {
"name": "SparkFun ESP32-S2 Thing Plus",
"variant": VARIANT_ESP32S2,
},
"sparkfun_esp32s2_thing_plus_c": {
"name": "SparkFun ESP32 Thing Plus C",
"variant": VARIANT_ESP32,
},
"sparkfun_esp32s3_thing_plus": {
"name": "SPARKFUN_ESP32S3_THING_PLUS",
"variant": VARIANT_ESP32S3,
},
"sparkfun_lora_gateway_1-channel": {
"name": "SparkFun LoRa Gateway 1-Channel",
"variant": VARIANT_ESP32,
},
"sparkfun_qwiic_pocket_esp32c6": {
"name": "SparkFun ESP32-C6 Qwiic Pocket",
"variant": VARIANT_ESP32C6,
},
"tamc_termod_s3": {
"name": "TAMC Termod S3",
"variant": VARIANT_ESP32S3,
@@ -2150,6 +2187,10 @@ BOARDS = {
"name": "Unexpected Maker TinyPICO",
"variant": VARIANT_ESP32,
},
"trueverit-iot-driver": {
"name": "Trueverit ESP32 Universal IoT Driver",
"variant": VARIANT_ESP32,
},
"trueverit-iot-driver-mk2": {
"name": "Trueverit ESP32 Universal IoT Driver MK II",
"variant": VARIANT_ESP32,
@@ -2158,32 +2199,16 @@ BOARDS = {
"name": "Trueverit ESP32 Universal IoT Driver MK III",
"variant": VARIANT_ESP32,
},
"trueverit-iot-driver": {
"name": "Trueverit ESP32 Universal IoT Driver",
"variant": VARIANT_ESP32,
},
"ttgo-lora32-v1": {
"name": "TTGO LoRa32-OLED V1",
"variant": VARIANT_ESP32,
},
"ttgo-lora32-v21": {
"name": "TTGO LoRa32-OLED v2.1.6",
"variant": VARIANT_ESP32,
},
"ttgo-lora32-v2": {
"name": "TTGO LoRa32-OLED V2",
"variant": VARIANT_ESP32,
},
"ttgo-t1": {
"name": "TTGO T1",
"variant": VARIANT_ESP32,
},
"ttgo-t7-v13-mini32": {
"name": "TTGO T7 V1.3 Mini32",
"variant": VARIANT_ESP32,
},
"ttgo-t7-v14-mini32": {
"name": "TTGO T7 V1.4 Mini32",
"ttgo-lora32-v21": {
"name": "TTGO LoRa32-OLED v2.1.6",
"variant": VARIANT_ESP32,
},
"ttgo-t-beam": {
@@ -2198,6 +2223,18 @@ BOARDS = {
"name": "TTGO T-Watch",
"variant": VARIANT_ESP32,
},
"ttgo-t1": {
"name": "TTGO T1",
"variant": VARIANT_ESP32,
},
"ttgo-t7-v13-mini32": {
"name": "TTGO T7 V1.3 Mini32",
"variant": VARIANT_ESP32,
},
"ttgo-t7-v14-mini32": {
"name": "TTGO T7 V1.4 Mini32",
"variant": VARIANT_ESP32,
},
"turta_iot_node": {
"name": "Turta IoT Node",
"variant": VARIANT_ESP32,
@@ -2270,9 +2307,17 @@ BOARDS = {
"name": "SQFMI Watchy v2.0",
"variant": VARIANT_ESP32,
},
"wemosbat": {
"name": "WeMos WiFi and Bluetooth Battery",
"variant": VARIANT_ESP32,
"waveshare_esp32_s3_zero": {
"name": "Waveshare ESP32-S3-Zero",
"variant": VARIANT_ESP32S3,
},
"waveshare_esp32s3_touch_lcd_128": {
"name": "Waveshare ESP32-S3-Touch-LCD-1.28 (16 MB QD, 2MB PSRAM)",
"variant": VARIANT_ESP32S3,
},
"weactstudio_esp32c3coreboard": {
"name": "WeAct Studio ESP32C3CoreBoard",
"variant": VARIANT_ESP32C3,
},
"wemos_d1_mini32": {
"name": "WEMOS D1 MINI ESP32",
@@ -2282,6 +2327,10 @@ BOARDS = {
"name": "WEMOS D1 R32",
"variant": VARIANT_ESP32,
},
"wemosbat": {
"name": "WeMos WiFi and Bluetooth Battery",
"variant": VARIANT_ESP32,
},
"wesp32": {
"name": "Silicognition wESP32",
"variant": VARIANT_ESP32,
@@ -2290,14 +2339,14 @@ BOARDS = {
"name": "Widora AIR",
"variant": VARIANT_ESP32,
},
"wifiduino32c3": {
"name": "Blinker WiFiduinoV2 (ESP32-C3)",
"variant": VARIANT_ESP32C3,
},
"wifiduino32": {
"name": "Blinker WiFiduino32",
"variant": VARIANT_ESP32,
},
"wifiduino32c3": {
"name": "Blinker WiFiduinoV2 (ESP32-C3)",
"variant": VARIANT_ESP32C3,
},
"wifiduino32s3": {
"name": "Blinker WiFiduino32S3",
"variant": VARIANT_ESP32S3,
@@ -2306,12 +2355,32 @@ BOARDS = {
"name": "Pycom WiPy3",
"variant": VARIANT_ESP32,
},
"ws_esp32_s3_matrix": {
"name": "Waveshare ESP32-S3-Matrix",
"variant": VARIANT_ESP32S3,
},
"wt32-eth01": {
"name": "Wireless-Tag WT32-ETH01 Ethernet Module",
"variant": VARIANT_ESP32,
},
"wt32-sc01-plus": {
"name": "wt32-sc01-plus",
"variant": VARIANT_ESP32S3,
},
"xinabox_cw02": {
"name": "XinaBox CW02",
"variant": VARIANT_ESP32,
},
"yb_esp32s3_amp_v2": {
"name": "YelloByte YB-ESP32-S3-AMP (Rev.2)",
"variant": VARIANT_ESP32S3,
},
"yb_esp32s3_amp_v3": {
"name": "YelloByte YB-ESP32-S3-AMP (Rev.3)",
"variant": VARIANT_ESP32S3,
},
"yb_esp32s3_eth": {
"name": "YelloByte YB-ESP32-S3-ETH",
"variant": VARIANT_ESP32S3,
},
}

View File

@@ -15,7 +15,7 @@ void EZOSensor::dump_config() {
LOG_SENSOR("", "EZO", this);
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with EZO circuit failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
}

View File

@@ -41,7 +41,7 @@ static const std::string DOSING_MODE_CONTINUOUS = "Continuous";
void EzoPMP::dump_config() {
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with EZO-PMP circuit failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
}

View File

@@ -10,7 +10,7 @@ static const char *const TAG = "factory_reset.button";
void FactoryResetButton::dump_config() { LOG_BUTTON("", "Factory Reset Button", this); }
void FactoryResetButton::press_action() {
ESP_LOGI(TAG, "Resetting to factory defaults...");
ESP_LOGI(TAG, "Resetting...");
// Let MQTT settle a bit
delay(100); // NOLINT
global_preferences->reset();

View File

@@ -14,7 +14,7 @@ void FactoryResetSwitch::write_state(bool state) {
this->publish_state(false);
if (state) {
ESP_LOGI(TAG, "Resetting to factory defaults...");
ESP_LOGI(TAG, "Resetting...");
// Let MQTT settle a bit
delay(100); // NOLINT
global_preferences->reset();

View File

@@ -14,8 +14,6 @@ namespace gcja5 {
static const char *const TAG = "gcja5";
void GCJA5Component::setup() { ESP_LOGCONFIG(TAG, "Running setup"); }
void GCJA5Component::loop() {
const uint32_t now = App.get_loop_component_start_time();
if (now - this->last_transmission_ >= 500) {

View File

@@ -9,7 +9,6 @@ namespace gcja5 {
class GCJA5Component : public Component, public uart::UARTDevice {
public:
void setup() override;
void dump_config() override;
void loop() override;
float get_setup_priority() const override { return setup_priority::DATA; }

View File

@@ -60,7 +60,7 @@ void GDK101Component::dump_config() {
ESP_LOGCONFIG(TAG, "GDK101:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with GDK101 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
#ifdef USE_SENSOR
LOG_SENSOR(" ", "Firmware Version", this->fw_version_sensor_);

View File

@@ -7,7 +7,7 @@ namespace gpio {
static const char *const TAG = "gpio.output";
void GPIOBinaryOutput::dump_config() {
ESP_LOGCONFIG(TAG, "GPIO Binary Output:");
ESP_LOGCONFIG(TAG, "Binary Output:");
LOG_PIN(" Pin: ", this->pin_);
LOG_BINARY_OUTPUT(this);
}

View File

@@ -67,17 +67,17 @@ void GroveGasMultichannelV2Component::dump_config() {
if (this->is_failed()) {
switch (this->error_code_) {
case COMMUNICATION_FAILED:
ESP_LOGW(TAG, "Communication failed! Is the sensor connected?");
ESP_LOGW(TAG, ESP_LOG_MSG_COMM_FAIL);
break;
case APP_INVALID:
ESP_LOGW(TAG, "Sensor reported invalid APP installed.");
ESP_LOGW(TAG, "Sensor reported invalid APP installed");
break;
case APP_START_FAILED:
ESP_LOGW(TAG, "Sensor reported APP start failed.");
ESP_LOGW(TAG, "Sensor reported APP start failed");
break;
case UNKNOWN:
default:
ESP_LOGW(TAG, "Unknown setup error!");
ESP_LOGW(TAG, "Unknown setup error");
break;
}
}

View File

@@ -31,7 +31,7 @@ void HDC1080Component::dump_config() {
ESP_LOGCONFIG(TAG, "HDC1080:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with HDC1080 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
LOG_SENSOR(" ", "Temperature", this->temperature_);

View File

@@ -23,7 +23,7 @@ void HM3301Component::dump_config() {
ESP_LOGCONFIG(TAG, "HM3301:");
LOG_I2C_DEVICE(this);
if (error_code_ == ERROR_COMM) {
ESP_LOGE(TAG, "Communication with HM3301 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_SENSOR(" ", "PM1.0", this->pm_1_0_sensor_);

View File

@@ -73,7 +73,7 @@ void HMC5883LComponent::dump_config() {
ESP_LOGCONFIG(TAG, "HMC5883L:");
LOG_I2C_DEVICE(this);
if (this->error_code_ == COMMUNICATION_FAILED) {
ESP_LOGE(TAG, "Communication with HMC5883L failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
} else if (this->error_code_ == ID_REGISTERS) {
ESP_LOGE(TAG, "The ID registers don't match - Is this really an HMC5883L?");
}

View File

@@ -17,7 +17,7 @@ void HoneywellHIComponent::read_sensor_data_() {
uint8_t data[4];
if (this->read(data, sizeof(data)) != i2c::ERROR_OK) {
ESP_LOGE(TAG, "Communication with Honeywell HIH failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
this->mark_failed();
return;
}
@@ -37,7 +37,7 @@ void HoneywellHIComponent::read_sensor_data_() {
void HoneywellHIComponent::start_measurement_() {
if (this->write(REQUEST_CMD, sizeof(REQUEST_CMD)) != i2c::ERROR_OK) {
ESP_LOGE(TAG, "Communication with Honeywell HIH failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
this->mark_failed();
return;
}
@@ -49,7 +49,7 @@ bool HoneywellHIComponent::is_measurement_ready_() {
uint8_t data[1];
if (this->read(data, sizeof(data)) != i2c::ERROR_OK) {
ESP_LOGE(TAG, "Communication with Honeywell HIH failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
this->mark_failed();
return false;
}
@@ -84,7 +84,7 @@ void HoneywellHIComponent::dump_config() {
ESP_LOGD(TAG, "Honeywell HIH:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with Honeywell HIH failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);

View File

@@ -14,7 +14,7 @@ static const char *const TAG = "honeywellabp2";
void HONEYWELLABP2Sensor::read_sensor_data() {
if (this->read(raw_data_, 7) != i2c::ERROR_OK) {
ESP_LOGE(TAG, "Communication with ABP2 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
this->status_set_warning("couldn't read sensor data");
return;
}
@@ -30,7 +30,7 @@ void HONEYWELLABP2Sensor::read_sensor_data() {
void HONEYWELLABP2Sensor::start_measurement() {
if (this->write(i2c_cmd_, 3) != i2c::ERROR_OK) {
ESP_LOGE(TAG, "Communication with ABP2 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
this->status_set_warning("couldn't start measurement");
return;
}
@@ -39,7 +39,7 @@ void HONEYWELLABP2Sensor::start_measurement() {
bool HONEYWELLABP2Sensor::is_measurement_ready() {
if (this->read(raw_data_, 1) != i2c::ERROR_OK) {
ESP_LOGE(TAG, "Communication with ABP2 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
this->status_set_warning("couldn't check measurement");
return false;
}

View File

@@ -25,7 +25,7 @@ void HTE501Component::dump_config() {
LOG_I2C_DEVICE(this);
switch (this->error_code_) {
case COMMUNICATION_FAILED:
ESP_LOGE(TAG, "Communication with HTE501 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
break;
case CRC_CHECK_FAILED:
ESP_LOGE(TAG, "The crc check failed");

View File

@@ -10,6 +10,7 @@ from esphome.const import (
CONF_TIMEOUT,
CONF_TRIGGER_ID,
CONF_URL,
CONF_WATCHDOG_TIMEOUT,
PLATFORM_HOST,
__version__,
)
@@ -43,7 +44,6 @@ CONF_USERAGENT = "useragent"
CONF_VERIFY_SSL = "verify_ssl"
CONF_FOLLOW_REDIRECTS = "follow_redirects"
CONF_REDIRECT_LIMIT = "redirect_limit"
CONF_WATCHDOG_TIMEOUT = "watchdog_timeout"
CONF_BUFFER_SIZE_RX = "buffer_size_rx"
CONF_BUFFER_SIZE_TX = "buffer_size_tx"
CONF_CA_CERTIFICATE_PATH = "ca_certificate_path"

View File

@@ -32,7 +32,7 @@ void HTU21DComponent::dump_config() {
ESP_LOGCONFIG(TAG, "HTU21D:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with HTU21D failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
LOG_SENSOR(" ", "Temperature", this->temperature_);

View File

@@ -161,7 +161,7 @@ void HTU31DComponent::dump_config() {
ESP_LOGCONFIG(TAG, "HTU31D:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with HTU31D failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
LOG_SENSOR(" ", "Temperature", this->temperature_);

View File

@@ -21,14 +21,14 @@ void HYT271Component::update() {
if (this->write(&raw_data[0], 0) != i2c::ERROR_OK) {
this->status_set_warning();
ESP_LOGE(TAG, "Communication with HYT271 failed! => Ask new values");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
return;
}
this->set_timeout("wait_convert", 50, [this]() {
uint8_t raw_data[4];
if (this->read(raw_data, 4) != i2c::ERROR_OK) {
this->status_set_warning();
ESP_LOGE(TAG, "Communication with HYT271 failed! => Read values");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
return;
}
uint16_t raw_temperature = ((raw_data[2] << 8) | raw_data[3]) >> 2;

View File

@@ -94,13 +94,13 @@ void ArduinoI2CBus::dump_config() {
break;
}
if (this->scan_) {
ESP_LOGI(TAG, "Results from i2c bus scan:");
ESP_LOGI(TAG, "Results from bus scan:");
if (scan_results_.empty()) {
ESP_LOGI(TAG, "Found no i2c devices!");
ESP_LOGI(TAG, "Found no devices");
} else {
for (const auto &s : scan_results_) {
if (s.second) {
ESP_LOGI(TAG, "Found i2c device at address 0x%02X", s.first);
ESP_LOGI(TAG, "Found device at address 0x%02X", s.first);
} else {
ESP_LOGE(TAG, "Unknown error at address 0x%02X", s.first);
}
@@ -216,7 +216,7 @@ ErrorCode ArduinoI2CBus::writev(uint8_t address, WriteBuffer *buffers, size_t cn
/// https://www.nxp.com/docs/en/user-guide/UM10204.pdf
/// https://www.analog.com/media/en/technical-documentation/application-notes/54305147357414AN686_0.pdf
void ArduinoI2CBus::recover_() {
ESP_LOGI(TAG, "Performing I2C bus recovery");
ESP_LOGI(TAG, "Performing bus recovery");
// For the upcoming operations, target for a 100kHz toggle frequency.
// This is the maximum frequency for I2C running in standard-mode.
@@ -232,7 +232,7 @@ void ArduinoI2CBus::recover_() {
// line. In that case, the I2C bus cannot be recovered.
delayMicroseconds(half_period_usec);
if (digitalRead(scl_pin_) == LOW) { // NOLINT
ESP_LOGE(TAG, "Recovery failed: SCL is held LOW on the I2C bus");
ESP_LOGE(TAG, "Recovery failed: SCL is held LOW on the bus");
recovery_result_ = RECOVERY_FAILED_SCL_LOW;
return;
}

View File

@@ -28,7 +28,7 @@ void IDFI2CBus::setup() {
#endif
if (port_ == I2C_NUM_MAX) {
ESP_LOGE(TAG, "Too many I2C buses configured. Max %u supported.", SOC_HP_I2C_NUM);
ESP_LOGE(TAG, "No more than %u buses supported", SOC_HP_I2C_NUM);
this->mark_failed();
return;
}
@@ -99,13 +99,13 @@ void IDFI2CBus::dump_config() {
break;
}
if (this->scan_) {
ESP_LOGI(TAG, "Results from i2c bus scan:");
ESP_LOGI(TAG, "Results from bus scan:");
if (scan_results_.empty()) {
ESP_LOGI(TAG, "Found no i2c devices!");
ESP_LOGI(TAG, "Found no devices");
} else {
for (const auto &s : scan_results_) {
if (s.second) {
ESP_LOGI(TAG, "Found i2c device at address 0x%02X", s.first);
ESP_LOGI(TAG, "Found device at address 0x%02X", s.first);
} else {
ESP_LOGE(TAG, "Unknown error at address 0x%02X", s.first);
}
@@ -257,7 +257,7 @@ ErrorCode IDFI2CBus::writev(uint8_t address, WriteBuffer *buffers, size_t cnt, b
/// https://www.nxp.com/docs/en/user-guide/UM10204.pdf
/// https://www.analog.com/media/en/technical-documentation/application-notes/54305147357414AN686_0.pdf
void IDFI2CBus::recover_() {
ESP_LOGI(TAG, "Performing I2C bus recovery");
ESP_LOGI(TAG, "Performing bus recovery");
const gpio_num_t scl_pin = static_cast<gpio_num_t>(scl_pin_);
const gpio_num_t sda_pin = static_cast<gpio_num_t>(sda_pin_);
@@ -294,7 +294,7 @@ void IDFI2CBus::recover_() {
// with the SCL line. In that case, the I2C bus cannot be recovered.
delayMicroseconds(half_period_usec);
if (gpio_get_level(scl_pin) == 0) {
ESP_LOGE(TAG, "Recovery failed: SCL is held LOW on the I2C bus");
ESP_LOGE(TAG, "Recovery failed: SCL is held LOW on the bus");
recovery_result_ = RECOVERY_FAILED_SCL_LOW;
return;
}

View File

@@ -26,7 +26,7 @@ struct SensorData {
void IAQCore::setup() {
if (this->write(nullptr, 0) != i2c::ERROR_OK) {
ESP_LOGD(TAG, "Communication failed!");
ESP_LOGD(TAG, ESP_LOG_MSG_COMM_FAIL);
this->mark_failed();
return;
}
@@ -89,7 +89,7 @@ void IAQCore::dump_config() {
LOG_I2C_DEVICE(this);
LOG_UPDATE_INTERVAL(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with AMS iAQ Core failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_SENSOR(" ", "CO2", this->co2_);
LOG_SENSOR(" ", "TVOC", this->tvoc_);

View File

@@ -134,7 +134,7 @@ void INA219Component::dump_config() {
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with INA219 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
return;
}
LOG_UPDATE_INTERVAL(this);

View File

@@ -88,7 +88,7 @@ void INA226Component::dump_config() {
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with INA226 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
return;
}
LOG_UPDATE_INTERVAL(this);

View File

@@ -203,7 +203,7 @@ void INA2XX::dump_config() {
this->dev_id_);
}
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with INA2xx failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
ESP_LOGCONFIG(TAG, " Shunt resistance = %f Ohm", this->shunt_resistance_ohm_);

View File

@@ -60,7 +60,7 @@ void INA3221Component::dump_config() {
ESP_LOGCONFIG(TAG, "INA3221:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with INA3221 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);

View File

@@ -6,9 +6,12 @@ from esphome.const import (
CONF_FULL_UPDATE_EVERY,
CONF_ID,
CONF_LAMBDA,
CONF_MIRROR_X,
CONF_MIRROR_Y,
CONF_MODEL,
CONF_OE_PIN,
CONF_PAGES,
CONF_TRANSFORM,
CONF_WAKEUP_PIN,
)
@@ -36,7 +39,6 @@ CONF_SPH_PIN = "sph_pin"
CONF_SPV_PIN = "spv_pin"
CONF_VCOM_PIN = "vcom_pin"
inkplate6_ns = cg.esphome_ns.namespace("inkplate6")
Inkplate6 = inkplate6_ns.class_(
"Inkplate6",
@@ -62,6 +64,12 @@ CONFIG_SCHEMA = cv.All(
{
cv.GenerateID(): cv.declare_id(Inkplate6),
cv.Optional(CONF_GREYSCALE, default=False): cv.boolean,
cv.Optional(CONF_TRANSFORM): cv.Schema(
{
cv.Optional(CONF_MIRROR_X, default=False): cv.boolean,
cv.Optional(CONF_MIRROR_Y, default=False): cv.boolean,
}
),
cv.Optional(CONF_PARTIAL_UPDATING, default=True): cv.boolean,
cv.Optional(CONF_FULL_UPDATE_EVERY, default=10): cv.uint32_t,
cv.Optional(CONF_MODEL, default="inkplate_6"): cv.enum(
@@ -126,6 +134,9 @@ async def to_code(config):
cg.add(var.set_writer(lambda_))
cg.add(var.set_greyscale(config[CONF_GREYSCALE]))
if transform := config.get(CONF_TRANSFORM):
cg.add(var.set_mirror_x(transform[CONF_MIRROR_X]))
cg.add(var.set_mirror_y(transform[CONF_MIRROR_Y]))
cg.add(var.set_partial_updating(config[CONF_PARTIAL_UPDATING]))
cg.add(var.set_full_update_every(config[CONF_FULL_UPDATE_EVERY]))

View File

@@ -1,7 +1,7 @@
#include "inkplate.h"
#include "esphome/core/log.h"
#include "esphome/core/application.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
#ifdef USE_ESP32_FRAMEWORK_ARDUINO
@@ -156,6 +156,12 @@ void HOT Inkplate6::draw_absolute_pixel_internal(int x, int y, Color color) {
if (x >= this->get_width_internal() || y >= this->get_height_internal() || x < 0 || y < 0)
return;
if (this->mirror_y_)
y = this->get_height_internal() - y - 1;
if (this->mirror_x_)
x = this->get_width_internal() - x - 1;
if (this->greyscale_) {
int x1 = x / 2;
int x_sub = x % 2;

View File

@@ -1,9 +1,9 @@
#pragma once
#include "esphome/components/display/display_buffer.h"
#include "esphome/components/i2c/i2c.h"
#include "esphome/core/component.h"
#include "esphome/core/hal.h"
#include "esphome/components/i2c/i2c.h"
#include "esphome/components/display/display_buffer.h"
#ifdef USE_ESP32_FRAMEWORK_ARDUINO
@@ -92,6 +92,9 @@ class Inkplate6 : public display::DisplayBuffer, public i2c::I2CDevice {
if (this->is_ready())
this->initialize_();
}
void set_mirror_y(bool mirror_y) { this->mirror_y_ = mirror_y; }
void set_mirror_x(bool mirror_x) { this->mirror_x_ = mirror_x; }
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; }
@@ -221,6 +224,8 @@ class Inkplate6 : public display::DisplayBuffer, public i2c::I2CDevice {
bool block_partial_{true};
bool greyscale_;
bool mirror_y_{false};
bool mirror_x_{false};
bool partial_updating_;
InkplateModel model_;

View File

@@ -20,8 +20,7 @@ std::string build_json(const json_build_t &f) {
ESP_LOGV(TAG, "Attempting to allocate %zu bytes for JSON serialization", request_size);
DynamicJsonDocument json_document(request_size);
if (json_document.capacity() == 0) {
ESP_LOGE(TAG,
"Could not allocate memory for JSON document! Requested %zu bytes, largest free heap block: %zu bytes",
ESP_LOGE(TAG, "Could not allocate memory for document! Requested %zu bytes, largest free heap block: %zu bytes",
request_size, free_heap);
return "{}";
}
@@ -29,7 +28,7 @@ std::string build_json(const json_build_t &f) {
f(root);
if (json_document.overflowed()) {
if (request_size == free_heap) {
ESP_LOGE(TAG, "Could not allocate memory for JSON document! Overflowed largest free heap block: %zu bytes",
ESP_LOGE(TAG, "Could not allocate memory for document! Overflowed largest free heap block: %zu bytes",
free_heap);
return "{}";
}
@@ -54,7 +53,7 @@ bool parse_json(const std::string &data, const json_parse_t &f) {
while (true) {
DynamicJsonDocument json_document(request_size);
if (json_document.capacity() == 0) {
ESP_LOGE(TAG, "Could not allocate memory for JSON document! Requested %zu bytes, free heap: %zu", request_size,
ESP_LOGE(TAG, "Could not allocate memory for document! Requested %zu bytes, free heap: %zu", request_size,
free_heap);
return false;
}
@@ -74,7 +73,7 @@ bool parse_json(const std::string &data, const json_parse_t &f) {
request_size *= 2;
continue;
} else {
ESP_LOGE(TAG, "JSON parse error: %s", err.c_str());
ESP_LOGE(TAG, "Parse error: %s", err.c_str());
return false;
}
};

View File

@@ -10,7 +10,7 @@ static const char *const TAG = "kamstrup_kmp";
void KamstrupKMPComponent::dump_config() {
ESP_LOGCONFIG(TAG, "kamstrup_kmp:");
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with Kamstrup meter failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);

View File

@@ -26,7 +26,7 @@ void PCF8574LCDDisplay::dump_config() {
LOG_I2C_DEVICE(this);
LOG_UPDATE_INTERVAL(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with LCD Display failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}
void PCF8574LCDDisplay::write_n_bits(uint8_t value, uint8_t n) {

View File

@@ -113,7 +113,7 @@ void LTRAlsPs501Component::dump_config() {
LOG_SENSOR(" ", "Actual gain", this->actual_gain_sensor_);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with I2C LTR-501/301/558 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}

View File

@@ -105,7 +105,7 @@ void LTRAlsPsComponent::dump_config() {
LOG_UPDATE_INTERVAL(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with I2C LTR-303/329/55x/659 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}

View File

@@ -76,7 +76,7 @@ void MAX17043Component::dump_config() {
ESP_LOGCONFIG(TAG, "MAX17043:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with MAX17043 failed");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
LOG_SENSOR(" ", "Battery Voltage", this->voltage_sensor_);

View File

@@ -48,7 +48,7 @@ void MAX44009Sensor::dump_config() {
ESP_LOGCONFIG(TAG, "MAX44009:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with MAX44009 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}

View File

@@ -20,7 +20,7 @@ void MCP4725::dump_config() {
LOG_I2C_DEVICE(this);
if (this->error_code_ == COMMUNICATION_FAILED) {
ESP_LOGE(TAG, "Communication with MCP4725 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}

View File

@@ -21,7 +21,7 @@ void MCP4728Component::dump_config() {
ESP_LOGCONFIG(TAG, "MCP4728:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with MCP4728 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}

View File

@@ -23,13 +23,13 @@ void MCP9808Sensor::setup() {
uint16_t manu = 0;
if (!this->read_byte_16(MCP9808_REG_MANUF_ID, &manu) || manu != MCP9808_MANUF_ID) {
this->mark_failed();
ESP_LOGE(TAG, "%s manufacuturer id failed, device returned %X", this->name_.c_str(), manu);
ESP_LOGE(TAG, "Incorrect manufacturer ID (%X) for '%s'", manu, this->name_.c_str());
return;
}
uint16_t dev_id = 0;
if (!this->read_byte_16(MCP9808_REG_DEVICE_ID, &dev_id) || dev_id != MCP9808_DEV_ID) {
this->mark_failed();
ESP_LOGE(TAG, "%s device id failed, device returned %X", this->name_.c_str(), dev_id);
ESP_LOGE(TAG, "Incorrect device ID (%X) for '%s'", dev_id, this->name_.c_str());
return;
}
}
@@ -37,7 +37,7 @@ void MCP9808Sensor::dump_config() {
ESP_LOGCONFIG(TAG, "%s:", this->name_.c_str());
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with %s failed!", this->name_.c_str());
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL_FOR, this->name_.c_str());
}
LOG_UPDATE_INTERVAL(this);
LOG_SENSOR(" ", "Temperature", this);

View File

@@ -17,7 +17,7 @@ void MDNSComponent::setup() {
esp_err_t err = mdns_init();
if (err != ESP_OK) {
ESP_LOGW(TAG, "mDNS init failed: %s", esp_err_to_name(err));
ESP_LOGW(TAG, "Init failed: %s", esp_err_to_name(err));
this->mark_failed();
return;
}
@@ -45,7 +45,7 @@ void MDNSComponent::setup() {
}
if (err != ESP_OK) {
ESP_LOGW(TAG, "Failed to register mDNS service %s: %s", service.service_type.c_str(), esp_err_to_name(err));
ESP_LOGW(TAG, "Failed to register service %s: %s", service.service_type.c_str(), esp_err_to_name(err));
}
}
}

View File

@@ -122,7 +122,7 @@ void MLX90393Cls::dump_config() {
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with MLX90393 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
return;
}
LOG_UPDATE_INTERVAL(this);

View File

@@ -29,7 +29,7 @@ static const char *const TAG = "mlx90614";
void MLX90614Component::setup() {
ESP_LOGCONFIG(TAG, "Running setup");
if (!this->write_emissivity_()) {
ESP_LOGE(TAG, "Communication with MLX90614 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
this->mark_failed();
return;
}
@@ -79,7 +79,7 @@ void MLX90614Component::dump_config() {
ESP_LOGCONFIG(TAG, "MLX90614:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with MLX90614 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
LOG_SENSOR(" ", "Ambient", this->ambient_sensor_);

View File

@@ -79,7 +79,7 @@ void MMC5603Component::dump_config() {
ESP_LOGCONFIG(TAG, "MMC5603:");
LOG_I2C_DEVICE(this);
if (this->error_code_ == COMMUNICATION_FAILED) {
ESP_LOGE(TAG, "Communication with MMC5603 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
} else if (this->error_code_ == ID_REGISTERS) {
ESP_LOGE(TAG, "The ID registers don't match - Is this really an MMC5603?");
}

View File

@@ -90,7 +90,7 @@ bool Modbus::parse_modbus_byte_(uint8_t byte) {
} else {
// data starts at 2 and length is 4 for read registers commands
if (this->role == ModbusRole::SERVER && (function_code == 0x3 || function_code == 0x4)) {
if (this->role == ModbusRole::SERVER && (function_code == 0x1 || function_code == 0x3 || function_code == 0x4)) {
data_offset = 2;
data_len = 4;
}

View File

@@ -37,7 +37,7 @@ void MPL3115A2Component::dump_config() {
if (this->is_failed()) {
switch (this->error_code_) {
case COMMUNICATION_FAILED:
ESP_LOGE(TAG, "Communication with MPL3115A2 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
break;
case WRONG_ID:
ESP_LOGE(TAG, "MPL3115A2 has invalid id");

View File

@@ -72,7 +72,7 @@ void MPR121Component::dump_config() {
LOG_I2C_DEVICE(this);
switch (this->error_code_) {
case COMMUNICATION_FAILED:
ESP_LOGE(TAG, "Communication with MPR121 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
break;
case WRONG_CHIP_STATE:
ESP_LOGE(TAG, "MPR121 has wrong default value for CONFIG2?");

View File

@@ -86,7 +86,7 @@ void MPU6050Component::dump_config() {
ESP_LOGCONFIG(TAG, "MPU6050:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with MPU6050 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
LOG_SENSOR(" ", "Acceleration X", this->accel_x_sensor_);

View File

@@ -91,7 +91,7 @@ void MPU6886Component::dump_config() {
ESP_LOGCONFIG(TAG, "MPU6886:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with MPU6886 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
LOG_SENSOR(" ", "Acceleration X", this->accel_x_sensor_);

View File

@@ -32,7 +32,7 @@ void MS5611Component::dump_config() {
ESP_LOGCONFIG(TAG, "MS5611:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with MS5611 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);

View File

@@ -140,7 +140,7 @@ void MS8607Component::dump_config() {
// LOG_I2C_DEVICE doesn't work for humidity, the `address_` is protected. Log using get_address()
ESP_LOGCONFIG(TAG, " Address: 0x%02X", this->humidity_device_->get_address());
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with MS8607 failed.");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
switch (this->error_code_) {
case ErrorCode::PT_RESET_FAILED:
ESP_LOGE(TAG, "Temperature/Pressure RESET failed");

View File

@@ -159,7 +159,7 @@ void MSA3xxComponent::dump_config() {
ESP_LOGCONFIG(TAG, "MSA3xx:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with MSA3xx failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
ESP_LOGCONFIG(TAG, " Model: %s", model_to_string(this->model_));
ESP_LOGCONFIG(TAG, " Power Mode: %s", power_mode_to_string(this->power_mode_));

View File

@@ -127,7 +127,7 @@ void NAU7802Sensor::dump_config() {
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with NAU7802 failed earlier, during setup");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL_FOR, this->get_name().c_str());
return;
}
// Note these may differ from the values on the device if calbration has been run

View File

@@ -17,12 +17,10 @@ void NPI19Component::setup() {
uint16_t raw_pressure(0);
i2c::ErrorCode err = this->read_(raw_temperature, raw_pressure);
if (err != i2c::ERROR_OK) {
ESP_LOGCONFIG(TAG, " I2C Communication Failed...");
ESP_LOGCONFIG(TAG, ESP_LOG_MSG_COMM_FAIL);
this->mark_failed();
return;
}
ESP_LOGCONFIG(TAG, " Success...");
}
void NPI19Component::dump_config() {
@@ -90,7 +88,7 @@ void NPI19Component::update() {
i2c::ErrorCode err = this->read_(raw_temperature, raw_pressure);
if (err != i2c::ERROR_OK) {
ESP_LOGW(TAG, "I2C Communication Failed");
ESP_LOGW(TAG, ESP_LOG_MSG_COMM_FAIL);
this->status_set_warning();
return;
}

View File

@@ -60,7 +60,7 @@ void PCA6416AComponent::dump_config() {
}
LOG_I2C_DEVICE(this)
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with PCA6416A failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}

View File

@@ -49,7 +49,7 @@ void PCA9554Component::dump_config() {
ESP_LOGCONFIG(TAG, " I/O Pins: %d", this->pin_count_);
LOG_I2C_DEVICE(this)
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with PCA9554 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}

View File

@@ -22,7 +22,7 @@ void PCF85063Component::dump_config() {
ESP_LOGCONFIG(TAG, "PCF85063:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with PCF85063 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
ESP_LOGCONFIG(TAG, " Timezone: '%s'", this->timezone_.c_str());
}

View File

@@ -22,7 +22,7 @@ void PCF8563Component::dump_config() {
ESP_LOGCONFIG(TAG, "PCF8563:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with PCF8563 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
ESP_LOGCONFIG(TAG, " Timezone: '%s'", this->timezone_.c_str());
}

View File

@@ -22,7 +22,7 @@ void PCF8574Component::dump_config() {
LOG_I2C_DEVICE(this)
ESP_LOGCONFIG(TAG, " Is PCF8575: %s", YESNO(this->pcf8575_));
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with PCF8574 failed!");
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}
bool PCF8574Component::digital_read(uint8_t pin) {

Some files were not shown because too many files have changed in this diff Show More