mirror of
https://github.com/esphome/esphome.git
synced 2026-07-11 09:25:34 +00:00
Merge remote-tracking branch 'origin/fix-preferences-log-spam' into integration
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "adc_sensor.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include <cinttypes>
|
||||
|
||||
namespace esphome {
|
||||
namespace adc {
|
||||
@@ -346,7 +347,8 @@ float ADCSensor::sample_autorange_() {
|
||||
ESP_LOGVV(TAG, "Autorange summary:");
|
||||
ESP_LOGVV(TAG, " Raw readings: 12db=%d, 6db=%d, 2.5db=%d, 0db=%d", raw12, raw6, raw2, raw0);
|
||||
ESP_LOGVV(TAG, " Voltages: 12db=%.6f, 6db=%.6f, 2.5db=%.6f, 0db=%.6f", mv12, mv6, mv2, mv0);
|
||||
ESP_LOGVV(TAG, " Coefficients: c12=%u, c6=%u, c2=%u, c0=%u, sum=%u", c12, c6, c2, c0, csum);
|
||||
ESP_LOGVV(TAG, " Coefficients: c12=%" PRIu32 ", c6=%" PRIu32 ", c2=%" PRIu32 ", c0=%" PRIu32 ", sum=%" PRIu32, c12,
|
||||
c6, c2, c0, csum);
|
||||
|
||||
if (csum == 0) {
|
||||
ESP_LOGE(TAG, "Invalid weight sum in autorange calculation");
|
||||
@@ -354,8 +356,10 @@ float ADCSensor::sample_autorange_() {
|
||||
}
|
||||
|
||||
const float final_result = (mv12 * c12 + mv6 * c6 + mv2 * c2 + mv0 * c0) / csum;
|
||||
ESP_LOGV(TAG, "Autorange final: (%.6f*%u + %.6f*%u + %.6f*%u + %.6f*%u)/%u = %.6fV", mv12, c12, mv6, c6, mv2, c2, mv0,
|
||||
c0, csum, final_result);
|
||||
ESP_LOGV(TAG,
|
||||
"Autorange final: (%.6f*%" PRIu32 " + %.6f*%" PRIu32 " + %.6f*%" PRIu32 " + %.6f*%" PRIu32 ")/%" PRIu32
|
||||
" = %.6fV",
|
||||
mv12, c12, mv6, c6, mv2, c2, mv0, c0, csum, final_result);
|
||||
|
||||
return final_result;
|
||||
}
|
||||
|
||||
@@ -1465,7 +1465,7 @@ void APIConnection::send_infrared_rf_receive_event(const InfraredRFReceiveEvent
|
||||
void APIConnection::on_serial_proxy_configure_request(const SerialProxyConfigureRequest &msg) {
|
||||
auto &proxies = App.get_serial_proxies();
|
||||
if (msg.instance >= proxies.size()) {
|
||||
ESP_LOGW(TAG, "Serial proxy instance %u out of range (max %u)", msg.instance,
|
||||
ESP_LOGW(TAG, "Serial proxy instance %" PRIu32 " out of range (max %" PRIu32 ")", msg.instance,
|
||||
static_cast<uint32_t>(proxies.size()));
|
||||
return;
|
||||
}
|
||||
@@ -1476,7 +1476,7 @@ void APIConnection::on_serial_proxy_configure_request(const SerialProxyConfigure
|
||||
void APIConnection::on_serial_proxy_write_request(const SerialProxyWriteRequest &msg) {
|
||||
auto &proxies = App.get_serial_proxies();
|
||||
if (msg.instance >= proxies.size()) {
|
||||
ESP_LOGW(TAG, "Serial proxy instance %u out of range", msg.instance);
|
||||
ESP_LOGW(TAG, "Serial proxy instance %" PRIu32 " out of range", msg.instance);
|
||||
return;
|
||||
}
|
||||
proxies[msg.instance]->write_from_client(msg.data, msg.data_len);
|
||||
@@ -1485,7 +1485,7 @@ void APIConnection::on_serial_proxy_write_request(const SerialProxyWriteRequest
|
||||
void APIConnection::on_serial_proxy_set_modem_pins_request(const SerialProxySetModemPinsRequest &msg) {
|
||||
auto &proxies = App.get_serial_proxies();
|
||||
if (msg.instance >= proxies.size()) {
|
||||
ESP_LOGW(TAG, "Serial proxy instance %u out of range", msg.instance);
|
||||
ESP_LOGW(TAG, "Serial proxy instance %" PRIu32 " out of range", msg.instance);
|
||||
return;
|
||||
}
|
||||
proxies[msg.instance]->set_modem_pins(msg.line_states);
|
||||
@@ -1494,7 +1494,7 @@ void APIConnection::on_serial_proxy_set_modem_pins_request(const SerialProxySetM
|
||||
void APIConnection::on_serial_proxy_get_modem_pins_request(const SerialProxyGetModemPinsRequest &msg) {
|
||||
auto &proxies = App.get_serial_proxies();
|
||||
if (msg.instance >= proxies.size()) {
|
||||
ESP_LOGW(TAG, "Serial proxy instance %u out of range", msg.instance);
|
||||
ESP_LOGW(TAG, "Serial proxy instance %" PRIu32 " out of range", msg.instance);
|
||||
return;
|
||||
}
|
||||
SerialProxyGetModemPinsResponse resp{};
|
||||
@@ -1506,7 +1506,7 @@ void APIConnection::on_serial_proxy_get_modem_pins_request(const SerialProxyGetM
|
||||
void APIConnection::on_serial_proxy_request(const SerialProxyRequest &msg) {
|
||||
auto &proxies = App.get_serial_proxies();
|
||||
if (msg.instance >= proxies.size()) {
|
||||
ESP_LOGW(TAG, "Serial proxy instance %u out of range", msg.instance);
|
||||
ESP_LOGW(TAG, "Serial proxy instance %" PRIu32 " out of range", msg.instance);
|
||||
return;
|
||||
}
|
||||
switch (msg.type) {
|
||||
@@ -1536,7 +1536,7 @@ void APIConnection::on_serial_proxy_request(const SerialProxyRequest &msg) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ESP_LOGW(TAG, "Unknown serial proxy request type: %u", static_cast<uint32_t>(msg.type));
|
||||
ESP_LOGW(TAG, "Unknown serial proxy request type: %" PRIu32, static_cast<uint32_t>(msg.type));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "esphome/components/audio/audio_decoder.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cstring>
|
||||
|
||||
namespace esphome::audio_file {
|
||||
@@ -249,7 +250,7 @@ void AudioFileMediaSource::decode_task(void *params) {
|
||||
|
||||
audio::AudioStreamInfo stream_info = decoder->get_audio_stream_info().value();
|
||||
|
||||
ESP_LOGD(TAG, "Bits per sample: %d, Channels: %d, Sample rate: %d", stream_info.get_bits_per_sample(),
|
||||
ESP_LOGD(TAG, "Bits per sample: %d, Channels: %d, Sample rate: %" PRIu32, stream_info.get_bits_per_sample(),
|
||||
stream_info.get_channels(), stream_info.get_sample_rate());
|
||||
|
||||
if (stream_info.get_bits_per_sample() != 16 || stream_info.get_channels() > 2) {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#include "bm8563.h"
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome::bm8563 {
|
||||
@@ -146,10 +149,10 @@ optional<uint8_t> BM8563::read_register_(uint8_t reg) {
|
||||
}
|
||||
|
||||
void BM8563::set_timer_irq_(uint32_t duration_s) {
|
||||
ESP_LOGI(TAG, "Timer Duration: %u s", duration_s);
|
||||
ESP_LOGI(TAG, "Timer Duration: %" PRIu32 " s", duration_s);
|
||||
|
||||
if (duration_s > MAX_TIMER_DURATION_S) {
|
||||
ESP_LOGW(TAG, "Timer duration %u s exceeds maximum %u s", duration_s, MAX_TIMER_DURATION_S);
|
||||
ESP_LOGW(TAG, "Timer duration %" PRIu32 " s exceeds maximum %" PRIu32 " s", duration_s, MAX_TIMER_DURATION_S);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ void BME68xBSEC2Component::dump_config() {
|
||||
" Operating age: %s\n"
|
||||
" Sample rate: %s\n"
|
||||
" Voltage: %s\n"
|
||||
" State save interval: %ims\n"
|
||||
" State save interval: %" PRIu32 "ms\n"
|
||||
" Temperature offset: %.2f",
|
||||
BME68X_BSEC2_OPERATING_AGE_LOG(this->operating_age_), BME68X_BSEC2_SAMPLE_RATE_LOG(this->sample_rate_),
|
||||
BME68X_BSEC2_VOLTAGE_LOG(this->voltage_), this->state_save_interval_ms_, this->temperature_offset_);
|
||||
@@ -283,7 +283,7 @@ void BME68xBSEC2Component::run_() {
|
||||
if (this->bsec_settings_.trigger_measurement && this->bsec_settings_.op_mode != BME68X_SLEEP_MODE) {
|
||||
bme68x_get_conf(&bme68x_conf, &this->bme68x_);
|
||||
uint32_t meas_dur = bme68x_get_meas_dur(this->op_mode_, &bme68x_conf, &this->bme68x_);
|
||||
ESP_LOGV(TAG, "Queueing read in %uus", meas_dur);
|
||||
ESP_LOGV(TAG, "Queueing read in %" PRIu32 "us", meas_dur);
|
||||
this->trigger_time_ns_ = curr_time_ns;
|
||||
this->set_timeout("read", meas_dur / 1000, [this]() { this->read_(this->trigger_time_ns_); });
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "dlms_meter.h"
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#if defined(USE_ESP8266_FRAMEWORK_ARDUINO)
|
||||
#include <bearssl/bearssl.h>
|
||||
#elif defined(USE_ESP32)
|
||||
@@ -21,7 +23,7 @@ void DlmsMeterComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG,
|
||||
"DLMS Meter:\n"
|
||||
" Provider: %s\n"
|
||||
" Read Timeout: %u ms",
|
||||
" Read Timeout: %" PRIu32 " ms",
|
||||
provider_name, this->read_timeout_);
|
||||
#define DLMS_METER_LOG_SENSOR(s) LOG_SENSOR(" ", #s, this->s##_sensor_);
|
||||
DLMS_METER_SENSOR_LIST(DLMS_METER_LOG_SENSOR, )
|
||||
|
||||
@@ -129,11 +129,15 @@ bool ESP32Preferences::sync() {
|
||||
}
|
||||
s_pending_save.clear();
|
||||
|
||||
ESP_LOGD(TAG, "Writing %d items: %d cached, %d written, %d failed", cached + written + failed, cached, written,
|
||||
failed);
|
||||
if (failed > 0) {
|
||||
ESP_LOGE(TAG, "Writing %d items failed. Last error=%s for key=%" PRIu32, failed, esp_err_to_name(last_err),
|
||||
last_key);
|
||||
ESP_LOGW(TAG, "Writing %d items: %d cached, %d written, %d failed. Last error=%s for key=%" PRIu32,
|
||||
cached + written + failed, cached, written, failed, esp_err_to_name(last_err), last_key);
|
||||
} else if (written > 0) {
|
||||
ESP_LOGD(TAG, "Writing %d items: %d cached, %d written, %d failed", cached + written + failed, cached, written,
|
||||
failed);
|
||||
} else {
|
||||
ESP_LOGV(TAG, "Writing %d items: %d cached, %d written, %d failed", cached + written + failed, cached, written,
|
||||
failed);
|
||||
}
|
||||
|
||||
// note: commit on esp-idf currently is a no-op, nvs_set_blob always writes
|
||||
|
||||
@@ -217,7 +217,7 @@ void ESP32TouchComponent::setup() {
|
||||
for (uint32_t i = 0; i < ONESHOT_SCAN_COUNT; i++) {
|
||||
err = touch_sensor_trigger_oneshot_scanning(this->sens_handle_, ONESHOT_SCAN_TIMEOUT_MS);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "Oneshot scan %d failed: %s", i, esp_err_to_name(err));
|
||||
ESP_LOGW(TAG, "Oneshot scan %" PRIu32 " failed: %s", i, esp_err_to_name(err));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "espnow_err.h"
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/defines.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
@@ -266,7 +268,7 @@ void ESPNowComponent::loop() {
|
||||
if (wifi::global_wifi_component != nullptr && wifi::global_wifi_component->is_connected()) {
|
||||
int32_t new_channel = wifi::global_wifi_component->get_wifi_channel();
|
||||
if (new_channel != this->wifi_channel_) {
|
||||
ESP_LOGI(TAG, "Wifi Channel is changed from %d to %d.", this->wifi_channel_, new_channel);
|
||||
ESP_LOGI(TAG, "Wifi Channel is changed from %d to %" PRId32 ".", this->wifi_channel_, new_channel);
|
||||
this->wifi_channel_ = new_channel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ static const char *const TAG = "http_request";
|
||||
void HttpRequestComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG,
|
||||
"HTTP Request:\n"
|
||||
" Timeout: %ums\n"
|
||||
" Timeout: %" PRIu32 "ms\n"
|
||||
" User-Agent: %s\n"
|
||||
" Follow redirects: %s\n"
|
||||
" Redirect limit: %d",
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "hub75_component.h"
|
||||
#include "esphome/core/application.h"
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#ifdef USE_ESP32
|
||||
|
||||
namespace esphome::hub75 {
|
||||
@@ -58,7 +60,7 @@ void HUB75Display::dump_config() {
|
||||
config_.pins.oe, config_.pins.clk);
|
||||
|
||||
ESP_LOGCONFIG(TAG,
|
||||
" Clock Speed: %u MHz\n"
|
||||
" Clock Speed: %" PRIu32 " MHz\n"
|
||||
" Latch Blanking: %i\n"
|
||||
" Clock Phase: %s\n"
|
||||
" Min Refresh Rate: %i Hz\n"
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#include "infrared.h"
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#ifdef USE_API
|
||||
@@ -100,7 +103,7 @@ void Infrared::control(const InfraredCall &call) {
|
||||
// Zero-copy from packed protobuf data
|
||||
transmit_data->set_data_from_packed_sint32(call.get_packed_data(), call.get_packed_length(),
|
||||
call.get_packed_count());
|
||||
ESP_LOGD(TAG, "Transmitting packed raw timings: count=%u, repeat=%u", call.get_packed_count(),
|
||||
ESP_LOGD(TAG, "Transmitting packed raw timings: count=%" PRIu16 ", repeat=%" PRIu32, call.get_packed_count(),
|
||||
call.get_repeat_count());
|
||||
} else if (call.is_base64url()) {
|
||||
// Decode base64url (URL-safe) into transmit buffer
|
||||
@@ -113,16 +116,16 @@ void Infrared::control(const InfraredCall &call) {
|
||||
for (int32_t timing : transmit_data->get_data()) {
|
||||
int32_t abs_timing = timing < 0 ? -timing : timing;
|
||||
if (abs_timing > max_timing_us) {
|
||||
ESP_LOGE(TAG, "Invalid timing value: %d µs (max %d)", timing, max_timing_us);
|
||||
ESP_LOGE(TAG, "Invalid timing value: %" PRId32 " µs (max %" PRId32 ")", timing, max_timing_us);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ESP_LOGD(TAG, "Transmitting base64url raw timings: count=%zu, repeat=%u", transmit_data->get_data().size(),
|
||||
ESP_LOGD(TAG, "Transmitting base64url raw timings: count=%zu, repeat=%" PRIu32, transmit_data->get_data().size(),
|
||||
call.get_repeat_count());
|
||||
} else {
|
||||
// From vector (lambdas/automations)
|
||||
transmit_data->set_data(call.get_raw_timings());
|
||||
ESP_LOGD(TAG, "Transmitting raw timings: count=%zu, repeat=%u", call.get_raw_timings().size(),
|
||||
ESP_LOGD(TAG, "Transmitting raw timings: count=%zu, repeat=%" PRIu32, call.get_raw_timings().size(),
|
||||
call.get_repeat_count());
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#include <hal/gpio_hal.h>
|
||||
|
||||
namespace esphome {
|
||||
@@ -193,7 +195,7 @@ void Inkplate::dump_config() {
|
||||
ESP_LOGCONFIG(TAG,
|
||||
" Greyscale: %s\n"
|
||||
" Partial Updating: %s\n"
|
||||
" Full Update Every: %d",
|
||||
" Full Update Every: %" PRIu32,
|
||||
YESNO(this->greyscale_), YESNO(this->partial_updating_), this->full_update_every_);
|
||||
// Log pins
|
||||
LOG_PIN(" CKV Pin: ", this->ckv_pin_);
|
||||
@@ -306,7 +308,7 @@ void Inkplate::fill(Color color) {
|
||||
// If clipping is active, fall back to base implementation
|
||||
if (this->get_clipping().is_set()) {
|
||||
Display::fill(color);
|
||||
ESP_LOGV(TAG, "Fill finished (%ums)", millis() - start_time);
|
||||
ESP_LOGV(TAG, "Fill finished (%" PRIu32 "ms)", millis() - start_time);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -329,12 +331,12 @@ void Inkplate::display() {
|
||||
this->display3b_();
|
||||
} else {
|
||||
if (this->partial_updating_ && this->partial_update_()) {
|
||||
ESP_LOGV(TAG, "Display finished (partial) (%ums)", millis() - start_time);
|
||||
ESP_LOGV(TAG, "Display finished (partial) (%" PRIu32 "ms)", millis() - start_time);
|
||||
return;
|
||||
}
|
||||
this->display1b_();
|
||||
}
|
||||
ESP_LOGV(TAG, "Display finished (full) (%ums)", millis() - start_time);
|
||||
ESP_LOGV(TAG, "Display finished (full) (%" PRIu32 "ms)", millis() - start_time);
|
||||
}
|
||||
|
||||
void Inkplate::display1b_() {
|
||||
@@ -409,7 +411,7 @@ void Inkplate::display1b_() {
|
||||
|
||||
uint32_t clock = (1UL << this->cl_pin_->get_pin());
|
||||
uint32_t data_mask = this->get_data_pin_mask_();
|
||||
ESP_LOGV(TAG, "Display1b start loops (%ums)", millis() - start_time);
|
||||
ESP_LOGV(TAG, "Display1b start loops (%" PRIu32 "ms)", millis() - start_time);
|
||||
|
||||
for (uint8_t k = 0; k < rep; k++) {
|
||||
buffer_ptr = &this->buffer_[this->get_buffer_length_() - 1];
|
||||
@@ -440,7 +442,7 @@ void Inkplate::display1b_() {
|
||||
}
|
||||
delayMicroseconds(230);
|
||||
}
|
||||
ESP_LOGV(TAG, "Display1b first loop x %d (%ums)", 4, millis() - start_time);
|
||||
ESP_LOGV(TAG, "Display1b first loop x %d (%" PRIu32 "ms)", 4, millis() - start_time);
|
||||
|
||||
buffer_ptr = &this->buffer_[this->get_buffer_length_() - 1];
|
||||
vscan_start_();
|
||||
@@ -469,7 +471,7 @@ void Inkplate::display1b_() {
|
||||
vscan_end_();
|
||||
}
|
||||
delayMicroseconds(230);
|
||||
ESP_LOGV(TAG, "Display1b second loop (%ums)", millis() - start_time);
|
||||
ESP_LOGV(TAG, "Display1b second loop (%" PRIu32 "ms)", millis() - start_time);
|
||||
|
||||
if (this->model_ == INKPLATE_6_PLUS) {
|
||||
clean_fast_(2, 2);
|
||||
@@ -495,13 +497,13 @@ void Inkplate::display1b_() {
|
||||
vscan_end_();
|
||||
}
|
||||
delayMicroseconds(230);
|
||||
ESP_LOGV(TAG, "Display1b third loop (%ums)", millis() - start_time);
|
||||
ESP_LOGV(TAG, "Display1b third loop (%" PRIu32 "ms)", millis() - start_time);
|
||||
}
|
||||
vscan_start_();
|
||||
eink_off_();
|
||||
this->block_partial_ = false;
|
||||
this->partial_updates_ = 0;
|
||||
ESP_LOGV(TAG, "Display1b finished (%ums)", millis() - start_time);
|
||||
ESP_LOGV(TAG, "Display1b finished (%" PRIu32 "ms)", millis() - start_time);
|
||||
}
|
||||
|
||||
void Inkplate::display3b_() {
|
||||
@@ -614,7 +616,7 @@ void Inkplate::display3b_() {
|
||||
clean_fast_(3, 1);
|
||||
vscan_start_();
|
||||
eink_off_();
|
||||
ESP_LOGV(TAG, "Display3b finished (%ums)", millis() - start_time);
|
||||
ESP_LOGV(TAG, "Display3b finished (%" PRIu32 "ms)", millis() - start_time);
|
||||
}
|
||||
|
||||
bool Inkplate::partial_update_() {
|
||||
@@ -641,7 +643,7 @@ bool Inkplate::partial_update_() {
|
||||
this->partial_buffer_2_[n--] = LUTW[diffw & 0x0F] & LUTB[diffb & 0x0F];
|
||||
}
|
||||
}
|
||||
ESP_LOGV(TAG, "Partial update buffer built after (%ums)", millis() - start_time);
|
||||
ESP_LOGV(TAG, "Partial update buffer built after (%" PRIu32 "ms)", millis() - start_time);
|
||||
|
||||
int rep = (this->model_ == INKPLATE_6_V2) ? 6 : 5;
|
||||
|
||||
@@ -667,7 +669,7 @@ bool Inkplate::partial_update_() {
|
||||
vscan_end_();
|
||||
}
|
||||
delayMicroseconds(230);
|
||||
ESP_LOGV(TAG, "Partial update loop k=%d (%ums)", k, millis() - start_time);
|
||||
ESP_LOGV(TAG, "Partial update loop k=%d (%" PRIu32 "ms)", k, millis() - start_time);
|
||||
}
|
||||
clean_fast_(2, 2);
|
||||
clean_fast_(3, 1);
|
||||
@@ -675,7 +677,7 @@ bool Inkplate::partial_update_() {
|
||||
eink_off_();
|
||||
|
||||
memcpy(this->buffer_, this->partial_buffer_, this->get_buffer_length_());
|
||||
ESP_LOGV(TAG, "Partial update finished (%ums)", millis() - start_time);
|
||||
ESP_LOGV(TAG, "Partial update finished (%" PRIu32 "ms)", millis() - start_time);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -730,7 +732,7 @@ void Inkplate::clean() {
|
||||
clean_fast_(0, 8); // Black to Black
|
||||
clean_fast_(2, 1); // Black to White
|
||||
clean_fast_(1, 10); // White to White
|
||||
ESP_LOGV(TAG, "Clean finished (%ums)", millis() - start_time);
|
||||
ESP_LOGV(TAG, "Clean finished (%" PRIu32 "ms)", millis() - start_time);
|
||||
}
|
||||
|
||||
void Inkplate::clean_fast_(uint8_t c, uint8_t rep) {
|
||||
@@ -773,9 +775,9 @@ void Inkplate::clean_fast_(uint8_t c, uint8_t rep) {
|
||||
vscan_end_();
|
||||
}
|
||||
delayMicroseconds(230);
|
||||
ESP_LOGV(TAG, "Clean fast rep loop %d finished (%ums)", k, millis() - start_time);
|
||||
ESP_LOGV(TAG, "Clean fast rep loop %d finished (%" PRIu32 "ms)", k, millis() - start_time);
|
||||
}
|
||||
ESP_LOGV(TAG, "Clean fast finished (%ums)", millis() - start_time);
|
||||
ESP_LOGV(TAG, "Clean fast finished (%" PRIu32 "ms)", millis() - start_time);
|
||||
}
|
||||
|
||||
void Inkplate::pins_z_state_() {
|
||||
|
||||
@@ -22,11 +22,18 @@ extern "C" {
|
||||
uint32_t temp_single_get_current_temperature(uint32_t *temp_value);
|
||||
}
|
||||
#endif // USE_BK72XX
|
||||
#if defined(USE_ZEPHYR) && defined(USE_NRF52)
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/drivers/sensor.h>
|
||||
#endif // USE_ZEPHYR && USE_NRF52
|
||||
|
||||
namespace esphome {
|
||||
namespace internal_temperature {
|
||||
|
||||
static const char *const TAG = "internal_temperature";
|
||||
#if defined(USE_ZEPHYR) && defined(USE_NRF52)
|
||||
static const struct device *const DIE_TEMPERATURE_SENSOR = DEVICE_DT_GET_ONE(nordic_nrf_temp);
|
||||
#endif // USE_ZEPHYR && USE_NRF52
|
||||
#ifdef USE_ESP32
|
||||
#if defined(USE_ESP32_VARIANT_ESP32C2) || defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C5) || \
|
||||
defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32C61) || defined(USE_ESP32_VARIANT_ESP32H2) || \
|
||||
@@ -36,6 +43,37 @@ static temperature_sensor_handle_t tsensNew = NULL;
|
||||
#endif // USE_ESP32
|
||||
|
||||
void InternalTemperatureSensor::update() {
|
||||
#if defined(USE_ZEPHYR) && defined(USE_NRF52)
|
||||
struct sensor_value value;
|
||||
int result = sensor_sample_fetch(DIE_TEMPERATURE_SENSOR);
|
||||
if (result != 0) {
|
||||
ESP_LOGE(TAG, "Failed to fetch nRF52 die temperature sample (%d)", result);
|
||||
if (!this->has_state()) {
|
||||
this->publish_state(NAN);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
result = sensor_channel_get(DIE_TEMPERATURE_SENSOR, SENSOR_CHAN_DIE_TEMP, &value);
|
||||
if (result != 0) {
|
||||
ESP_LOGE(TAG, "Failed to get nRF52 die temperature (%d)", result);
|
||||
if (!this->has_state()) {
|
||||
this->publish_state(NAN);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const float temperature = value.val1 + (value.val2 / 1000000.0f);
|
||||
if (std::isfinite(temperature)) {
|
||||
this->publish_state(temperature);
|
||||
} else {
|
||||
ESP_LOGD(TAG, "Ignoring invalid nRF52 temperature (value=%.1f)", temperature);
|
||||
if (!this->has_state()) {
|
||||
this->publish_state(NAN);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
float temperature = NAN;
|
||||
bool success = false;
|
||||
#ifdef USE_ESP32
|
||||
@@ -79,9 +117,17 @@ void InternalTemperatureSensor::update() {
|
||||
this->publish_state(NAN);
|
||||
}
|
||||
}
|
||||
#endif // USE_ZEPHYR && USE_NRF52
|
||||
}
|
||||
|
||||
void InternalTemperatureSensor::setup() {
|
||||
#if defined(USE_ZEPHYR) && defined(USE_NRF52)
|
||||
if (!device_is_ready(DIE_TEMPERATURE_SENSOR)) {
|
||||
ESP_LOGE(TAG, "nRF52 die temperature sensor device %s not ready", DIE_TEMPERATURE_SENSOR->name);
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
#endif // USE_ZEPHYR && USE_NRF52
|
||||
#ifdef USE_ESP32
|
||||
#if defined(USE_ESP32_VARIANT_ESP32C2) || defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C5) || \
|
||||
defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32C61) || defined(USE_ESP32_VARIANT_ESP32H2) || \
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
import esphome.codegen as cg
|
||||
from esphome.components import sensor
|
||||
from esphome.components.zephyr import zephyr_add_prj_conf
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
PLATFORM_BK72XX,
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_NRF52,
|
||||
PLATFORM_RP2040,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
UNIT_CELSIUS,
|
||||
)
|
||||
from esphome.core import CORE
|
||||
|
||||
internal_temperature_ns = cg.esphome_ns.namespace("internal_temperature")
|
||||
InternalTemperatureSensor = internal_temperature_ns.class_(
|
||||
@@ -25,10 +28,14 @@ CONFIG_SCHEMA = cv.All(
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
).extend(cv.polling_component_schema("60s")),
|
||||
cv.only_on([PLATFORM_ESP32, PLATFORM_RP2040, PLATFORM_BK72XX]),
|
||||
cv.only_on([PLATFORM_ESP32, PLATFORM_RP2040, PLATFORM_BK72XX, PLATFORM_NRF52]),
|
||||
)
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
var = await sensor.new_sensor(config)
|
||||
await cg.register_component(var, config)
|
||||
|
||||
if CORE.using_zephyr and CORE.is_nrf52:
|
||||
zephyr_add_prj_conf("SENSOR", True)
|
||||
zephyr_add_prj_conf("TEMP_NRF5", True)
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
|
||||
@@ -575,7 +576,7 @@ void LD2450Component::handle_periodic_data_() {
|
||||
if (this->get_timeout_status_(this->presence_millis_)) {
|
||||
this->target_binary_sensor_->publish_state(false);
|
||||
} else {
|
||||
ESP_LOGV(TAG, "Clear presence waiting timeout: %d", this->timeout_);
|
||||
ESP_LOGV(TAG, "Clear presence waiting timeout: %" PRIu32, this->timeout_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,16 +108,21 @@ bool LibreTinyPreferences::sync() {
|
||||
}
|
||||
written++;
|
||||
} else {
|
||||
ESP_LOGD(TAG, "FDB data not changed; skipping %" PRIu32 " len=%zu", save.key, save.data.size());
|
||||
ESP_LOGV(TAG, "FDB data not changed; skipping %" PRIu32 " len=%zu", save.key, save.data.size());
|
||||
cached++;
|
||||
}
|
||||
}
|
||||
s_pending_save.clear();
|
||||
|
||||
ESP_LOGD(TAG, "Writing %d items: %d cached, %d written, %d failed", cached + written + failed, cached, written,
|
||||
failed);
|
||||
if (failed > 0) {
|
||||
ESP_LOGE(TAG, "Writing %d items failed. Last error=%d for key=%" PRIu32, failed, last_err, last_key);
|
||||
ESP_LOGW(TAG, "Writing %d items: %d cached, %d written, %d failed. Last error=%d for key=%" PRIu32,
|
||||
cached + written + failed, cached, written, failed, last_err, last_key);
|
||||
} else if (written > 0) {
|
||||
ESP_LOGD(TAG, "Writing %d items: %d cached, %d written, %d failed", cached + written + failed, cached, written,
|
||||
failed);
|
||||
} else {
|
||||
ESP_LOGV(TAG, "Writing %d items: %d cached, %d written, %d failed", cached + written + failed, cached, written,
|
||||
failed);
|
||||
}
|
||||
|
||||
return failed == 0;
|
||||
|
||||
@@ -48,6 +48,7 @@ from esphome.yaml_util import load_yaml
|
||||
|
||||
from . import defines as df, helpers, lv_validation as lvalid, widgets
|
||||
from .automation import focused_widgets, layers_to_code, lvgl_update, refreshed_widgets
|
||||
from .defines import CONF_ALIGN_TO_LAMBDA_ID
|
||||
from .encoders import (
|
||||
ENCODERS_CONFIG,
|
||||
encoders_to_code,
|
||||
@@ -69,8 +70,16 @@ from .schemas import (
|
||||
)
|
||||
from .styles import styles_to_code, theme_to_code
|
||||
from .touchscreens import touchscreen_schema, touchscreens_to_code
|
||||
from .trigger import add_on_boot_triggers, generate_triggers
|
||||
from .types import IdleTrigger, PlainTrigger, lv_font_t, lv_group_t, lv_style_t, lvgl_ns
|
||||
from .trigger import add_on_boot_triggers, generate_align_tos, generate_triggers
|
||||
from .types import (
|
||||
IdleTrigger,
|
||||
PlainTrigger,
|
||||
lv_font_t,
|
||||
lv_group_t,
|
||||
lv_lambda_t,
|
||||
lv_style_t,
|
||||
lvgl_ns,
|
||||
)
|
||||
from .widgets import (
|
||||
LvScrActType,
|
||||
Widget,
|
||||
@@ -345,6 +354,7 @@ async def to_code(configs):
|
||||
Widget.widgets_completed = True
|
||||
async with LvContext():
|
||||
await generate_triggers()
|
||||
await generate_align_tos(configs[0])
|
||||
for config in configs:
|
||||
lv_component = await cg.get_variable(config[CONF_ID])
|
||||
await generate_page_triggers(config)
|
||||
@@ -458,6 +468,7 @@ LVGL_SCHEMA = cv.All(
|
||||
.extend(
|
||||
{
|
||||
cv.GenerateID(CONF_ID): cv.declare_id(LvglComponent),
|
||||
cv.GenerateID(CONF_ALIGN_TO_LAMBDA_ID): cv.declare_id(lv_lambda_t),
|
||||
cv.GenerateID(df.CONF_DISPLAYS): display_schema,
|
||||
cv.Optional(CONF_COLOR_DEPTH, default=16): cv.one_of(16),
|
||||
cv.Optional(
|
||||
|
||||
@@ -504,6 +504,7 @@ CONF_ACCEPTED_CHARS = "accepted_chars"
|
||||
CONF_ADJUSTABLE = "adjustable"
|
||||
CONF_ALIGN = "align"
|
||||
CONF_ALIGN_TO = "align_to"
|
||||
CONF_ALIGN_TO_LAMBDA_ID = "align_to_lambda_id"
|
||||
CONF_ANGLE_RANGE = "angle_range"
|
||||
CONF_ANIMATED = "animated"
|
||||
CONF_ANIMATION = "animation"
|
||||
|
||||
@@ -128,10 +128,19 @@ class LvPageType : public Parented<LvglComponent> {
|
||||
bool skip;
|
||||
};
|
||||
|
||||
using LvLambdaType = std::function<void(lv_obj_t *)>;
|
||||
using set_value_lambda_t = std::function<void(float)>;
|
||||
using event_callback_t = void(lv_event_t *);
|
||||
using text_lambda_t = std::function<const char *()>;
|
||||
|
||||
class LvLambdaComponent : public Component {
|
||||
public:
|
||||
LvLambdaComponent(void (*callback)()) : callback_(callback) {}
|
||||
|
||||
void setup() override { this->callback_(); }
|
||||
// execute after the LvglComponent is setup
|
||||
float get_setup_priority() const override { return setup_priority::PROCESSOR - 5; }
|
||||
|
||||
protected:
|
||||
void (*callback_)();
|
||||
};
|
||||
|
||||
template<typename... Ts> class ObjUpdateAction : public Action<Ts...> {
|
||||
public:
|
||||
|
||||
@@ -8,10 +8,13 @@ from esphome.const import (
|
||||
CONF_X,
|
||||
CONF_Y,
|
||||
)
|
||||
from esphome.cpp_generator import new_Pvariable
|
||||
from esphome.cpp_helpers import register_component
|
||||
|
||||
from .defines import (
|
||||
CONF_ALIGN,
|
||||
CONF_ALIGN_TO,
|
||||
CONF_ALIGN_TO_LAMBDA_ID,
|
||||
DIRECTIONS,
|
||||
LV_EVENT_MAP,
|
||||
LV_EVENT_TRIGGERS,
|
||||
@@ -89,14 +92,32 @@ async def generate_triggers():
|
||||
|
||||
await add_on_boot_triggers(w.config.get(CONF_ON_BOOT, ()))
|
||||
|
||||
# Generate align to directives while we're here
|
||||
if align_to := w.config.get(CONF_ALIGN_TO):
|
||||
|
||||
async def generate_align_tos(config: dict):
|
||||
"""
|
||||
Called once, with a full lvgl configuration to emit deferred align_to actions as a component
|
||||
that executes after the LVGL setup. This is required since align_to actions are not recalculated on layout changes
|
||||
and so must be applied after the display is properly laid out.
|
||||
:param config:
|
||||
:return:
|
||||
"""
|
||||
align_tos = tuple(
|
||||
w for w in widget_map.values() if w.config and CONF_ALIGN_TO in w.config
|
||||
)
|
||||
if align_tos:
|
||||
async with LambdaContext(where="align_to") as context:
|
||||
for w in align_tos:
|
||||
align_to = w.config[CONF_ALIGN_TO]
|
||||
target = widget_map[align_to[CONF_ID]].obj
|
||||
align = literal(align_to[CONF_ALIGN])
|
||||
x = align_to[CONF_X]
|
||||
y = align_to[CONF_Y]
|
||||
lv.obj_align_to(w.obj, target, align, x, y)
|
||||
|
||||
action_id = config[CONF_ALIGN_TO_LAMBDA_ID]
|
||||
var = new_Pvariable(action_id, await context.get_lambda())
|
||||
await register_component(var, {})
|
||||
|
||||
|
||||
async def add_trigger(conf, w, *events, is_selected=None):
|
||||
is_selected = is_selected or w.is_selected()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from esphome import automation, codegen as cg
|
||||
from esphome.const import CONF_TEXT, CONF_VALUE
|
||||
from esphome.cpp_generator import MockObj
|
||||
from esphome.cpp_types import esphome_ns
|
||||
from esphome.cpp_types import Component, esphome_ns
|
||||
|
||||
from .defines import lvgl_ns
|
||||
|
||||
@@ -51,7 +51,7 @@ IdleTrigger = lvgl_ns.class_("IdleTrigger", automation.Trigger.template())
|
||||
ObjUpdateAction = lvgl_ns.class_("ObjUpdateAction", automation.Action)
|
||||
LvglCondition = lvgl_ns.class_("LvglCondition", automation.Condition)
|
||||
LvglAction = lvgl_ns.class_("LvglAction", automation.Action)
|
||||
lv_lambda_t = lvgl_ns.class_("LvLambdaType")
|
||||
lv_lambda_t = lvgl_ns.class_("LvLambdaComponent", Component)
|
||||
LvCompound = lvgl_ns.class_("LvCompound")
|
||||
lv_font_t = cg.global_ns.class_("lv_font_t")
|
||||
lv_style_t = cg.global_ns.struct("lv_style_t")
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "max7219font.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cinttypes>
|
||||
|
||||
namespace esphome {
|
||||
namespace max7219digit {
|
||||
@@ -92,7 +93,9 @@ void MAX7219Component::loop() {
|
||||
if (this->scroll_mode_ == ScrollMode::STOP) {
|
||||
if (static_cast<size_t>(this->stepsleft_ + get_width_internal()) == first_line_size + 1) {
|
||||
if (millis_since_last_scroll < this->scroll_dwell_) {
|
||||
ESP_LOGVV(TAG, "Dwell time at end of string in case of stop at end. Step %d, since last scroll %d, dwell %d.",
|
||||
ESP_LOGVV(TAG,
|
||||
"Dwell time at end of string in case of stop at end. Step %d, since last scroll %" PRIu32
|
||||
", dwell %d.",
|
||||
this->stepsleft_, millis_since_last_scroll, this->scroll_dwell_);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ void Modbus::send_next_frame_() {
|
||||
this->last_send_ = millis();
|
||||
this->tx_buffer_.pop_front();
|
||||
if (!this->tx_buffer_.empty()) {
|
||||
ESP_LOGV(TAG, "Write queue contains %" PRIu32 " items.", this->tx_buffer_.size());
|
||||
ESP_LOGV(TAG, "Write queue contains %zu items.", this->tx_buffer_.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -319,14 +319,14 @@ void Nextion::filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radiu
|
||||
void Nextion::qrcode(uint16_t x1, uint16_t y1, const char *content, uint16_t size, uint16_t background_color,
|
||||
uint16_t foreground_color, int32_t logo_pic, uint8_t border_width) {
|
||||
this->add_no_result_to_queue_with_printf_(
|
||||
"qrcode", "qrcode %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu8 ",%" PRIu8 ",\"%s\"", x1,
|
||||
"qrcode", "qrcode %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRId32 ",%" PRIu8 ",\"%s\"", x1,
|
||||
y1, size, background_color, foreground_color, logo_pic, border_width, content);
|
||||
}
|
||||
|
||||
void Nextion::qrcode(uint16_t x1, uint16_t y1, const char *content, uint16_t size, Color background_color,
|
||||
Color foreground_color, int32_t logo_pic, uint8_t border_width) {
|
||||
this->add_no_result_to_queue_with_printf_(
|
||||
"qrcode", "qrcode %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu8 ",%" PRIu8 ",\"%s\"", x1,
|
||||
"qrcode", "qrcode %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRId32 ",%" PRIu8 ",\"%s\"", x1,
|
||||
y1, size, display::ColorUtil::color_to_565(background_color), display::ColorUtil::color_to_565(foreground_color),
|
||||
logo_pic, border_width, content);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "qmp6988.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cmath>
|
||||
|
||||
namespace esphome {
|
||||
@@ -129,7 +131,7 @@ bool QMP6988Component::get_calibration_data_() {
|
||||
|
||||
ESP_LOGV(TAG,
|
||||
"Calibration data:\n"
|
||||
" COE_a0[%d] COE_a1[%d] COE_a2[%d] COE_b00[%d]\n"
|
||||
" COE_a0[%" PRId32 "] COE_a1[%d] COE_a2[%d] COE_b00[%" PRId32 "]\n"
|
||||
" COE_bt1[%d] COE_bt2[%d] COE_bp1[%d] COE_b11[%d]\n"
|
||||
" COE_bp2[%d] COE_b12[%d] COE_b21[%d] COE_bp3[%d]",
|
||||
qmp6988_data_.qmp6988_cali.COE_a0, qmp6988_data_.qmp6988_cali.COE_a1, qmp6988_data_.qmp6988_cali.COE_a2,
|
||||
@@ -153,7 +155,7 @@ bool QMP6988Component::get_calibration_data_() {
|
||||
qmp6988_data_.ik.bp3 = 2915L * (int64_t) qmp6988_data_.qmp6988_cali.COE_bp3 + 157155561L; // 28Q65
|
||||
ESP_LOGV(TAG,
|
||||
"Int calibration data:\n"
|
||||
" a0[%d] a1[%d] a2[%d] b00[%d]\n"
|
||||
" a0[%" PRId32 "] a1[%" PRId32 "] a2[%" PRId32 "] b00[%" PRId32 "]\n"
|
||||
" bt1[%lld] bt2[%lld] bp1[%lld] b11[%lld]\n"
|
||||
" bp2[%lld] b12[%lld] b21[%lld] bp3[%lld]",
|
||||
qmp6988_data_.ik.a0, qmp6988_data_.ik.a1, qmp6988_data_.ik.a2, qmp6988_data_.ik.b00, qmp6988_data_.ik.bt1,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "rd03d.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cmath>
|
||||
|
||||
namespace esphome::rd03d {
|
||||
@@ -56,7 +58,7 @@ void RD03DComponent::dump_config() {
|
||||
*this->tracking_mode_ == TrackingMode::SINGLE_TARGET ? "single" : "multi");
|
||||
}
|
||||
if (this->throttle_ > 0) {
|
||||
ESP_LOGCONFIG(TAG, " Throttle: %ums", this->throttle_);
|
||||
ESP_LOGCONFIG(TAG, " Throttle: %" PRIu32 "ms", this->throttle_);
|
||||
}
|
||||
#ifdef USE_SENSOR
|
||||
LOG_SENSOR(" ", "Target Count", this->target_count_sensor_);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "symphony_protocol.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
namespace esphome {
|
||||
namespace remote_base {
|
||||
|
||||
@@ -26,8 +28,8 @@ static constexpr uint32_t INTER_FRAME_GAP_US = 34760;
|
||||
|
||||
void SymphonyProtocol::encode(RemoteTransmitData *dst, const SymphonyData &data) {
|
||||
dst->set_carrier_frequency(CARRIER_FREQUENCY);
|
||||
ESP_LOGD(TAG, "Sending Symphony: data=0x%0*X nbits=%u repeats=%u", (data.nbits + 3) / 4, (uint32_t) data.data,
|
||||
data.nbits, data.repeats);
|
||||
ESP_LOGD(TAG, "Sending Symphony: data=0x%0*" PRIX32 " nbits=%" PRIu8 " repeats=%" PRIu8, (data.nbits + 3) / 4,
|
||||
(uint32_t) data.data, data.nbits, data.repeats);
|
||||
// Each bit produces a mark+space (2 entries). We fold the inter-frame/footer gap
|
||||
// into the last bit's space of each frame to avoid over-length gaps.
|
||||
dst->reserve(data.nbits * 2u * data.repeats);
|
||||
@@ -112,8 +114,8 @@ optional<SymphonyData> SymphonyProtocol::decode(RemoteReceiveData src) {
|
||||
}
|
||||
|
||||
void SymphonyProtocol::dump(const SymphonyData &data) {
|
||||
const int32_t hex_width = (data.nbits + 3) / 4; // pad to nibble width
|
||||
ESP_LOGI(TAG, "Received Symphony: data=0x%0*X, nbits=%d", hex_width, (uint32_t) data.data, data.nbits);
|
||||
const int hex_width = (data.nbits + 3) / 4; // pad to nibble width
|
||||
ESP_LOGI(TAG, "Received Symphony: data=0x%0*" PRIX32 ", nbits=%" PRIu8, hex_width, (uint32_t) data.data, data.nbits);
|
||||
}
|
||||
|
||||
} // namespace remote_base
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
namespace esphome::runtime_image {
|
||||
|
||||
static const char *const TAG = "image_decoder.bmp";
|
||||
@@ -107,7 +109,7 @@ int HOT BmpDecoder::decode(uint8_t *buffer, size_t size) {
|
||||
}
|
||||
|
||||
if (this->compression_method_ != 0) {
|
||||
ESP_LOGE(TAG, "Unsupported compression method: %d", this->compression_method_);
|
||||
ESP_LOGE(TAG, "Unsupported compression method: %" PRIu32, this->compression_method_);
|
||||
return DECODE_ERROR_UNSUPPORTED_FORMAT;
|
||||
}
|
||||
|
||||
|
||||
@@ -113,6 +113,7 @@ from esphome.core.entity_helpers import (
|
||||
setup_unit_of_measurement,
|
||||
)
|
||||
from esphome.cpp_generator import MockObj, MockObjClass
|
||||
from esphome.schema_extractors import SCHEMA_EXTRACT, schema_extractor
|
||||
from esphome.util import Registry
|
||||
|
||||
CODEOWNERS = ["@esphome/core"]
|
||||
@@ -229,7 +230,10 @@ _SENSOR_ENTITY_CATEGORIES = {
|
||||
}
|
||||
|
||||
|
||||
@schema_extractor("enum")
|
||||
def sensor_entity_category(value):
|
||||
if value == SCHEMA_EXTRACT:
|
||||
return _SENSOR_ENTITY_CATEGORIES
|
||||
return cv.enum(_SENSOR_ENTITY_CATEGORIES, lower=True)(value)
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#ifdef USE_SERIAL_PROXY
|
||||
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include "esphome/core/util.h"
|
||||
|
||||
#ifdef USE_API
|
||||
@@ -74,7 +76,7 @@ void __attribute__((noinline)) SerialProxy::read_and_send_(size_t available) {
|
||||
|
||||
void SerialProxy::dump_config() {
|
||||
ESP_LOGCONFIG(TAG,
|
||||
"Serial Proxy [%u]:\n"
|
||||
"Serial Proxy [%" PRIu32 "]:\n"
|
||||
" Name: %s\n"
|
||||
" Port Type: %s\n"
|
||||
" RTS Pin: %s\n"
|
||||
@@ -89,7 +91,9 @@ void SerialProxy::dump_config() {
|
||||
|
||||
void SerialProxy::configure(uint32_t baudrate, bool flow_control, uint8_t parity, uint8_t stop_bits,
|
||||
uint8_t data_size) {
|
||||
ESP_LOGD(TAG, "Configuring serial proxy [%u]: baud=%u, flow_ctrl=%s, parity=%u, stop=%u, data=%u",
|
||||
ESP_LOGD(TAG,
|
||||
"Configuring serial proxy [%" PRIu32 "]: baud=%" PRIu32 ", flow_ctrl=%s, parity=%" PRIu8 ", stop=%" PRIu8
|
||||
", data=%" PRIu8,
|
||||
this->instance_index_, baudrate, YESNO(flow_control), parity, stop_bits, data_size);
|
||||
|
||||
auto *uart_comp = this->parent_;
|
||||
@@ -148,7 +152,7 @@ void SerialProxy::write_from_client(const uint8_t *data, size_t len) {
|
||||
void SerialProxy::set_modem_pins(uint32_t line_states) {
|
||||
const bool rts = (line_states & SERIAL_PROXY_LINE_STATE_FLAG_RTS) != 0;
|
||||
const bool dtr = (line_states & SERIAL_PROXY_LINE_STATE_FLAG_DTR) != 0;
|
||||
ESP_LOGV(TAG, "Setting modem pins [%u]: RTS=%s, DTR=%s", this->instance_index_, ONOFF(rts), ONOFF(dtr));
|
||||
ESP_LOGV(TAG, "Setting modem pins [%" PRIu32 "]: RTS=%s, DTR=%s", this->instance_index_, ONOFF(rts), ONOFF(dtr));
|
||||
|
||||
if (this->rts_pin_ != nullptr) {
|
||||
this->rts_state_ = rts;
|
||||
@@ -161,12 +165,12 @@ void SerialProxy::set_modem_pins(uint32_t line_states) {
|
||||
}
|
||||
|
||||
uint32_t SerialProxy::get_modem_pins() const {
|
||||
return (this->rts_state_ ? SERIAL_PROXY_LINE_STATE_FLAG_RTS : 0u) |
|
||||
(this->dtr_state_ ? SERIAL_PROXY_LINE_STATE_FLAG_DTR : 0u);
|
||||
return (this->rts_state_ ? static_cast<uint32_t>(SERIAL_PROXY_LINE_STATE_FLAG_RTS) : 0u) |
|
||||
(this->dtr_state_ ? static_cast<uint32_t>(SERIAL_PROXY_LINE_STATE_FLAG_DTR) : 0u);
|
||||
}
|
||||
|
||||
uart::UARTFlushResult SerialProxy::flush_port() {
|
||||
ESP_LOGV(TAG, "Flushing serial proxy [%u]", this->instance_index_);
|
||||
ESP_LOGV(TAG, "Flushing serial proxy [%" PRIu32 "]", this->instance_index_);
|
||||
return this->flush();
|
||||
}
|
||||
|
||||
@@ -180,19 +184,19 @@ void SerialProxy::serial_proxy_request(api::APIConnection *api_connection, api::
|
||||
}
|
||||
this->api_connection_ = api_connection;
|
||||
this->enable_loop();
|
||||
ESP_LOGV(TAG, "API connection subscribed to serial proxy [%u]", this->instance_index_);
|
||||
ESP_LOGV(TAG, "API connection subscribed to serial proxy [%" PRIu32 "]", this->instance_index_);
|
||||
break;
|
||||
case api::enums::SERIAL_PROXY_REQUEST_TYPE_UNSUBSCRIBE:
|
||||
if (this->api_connection_ != api_connection) {
|
||||
ESP_LOGV(TAG, "API connection is not subscribed to serial proxy [%u]", this->instance_index_);
|
||||
ESP_LOGV(TAG, "API connection is not subscribed to serial proxy [%" PRIu32 "]", this->instance_index_);
|
||||
return;
|
||||
}
|
||||
this->api_connection_ = nullptr;
|
||||
this->disable_loop();
|
||||
ESP_LOGV(TAG, "API connection unsubscribed from serial proxy [%u]", this->instance_index_);
|
||||
ESP_LOGV(TAG, "API connection unsubscribed from serial proxy [%" PRIu32 "]", this->instance_index_);
|
||||
break;
|
||||
default:
|
||||
ESP_LOGW(TAG, "Unknown serial proxy request type: %u", static_cast<uint32_t>(type));
|
||||
ESP_LOGW(TAG, "Unknown serial proxy request type: %" PRIu32, static_cast<uint32_t>(type));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "spa06_base.h"
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#include "esphome/core/helpers.h"
|
||||
|
||||
namespace esphome::spa06_base {
|
||||
@@ -195,7 +197,7 @@ bool SPA06Component::read_coefficients_() {
|
||||
ESP_LOGV(TAG,
|
||||
"Coefficients:\n"
|
||||
" c0: %i, c1: %i,\n"
|
||||
" c00: %i, c10: %i, c20: %i, c30: %i, c40: %i,\n"
|
||||
" c00: %" PRIi32 ", c10: %" PRIi32 ", c20: %i, c30: %i, c40: %i,\n"
|
||||
" c01: %i, c11: %i, c21: %i, c31: %i",
|
||||
this->c0_, this->c1_, this->c00_, this->c10_, this->c20_, this->c30_, this->c40_, this->c01_, this->c11_,
|
||||
this->c21_, this->c31_);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "sps30.h"
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
namespace esphome {
|
||||
namespace sps30 {
|
||||
|
||||
@@ -105,7 +107,7 @@ void SPS30Component::dump_config() {
|
||||
" Firmware version v%0d.%0d",
|
||||
this->serial_number_, this->raw_firmware_version_ >> 8, this->raw_firmware_version_ & 0xFF);
|
||||
if (this->idle_interval_.has_value()) {
|
||||
ESP_LOGCONFIG(TAG, " Idle interval: %us", this->idle_interval_.value() / 1000);
|
||||
ESP_LOGCONFIG(TAG, " Idle interval: %" PRIu32 "s", this->idle_interval_.value() / 1000);
|
||||
}
|
||||
LOG_SENSOR(" ", "PM1.0 Weight Concentration", this->pm_1_0_sensor_);
|
||||
LOG_SENSOR(" ", "PM2.5 Weight Concentration", this->pm_2_5_sensor_);
|
||||
@@ -142,8 +144,8 @@ void SPS30Component::update() {
|
||||
// If its not time to take an action, do nothing.
|
||||
const uint32_t update_start_ms = millis();
|
||||
if (this->next_state_ != NONE && (int32_t) (this->next_state_ms_ - update_start_ms) > 0) {
|
||||
ESP_LOGD(TAG, "Sensor waiting for %ums before transitioning to state %d.", (this->next_state_ms_ - update_start_ms),
|
||||
this->next_state_);
|
||||
ESP_LOGD(TAG, "Sensor waiting for %" PRIu32 "ms before transitioning to state %d.",
|
||||
(this->next_state_ms_ - update_start_ms), this->next_state_);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include <cinttypes>
|
||||
|
||||
namespace esphome::thermostat {
|
||||
|
||||
@@ -1346,15 +1347,16 @@ void ThermostatClimate::set_timer_duration_in_sec_(ThermostatClimateTimerIndex t
|
||||
|
||||
if (elapsed >= new_duration_ms) {
|
||||
// Timer should complete immediately (including when new_duration_ms is 0)
|
||||
ESP_LOGVV(TAG, "timer %d completing immediately (elapsed %d >= new %d)", timer_index, elapsed, new_duration_ms);
|
||||
ESP_LOGVV(TAG, "timer %d completing immediately (elapsed %" PRIu32 " >= new %" PRIu32 ")", timer_index, elapsed,
|
||||
new_duration_ms);
|
||||
this->timer_[timer_index].active = false;
|
||||
// Trigger the timer callback immediately
|
||||
this->call_timer_callback_(timer_index);
|
||||
return;
|
||||
} else {
|
||||
// Adjust timer to run for remaining time - keep original start time
|
||||
ESP_LOGVV(TAG, "timer %d adjusted: elapsed %d, new total %d, remaining %d", timer_index, elapsed, new_duration_ms,
|
||||
new_duration_ms - elapsed);
|
||||
ESP_LOGVV(TAG, "timer %d adjusted: elapsed %" PRIu32 ", new total %" PRIu32 ", remaining %" PRIu32, timer_index,
|
||||
elapsed, new_duration_ms, new_duration_ms - elapsed);
|
||||
this->timer_[timer_index].time = new_duration_ms;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <cinttypes>
|
||||
#include <vector>
|
||||
|
||||
#include "tormatic_cover.h"
|
||||
@@ -120,11 +121,11 @@ void Tormatic::recalibrate_duration_(GateStatus s) {
|
||||
|
||||
if (s == OPENED) {
|
||||
this->open_duration_ = now - this->direction_start_time_;
|
||||
ESP_LOGI(TAG, "Recalibrated the gate's open duration to %dms", this->open_duration_);
|
||||
ESP_LOGI(TAG, "Recalibrated the gate's open duration to %" PRIu32 "ms", this->open_duration_);
|
||||
}
|
||||
if (s == CLOSED) {
|
||||
this->close_duration_ = now - this->direction_start_time_;
|
||||
ESP_LOGI(TAG, "Recalibrated the gate's close duration to %dms", this->close_duration_);
|
||||
ESP_LOGI(TAG, "Recalibrated the gate's close duration to %" PRIu32 "ms", this->close_duration_);
|
||||
}
|
||||
|
||||
this->direction_start_time_ = 0;
|
||||
@@ -269,7 +270,7 @@ optional<GateStatus> Tormatic::read_gate_status_() {
|
||||
switch (hdr.type) {
|
||||
case STATUS: {
|
||||
if (hdr.payload_size() != sizeof(StatusReply)) {
|
||||
ESP_LOGE(TAG, "Header specifies payload size %d but size of StatusReply is %d", hdr.payload_size(),
|
||||
ESP_LOGE(TAG, "Header specifies payload size %" PRIu32 " but size of StatusReply is %zu", hdr.payload_size(),
|
||||
sizeof(StatusReply));
|
||||
}
|
||||
|
||||
@@ -294,7 +295,7 @@ optional<GateStatus> Tormatic::read_gate_status_() {
|
||||
default:
|
||||
// Unknown message type, drain the remaining amount of bytes specified in
|
||||
// the header.
|
||||
ESP_LOGE(TAG, "Reading remaining %d payload bytes of unknown type 0x%x", hdr.payload_size(), hdr.type);
|
||||
ESP_LOGE(TAG, "Reading remaining %" PRIu32 " payload bytes of unknown type 0x%x", hdr.payload_size(), hdr.type);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -339,7 +340,7 @@ template<typename T> optional<T> Tormatic::read_data_() {
|
||||
}
|
||||
obj.byteswap();
|
||||
|
||||
ESP_LOGV(TAG, "Read %s in %d ms", obj.print().c_str(), millis() - start);
|
||||
ESP_LOGV(TAG, "Read %s in %" PRIu32 " ms", obj.print().c_str(), millis() - start);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#include "esphome/components/cover/cover.h"
|
||||
|
||||
/**
|
||||
@@ -86,7 +88,7 @@ struct MessageHeader {
|
||||
std::string print() {
|
||||
// 64 bytes: "MessageHeader: seq " + uint16 + ", len " + uint32 + ", type " + type + safety margin
|
||||
char buf[64];
|
||||
buf_append_printf(buf, sizeof(buf), 0, "MessageHeader: seq %d, len %d, type %s", this->seq, this->len,
|
||||
buf_append_printf(buf, sizeof(buf), 0, "MessageHeader: seq %d, len %" PRIu32 ", type %s", this->seq, this->len,
|
||||
message_type_to_str(this->type));
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@ void IDFUARTComponent::set_rx_timeout(size_t rx_timeout) {
|
||||
void IDFUARTComponent::write_array(const uint8_t *data, size_t len) {
|
||||
int32_t write_len = uart_write_bytes(this->uart_num_, data, len);
|
||||
if (write_len != (int32_t) len) {
|
||||
ESP_LOGW(TAG, "uart_write_bytes failed: %d != %zu", write_len, len);
|
||||
ESP_LOGW(TAG, "uart_write_bytes failed: %" PRId32 " != %zu", write_len, len);
|
||||
this->mark_failed();
|
||||
}
|
||||
#ifdef USE_UART_DEBUGGER
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
namespace esphome {
|
||||
namespace uponor_smatrix {
|
||||
|
||||
@@ -10,7 +12,7 @@ static const char *const TAG = "uponor_smatrix.climate";
|
||||
|
||||
void UponorSmatrixClimate::dump_config() {
|
||||
LOG_CLIMATE("", "Uponor Smatrix Climate", this);
|
||||
ESP_LOGCONFIG(TAG, " Device address: 0x%08X", this->address_);
|
||||
ESP_LOGCONFIG(TAG, " Device address: 0x%08" PRIX32, this->address_);
|
||||
}
|
||||
|
||||
void UponorSmatrixClimate::loop() {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "uponor_smatrix_sensor.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
namespace esphome {
|
||||
namespace uponor_smatrix {
|
||||
|
||||
@@ -9,7 +11,7 @@ static const char *const TAG = "uponor_smatrix.sensor";
|
||||
void UponorSmatrixSensor::dump_config() {
|
||||
ESP_LOGCONFIG(TAG,
|
||||
"Uponor Smatrix Sensor\n"
|
||||
" Device address: 0x%08X",
|
||||
" Device address: 0x%08" PRIX32,
|
||||
this->address_);
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
|
||||
LOG_SENSOR(" ", "External Temperature", this->external_temperature_sensor_);
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
namespace esphome {
|
||||
namespace uponor_smatrix {
|
||||
|
||||
@@ -24,7 +26,7 @@ void UponorSmatrixComponent::dump_config() {
|
||||
#ifdef USE_TIME
|
||||
if (this->time_id_ != nullptr) {
|
||||
ESP_LOGCONFIG(TAG, " Time synchronization: YES");
|
||||
ESP_LOGCONFIG(TAG, " Time master device address: 0x%08X", this->time_device_address_);
|
||||
ESP_LOGCONFIG(TAG, " Time master device address: 0x%08" PRIX32 "", this->time_device_address_);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -33,7 +35,7 @@ void UponorSmatrixComponent::dump_config() {
|
||||
if (!this->unknown_devices_.empty()) {
|
||||
ESP_LOGCONFIG(TAG, " Detected unknown device addresses:");
|
||||
for (auto device_address : this->unknown_devices_) {
|
||||
ESP_LOGCONFIG(TAG, " 0x%08X", device_address);
|
||||
ESP_LOGCONFIG(TAG, " 0x%08" PRIX32 "", device_address);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,14 +105,14 @@ bool UponorSmatrixComponent::parse_byte_(uint8_t byte) {
|
||||
#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
|
||||
char hex_buf[format_hex_size(UPONOR_MAX_LOG_BYTES)];
|
||||
#endif
|
||||
ESP_LOGV(TAG, "Received packet: addr=%08X, data=%s, crc=%04X", device_address,
|
||||
ESP_LOGV(TAG, "Received packet: addr=%08" PRIX32 ", data=%s, crc=%04X", device_address,
|
||||
format_hex_to(hex_buf, &packet[4], packet_len - 6), crc);
|
||||
|
||||
// Handle packet
|
||||
size_t data_len = (packet_len - 6) / 3;
|
||||
if (data_len == 0) {
|
||||
if (packet[4] == UPONOR_ID_REQUEST)
|
||||
ESP_LOGVV(TAG, "Ignoring request packet for device 0x%08X", device_address);
|
||||
ESP_LOGVV(TAG, "Ignoring request packet for device 0x%08" PRIX32 "", device_address);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -135,7 +137,7 @@ bool UponorSmatrixComponent::parse_byte_(uint8_t byte) {
|
||||
if (data[i].id == UPONOR_ID_DATETIME1)
|
||||
found_time = true;
|
||||
if (found_temperature && found_time) {
|
||||
ESP_LOGI(TAG, "Using detected time device address 0x%08X", device_address);
|
||||
ESP_LOGI(TAG, "Using detected time device address 0x%08" PRIX32 "", device_address);
|
||||
this->time_device_address_ = device_address;
|
||||
break;
|
||||
}
|
||||
@@ -154,7 +156,7 @@ bool UponorSmatrixComponent::parse_byte_(uint8_t byte) {
|
||||
|
||||
// Log unknown device addresses
|
||||
if (!found && !this->unknown_devices_.count(device_address)) {
|
||||
ESP_LOGI(TAG, "Received packet for unknown device address 0x%08X ", device_address);
|
||||
ESP_LOGI(TAG, "Received packet for unknown device address 0x%08" PRIX32 " ", device_address);
|
||||
this->unknown_devices_.insert(device_address);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "vl53l0x_sensor.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
/*
|
||||
* Most of the code in this integration is based on the VL53L0x library
|
||||
* by Pololu (Pololu Corporation), which in turn is based on the VL53L0X
|
||||
@@ -28,8 +30,8 @@ void VL53L0XSensor::dump_config() {
|
||||
LOG_PIN(" Enable Pin: ", this->enable_pin_);
|
||||
}
|
||||
ESP_LOGCONFIG(TAG,
|
||||
" Timeout: %u%s\n"
|
||||
" Timing Budget %uus ",
|
||||
" Timeout: %" PRIu32 "%s\n"
|
||||
" Timing Budget %" PRIu32 "us ",
|
||||
this->timeout_us_, this->timeout_us_ > 0 ? "us" : " (no timeout)", this->measurement_timing_budget_us_);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "water_heater.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/controller_registry.h"
|
||||
#include "esphome/core/progmem.h"
|
||||
@@ -110,7 +112,8 @@ void WaterHeaterCall::validate_() {
|
||||
auto traits = this->parent_->get_traits();
|
||||
if (this->mode_.has_value()) {
|
||||
if (!traits.supports_mode(*this->mode_)) {
|
||||
ESP_LOGW(TAG, "'%s' - Mode %d not supported", this->parent_->get_name().c_str(), *this->mode_);
|
||||
ESP_LOGW(TAG, "'%s' - Mode %" PRIu32 " not supported", this->parent_->get_name().c_str(),
|
||||
static_cast<uint32_t>(*this->mode_));
|
||||
this->mode_.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#ifdef USE_API
|
||||
|
||||
#include "esphome/components/api/api_server.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
@@ -160,7 +162,7 @@ void ZWaveProxy::zwave_proxy_request(api::APIConnection *api_connection, api::en
|
||||
break;
|
||||
|
||||
default:
|
||||
ESP_LOGW(TAG, "Unknown request type: %d", type);
|
||||
ESP_LOGW(TAG, "Unknown request type: %" PRIu32, static_cast<uint32_t>(type));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,10 +417,14 @@ def icon(value):
|
||||
return value
|
||||
|
||||
|
||||
@schema_extractor("use_id")
|
||||
def sub_device_id(value: str | None) -> core.ID | None:
|
||||
# Lazy import to avoid circular imports
|
||||
from esphome.core.config import Device
|
||||
|
||||
if value == SCHEMA_EXTRACT:
|
||||
return Device
|
||||
|
||||
if not value:
|
||||
return None
|
||||
|
||||
|
||||
@@ -71,11 +71,13 @@ def register_component_source(name: str) -> int:
|
||||
return pool.sources[name]
|
||||
idx = len(pool.sources) + 1
|
||||
if idx > _MAX_COMPONENT_SOURCES:
|
||||
_LOGGER.warning(
|
||||
"Too many unique component source names (max %d), '%s' will show as '<unknown>'",
|
||||
_MAX_COMPONENT_SOURCES,
|
||||
name,
|
||||
)
|
||||
if not CORE.testing_mode:
|
||||
_LOGGER.warning(
|
||||
"Too many unique component source names (max %d), "
|
||||
"'%s' will show as '<unknown>'",
|
||||
_MAX_COMPONENT_SOURCES,
|
||||
name,
|
||||
)
|
||||
return 0
|
||||
pool.sources[name] = idx
|
||||
_ensure_source_table_registered()
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ freetype-py==2.5.1
|
||||
jinja2==3.1.6
|
||||
bleak==2.1.1
|
||||
smpclient==6.0.0
|
||||
requests==2.33.0
|
||||
requests==2.33.1
|
||||
|
||||
# esp-idf >= 5.0 requires this
|
||||
pyparsing >= 3.0
|
||||
|
||||
+143
-63
@@ -67,19 +67,16 @@ def get_component_names():
|
||||
# pylint: disable-next=redefined-outer-name,reimported
|
||||
from esphome.loader import CORE_COMPONENTS_PATH
|
||||
|
||||
component_names = ["esphome", "sensor", "esp32", "esp8266"]
|
||||
skip_components = []
|
||||
|
||||
for d in CORE_COMPONENTS_PATH.iterdir():
|
||||
if (
|
||||
not d.name.startswith("__")
|
||||
and d.is_dir()
|
||||
and d.name not in component_names
|
||||
and d.name not in skip_components
|
||||
):
|
||||
component_names.append(d.name)
|
||||
|
||||
return sorted(component_names)
|
||||
# return sorted(
|
||||
# ["esphome", "sensor", "esp32", "esp8266", "adc", "touchscreen", "xpt2046"]
|
||||
# )
|
||||
return sorted(
|
||||
[
|
||||
d.name
|
||||
for d in CORE_COMPONENTS_PATH.iterdir()
|
||||
if not d.name.startswith("__") and d.is_dir()
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def load_components():
|
||||
@@ -120,39 +117,57 @@ from esphome.util import Registry # noqa: E402
|
||||
# pylint: enable=wrong-import-position
|
||||
|
||||
|
||||
def sort_obj(obj):
|
||||
if isinstance(obj, dict):
|
||||
return {k: sort_obj(v) for k, v in sorted(obj.items(), key=lambda x: str(x[0]))}
|
||||
if isinstance(obj, list):
|
||||
return [sort_obj(item) for item in obj]
|
||||
return obj
|
||||
|
||||
|
||||
def write_file(name, obj):
|
||||
full_path = Path(args.output_path) / f"{name}.json"
|
||||
sorted_obj = sort_obj(obj)
|
||||
if JSON_DUMP_PRETTY:
|
||||
json_str = json.dumps(obj, indent=2)
|
||||
json_str = json.dumps(sorted_obj, indent=2)
|
||||
else:
|
||||
json_str = json.dumps(obj, separators=(",", ":"))
|
||||
json_str = json.dumps(sorted_obj, separators=(",", ":"))
|
||||
write_file_if_changed(full_path, json_str)
|
||||
print(f"Wrote {full_path}")
|
||||
|
||||
|
||||
def delete_extra_files(keep_names):
|
||||
output_path = Path(args.output_path)
|
||||
count = 0
|
||||
for d in output_path.iterdir():
|
||||
if d.suffix == ".json" and d.stem not in keep_names:
|
||||
count += 1
|
||||
d.unlink()
|
||||
print(f"Deleted {d}")
|
||||
return count
|
||||
|
||||
|
||||
def register_module_schemas(key, module, manifest=None):
|
||||
count = 0
|
||||
for name, schema in module_schemas(module):
|
||||
count += 1
|
||||
register_known_schema(key, name, schema)
|
||||
|
||||
if manifest and manifest.multi_conf and S_CONFIG_SCHEMA in output[key][S_SCHEMAS]:
|
||||
if (
|
||||
manifest
|
||||
and manifest.multi_conf
|
||||
and key in output
|
||||
and S_CONFIG_SCHEMA in output[key][S_SCHEMAS]
|
||||
):
|
||||
# Multi conf should allow list of components
|
||||
# not sure about 2nd part of the if, might be useless config (e.g. as3935)
|
||||
output[key][S_SCHEMAS][S_CONFIG_SCHEMA]["is_list"] = True
|
||||
return count
|
||||
|
||||
|
||||
def register_known_schema(module, name, schema):
|
||||
if module not in output:
|
||||
output[module] = {S_SCHEMAS: {}}
|
||||
config = convert_config(schema, f"{module}/{name}")
|
||||
if S_TYPE not in config:
|
||||
if S_TYPE not in config and name != "FINAL_VALIDATE_SCHEMA" and module != "core":
|
||||
print(f"Config var without type: {module}.{name}")
|
||||
|
||||
output[module][S_SCHEMAS][name] = config
|
||||
@@ -175,14 +190,23 @@ def module_schemas(module):
|
||||
except OSError:
|
||||
# some empty __init__ files
|
||||
module_str = ""
|
||||
schemas = {}
|
||||
schemas = []
|
||||
for m_attr_name in dir(module):
|
||||
m_attr_obj = getattr(module, m_attr_name)
|
||||
if is_convertible_schema(m_attr_obj):
|
||||
schemas[module_str.find(m_attr_name)] = [m_attr_name, m_attr_obj]
|
||||
# Find where the name is assigned in the module source to preserve
|
||||
# definition order. Using ^NAME\s*= (multiline) targets assignments
|
||||
# at column 0, so "CONFIG_SCHEMA" won't collide with "CONFIG_SCHEMA_BASE".
|
||||
match = re.search(
|
||||
r"^" + re.escape(m_attr_name) + r"\s*=",
|
||||
module_str,
|
||||
re.MULTILINE,
|
||||
)
|
||||
pos = match.start() if match else -1
|
||||
schemas.append((pos, m_attr_name, m_attr_obj))
|
||||
|
||||
for pos in sorted(schemas.keys()):
|
||||
yield schemas[pos]
|
||||
for _, name, obj in sorted(schemas, key=lambda x: x[0]):
|
||||
yield name, obj
|
||||
|
||||
|
||||
found_registries = {}
|
||||
@@ -240,9 +264,16 @@ def add_module_registries(domain, module):
|
||||
if len(parts) == 2:
|
||||
reg_domain = parts[0]
|
||||
reg_entry_name = parts[1]
|
||||
else:
|
||||
reg_domain = ".".join([parts[1], parts[0]])
|
||||
reg_entry_name = parts[2]
|
||||
elif len(parts) == 3:
|
||||
# is a platform or a component?
|
||||
if parts[0] in schema_core[S_PLATFORMS]:
|
||||
reg_domain = ".".join([parts[1], parts[0]])
|
||||
reg_entry_name = parts[2]
|
||||
elif parts[0] in schema_core[S_COMPONENTS]:
|
||||
reg_domain = parts[0]
|
||||
reg_entry_name = ".".join([parts[1], parts[2]])
|
||||
else:
|
||||
print(f"registry {name} is unknown")
|
||||
|
||||
if reg_domain not in output:
|
||||
output[reg_domain] = {}
|
||||
@@ -252,8 +283,6 @@ def add_module_registries(domain, module):
|
||||
attr_obj[name].schema, f"{reg_domain}/{reg_type}/{reg_entry_name}"
|
||||
)
|
||||
|
||||
# print(f"{domain} - {attr_name} - {name}")
|
||||
|
||||
|
||||
def do_pins():
|
||||
# do pin registries
|
||||
@@ -330,6 +359,35 @@ def fix_font():
|
||||
)
|
||||
|
||||
|
||||
def fix_globals():
|
||||
if "globals" not in output:
|
||||
return
|
||||
from esphome.components.globals import _NON_RESTORING_SCHEMA
|
||||
|
||||
config = convert_config(_NON_RESTORING_SCHEMA, "globals/CONFIG_SCHEMA")
|
||||
config["is_list"] = True
|
||||
output["globals"][S_SCHEMAS][S_CONFIG_SCHEMA] = config
|
||||
|
||||
|
||||
def fix_mapping():
|
||||
if "mapping" not in output:
|
||||
return
|
||||
from esphome.components.mapping import BASE_SCHEMA
|
||||
|
||||
config = convert_config(BASE_SCHEMA, "mapping/CONFIG_SCHEMA")
|
||||
output["mapping"][S_SCHEMAS][S_CONFIG_SCHEMA] = config
|
||||
|
||||
|
||||
def fix_image():
|
||||
if "image" not in output:
|
||||
return
|
||||
from esphome.components.image import IMAGE_SCHEMA
|
||||
|
||||
config = convert_config(IMAGE_SCHEMA, "image/CONFIG_SCHEMA")
|
||||
config["is_list"] = True
|
||||
output["image"][S_SCHEMAS][S_CONFIG_SCHEMA] = config
|
||||
|
||||
|
||||
def fix_menu():
|
||||
if "display_menu_base" not in output:
|
||||
return
|
||||
@@ -355,7 +413,7 @@ def fix_menu():
|
||||
# 4. Configure menu items inside as recursive
|
||||
menu = schemas["MENU_TYPES"][S_SCHEMA][S_CONFIG_VARS]["items"]["types"]["menu"]
|
||||
menu[S_CONFIG_VARS].pop("items")
|
||||
menu[S_EXTENDS] = ["display_menu_base.MENU_TYPES"]
|
||||
menu[S_EXTENDS].append("display_menu_base.MENU_TYPES")
|
||||
|
||||
|
||||
def get_logger_tags():
|
||||
@@ -531,7 +589,6 @@ def shrink():
|
||||
else:
|
||||
arr_s.pop(S_EXTENDS)
|
||||
arr_s |= key_s[S_SCHEMA]
|
||||
print(x)
|
||||
|
||||
# simple types should be spread on each component,
|
||||
# for enums so far these are logger.is_log_level, cover.validate_cover_state and pulse_counter.sensor.COUNT_MODE_SCHEMA
|
||||
@@ -580,6 +637,10 @@ def shrink():
|
||||
domain_schemas[S_SCHEMAS].pop(schema_name)
|
||||
|
||||
|
||||
def is_cv_invalid(schema):
|
||||
return repr(schema).startswith("<function invalid.<locals>.validator")
|
||||
|
||||
|
||||
def build_schema():
|
||||
print("Building schema")
|
||||
|
||||
@@ -610,7 +671,8 @@ def build_schema():
|
||||
output[domain] = {S_COMPONENTS: {}, S_SCHEMAS: {}}
|
||||
platforms[domain] = {}
|
||||
elif manifest.config_schema is not None:
|
||||
# e.g. dallas
|
||||
if is_cv_invalid(manifest.config_schema):
|
||||
continue
|
||||
output[domain] = {S_SCHEMAS: {S_CONFIG_SCHEMA: {}}}
|
||||
|
||||
# Generate platforms (e.g. sensor, binary_sensor, climate )
|
||||
@@ -621,7 +683,9 @@ def build_schema():
|
||||
# Generate components
|
||||
for domain, manifest in components.items():
|
||||
if domain not in platforms:
|
||||
if manifest.config_schema is not None:
|
||||
if manifest.config_schema is not None and not is_cv_invalid(
|
||||
manifest.config_schema
|
||||
):
|
||||
core_components[domain] = {}
|
||||
if len(manifest.dependencies) > 0:
|
||||
core_components[domain]["dependencies"] = manifest.dependencies
|
||||
@@ -630,14 +694,15 @@ def build_schema():
|
||||
for platform in platforms:
|
||||
platform_manifest = get_platform(domain=platform, platform=domain)
|
||||
if platform_manifest is not None:
|
||||
output[platform][S_COMPONENTS][domain] = {}
|
||||
if len(platform_manifest.dependencies) > 0:
|
||||
output[platform][S_COMPONENTS][domain]["dependencies"] = (
|
||||
platform_manifest.dependencies
|
||||
)
|
||||
register_module_schemas(
|
||||
count = register_module_schemas(
|
||||
f"{domain}.{platform}", platform_manifest.module, platform_manifest
|
||||
)
|
||||
if count > 0:
|
||||
output[platform][S_COMPONENTS].setdefault(domain, {})
|
||||
if len(platform_manifest.dependencies) > 0:
|
||||
output[platform][S_COMPONENTS][domain]["dependencies"] = (
|
||||
platform_manifest.dependencies
|
||||
)
|
||||
|
||||
# Do registries
|
||||
add_module_registries("core", automation)
|
||||
@@ -657,6 +722,9 @@ def build_schema():
|
||||
fix_remote_receiver()
|
||||
fix_script()
|
||||
fix_font()
|
||||
fix_globals()
|
||||
fix_mapping()
|
||||
fix_image()
|
||||
add_logger_tags()
|
||||
shrink()
|
||||
fix_menu()
|
||||
@@ -677,12 +745,19 @@ def build_schema():
|
||||
# bundle core inside esphome
|
||||
data["esphome"]["core"] = data.pop("core")["core"]
|
||||
|
||||
if GENERATED_ID_TYPES:
|
||||
print(
|
||||
"Unconsumed id_type matchers:",
|
||||
[id_type for _, id_type in GENERATED_ID_TYPES],
|
||||
)
|
||||
|
||||
if args.check: # do not gen files
|
||||
return
|
||||
|
||||
for c, s in data.items():
|
||||
write_file(c, s)
|
||||
delete_extra_files(data.keys())
|
||||
deleted = delete_extra_files(data.keys())
|
||||
print(f"Written {len(data.items())} deleted {deleted} files.")
|
||||
|
||||
|
||||
def is_convertible_schema(schema):
|
||||
@@ -711,6 +786,30 @@ def convert_config(schema, path):
|
||||
return converted
|
||||
|
||||
|
||||
GENERATED_ID_TYPES = [
|
||||
(
|
||||
lambda p: p.startswith("i2c/CONFIG_SCHEMA/") and p.endswith("/id"),
|
||||
{"class": "i2c::I2CBus", "parents": ["Component"]},
|
||||
),
|
||||
(
|
||||
lambda p: p == "uart/CONFIG_SCHEMA/val 1/ext0/all/id",
|
||||
{"class": "uart::UARTComponent", "parents": ["Component"]},
|
||||
),
|
||||
(
|
||||
lambda p: p == "http_request/CONFIG_SCHEMA/val 1/ext0/all/id",
|
||||
{"class": "http_request::HttpRequestComponent", "parents": ["Component"]},
|
||||
),
|
||||
(
|
||||
lambda p: (
|
||||
p
|
||||
== "uptime.sensor/CONFIG_SCHEMA/type_timestamp/ext0/ext1/all/time_id/val 1"
|
||||
),
|
||||
{},
|
||||
),
|
||||
(lambda p: p == "esp_ldo/action/voltage.adjust/all/all/id", {}),
|
||||
]
|
||||
|
||||
|
||||
def convert(schema, config_var, path):
|
||||
"""config_var can be a config_var or a schema: both are dicts
|
||||
config_var has a S_TYPE property, if this is S_SCHEMA, then it has a S_SCHEMA property
|
||||
@@ -718,9 +817,6 @@ def convert(schema, config_var, path):
|
||||
"""
|
||||
repr_schema = repr(schema)
|
||||
|
||||
if path.startswith("ads1115.sensor") and path.endswith("gain"):
|
||||
print(path)
|
||||
|
||||
if repr_schema in known_schemas:
|
||||
schema_info = known_schemas[(repr_schema)]
|
||||
for schema_instance, name in schema_info:
|
||||
@@ -841,8 +937,6 @@ def convert(schema, config_var, path):
|
||||
schema({"delay": "1s"})
|
||||
except cv.Invalid:
|
||||
config_var["has_required_var"] = True
|
||||
else:
|
||||
print("figure out " + path)
|
||||
elif schema_type == "effects":
|
||||
config_var[S_TYPE] = "registry"
|
||||
config_var["registry"] = "light.effects"
|
||||
@@ -879,8 +973,6 @@ def convert(schema, config_var, path):
|
||||
"id"
|
||||
]["id_type"]["class"]
|
||||
config_var[S_TYPE] = "use_id"
|
||||
else:
|
||||
print("TODO deferred?")
|
||||
elif isinstance(data, str):
|
||||
# TODO: Figure out why pipsolar does this
|
||||
config_var["use_id_type"] = data
|
||||
@@ -890,23 +982,11 @@ def convert(schema, config_var, path):
|
||||
else:
|
||||
raise TypeError("Unknown extracted schema type")
|
||||
elif config_var.get("key") == "GeneratedID":
|
||||
if path.startswith("i2c/CONFIG_SCHEMA/") and path.endswith("/id"):
|
||||
config_var["id_type"] = {
|
||||
"class": "i2c::I2CBus",
|
||||
"parents": ["Component"],
|
||||
}
|
||||
elif path == "uart/CONFIG_SCHEMA/val 1/ext0/all/id":
|
||||
config_var["id_type"] = {
|
||||
"class": "uart::UARTComponent",
|
||||
"parents": ["Component"],
|
||||
}
|
||||
elif path == "http_request/CONFIG_SCHEMA/val 1/ext0/all/id":
|
||||
config_var["id_type"] = {
|
||||
"class": "http_request::HttpRequestComponent",
|
||||
"parents": ["Component"],
|
||||
}
|
||||
elif path == "pins/esp32/val 1/id":
|
||||
config_var["id_type"] = "pin"
|
||||
for i, (matcher, id_type) in enumerate(GENERATED_ID_TYPES):
|
||||
if matcher(path):
|
||||
config_var["id_type"] = id_type
|
||||
GENERATED_ID_TYPES.pop(i)
|
||||
break
|
||||
else:
|
||||
print("Cannot determine id_type for " + path)
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<<: !include common.yaml
|
||||
@@ -288,7 +288,9 @@ lvgl:
|
||||
- label:
|
||||
text: "Hello shiny day"
|
||||
text_color: 0xFFFFFF
|
||||
align: bottom_mid
|
||||
align_to:
|
||||
id: hello_label
|
||||
align: OUT_LEFT_TOP
|
||||
- label:
|
||||
id: setup_lambda_label
|
||||
# Test lambda in widget property during setup (LvContext)
|
||||
|
||||
@@ -140,9 +140,28 @@ def test_register_component_source_overflow_warns(
|
||||
sources={f"comp_{i}": i + 1 for i in range(0xFF)},
|
||||
table_registered=True,
|
||||
)
|
||||
monkeypatch.setattr(ch, "CORE", Mock(data={ch._COMPONENT_SOURCE_DOMAIN: pool}))
|
||||
monkeypatch.setattr(
|
||||
ch, "CORE", Mock(data={ch._COMPONENT_SOURCE_DOMAIN: pool}, testing_mode=False)
|
||||
)
|
||||
with caplog.at_level(logging.WARNING):
|
||||
idx = register_component_source("overflow_component")
|
||||
assert idx == 0
|
||||
assert "Too many unique component source names" in caplog.text
|
||||
assert "overflow_component" in caplog.text
|
||||
|
||||
|
||||
def test_register_component_source_overflow_suppressed_in_testing_mode(
|
||||
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
# Pre-fill pool to max
|
||||
pool = ComponentSourcePool(
|
||||
sources={f"comp_{i}": i + 1 for i in range(0xFF)},
|
||||
table_registered=True,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
ch, "CORE", Mock(data={ch._COMPONENT_SOURCE_DOMAIN: pool}, testing_mode=True)
|
||||
)
|
||||
with caplog.at_level(logging.WARNING):
|
||||
idx = register_component_source("overflow_component")
|
||||
assert idx == 0
|
||||
assert "Too many unique component source names" not in caplog.text
|
||||
|
||||
Reference in New Issue
Block a user