Compare commits

..

140 Commits

Author SHA1 Message Date
J. Nick Koston
396005db62 preen 2025-06-07 05:24:58 -05:00
J. Nick Koston
c6f605ce96 preen 2025-06-07 05:20:17 -05:00
J. Nick Koston
da6520586c preen 2025-06-07 05:18:25 -05:00
J. Nick Koston
fd22033bda consist 2025-06-07 05:17:02 -05:00
J. Nick Koston
bb6586d365 make it easier to maintain 2025-06-07 05:12:03 -05:00
J. Nick Koston
552dbca56b Merge branch 'loop_runtime_stats' into send_overhead_stats 2025-06-06 22:59:46 -05:00
J. Nick Koston
0c04364525 fix flakey tests 2025-06-06 22:44:25 -05:00
J. Nick Koston
c4ebdd3875 fix flakey tests 2025-06-06 22:39:36 -05:00
J. Nick Koston
7f8b277ea4 fix flakey tests 2025-06-06 22:39:31 -05:00
J. Nick Koston
0261168b08 fix flakey tests 2025-06-06 22:39:29 -05:00
J. Nick Koston
0187820475 fix flakey tests 2025-06-06 22:34:22 -05:00
J. Nick Koston
3b226625c6 fix flakey tests 2025-06-06 22:34:13 -05:00
J. Nick Koston
af060b4692 cover 2025-06-06 22:26:10 -05:00
J. Nick Koston
32be69f7f2 cleanup 2025-06-06 22:06:29 -05:00
J. Nick Koston
a89c60cf10 integration tests 2025-06-06 21:56:16 -05:00
J. Nick Koston
2f230f32fa get rid of duplicate buffers 2025-06-06 21:14:05 -05:00
J. Nick Koston
4b50b51faf optimize 2025-06-06 20:36:37 -05:00
J. Nick Koston
fb92cbad59 document 2025-06-06 20:10:41 -05:00
J. Nick Koston
5c2f68dcb1 naming 2025-06-06 20:09:20 -05:00
J. Nick Koston
661fb1e74f fix refactoring error 2025-06-06 20:08:18 -05:00
J. Nick Koston
4ec0cf6edc tweaks 2025-06-06 20:04:42 -05:00
J. Nick Koston
a0b71b9930 cleanup 2025-06-06 19:17:08 -05:00
J. Nick Koston
6d11b80684 iov cleanup 2025-06-06 18:48:18 -05:00
J. Nick Koston
83dab69d6a fix size calc 2025-06-06 18:34:08 -05:00
J. Nick Koston
1f64cb446d tweaks 2025-06-06 23:03:57 +01:00
J. Nick Koston
d45a04df3f refactor to get rid of lambda 2025-06-06 22:48:07 +01:00
J. Nick Koston
b2bd0d2318 cleanup 2025-06-06 21:40:18 +01:00
J. Nick Koston
259e513293 Revert "get rid of lambdas except for event"
This reverts commit 1226e581ec.
2025-06-06 21:03:28 +01:00
J. Nick Koston
1226e581ec get rid of lambdas except for event 2025-06-06 21:00:53 +01:00
J. Nick Koston
3271f74b1b c++11 2025-06-06 19:32:55 +01:00
J. Nick Koston
efe3ffe1da remove unused timestamp 2025-06-06 19:28:36 +01:00
J. Nick Koston
051aee5228 fix 2025-06-06 13:24:42 +01:00
J. Nick Koston
b62de22175 batch ListEntitiesDone 2025-06-06 13:23:11 +01:00
J. Nick Koston
7cf06eb0d5 tweaks 2025-06-06 13:13:16 +01:00
J. Nick Koston
add7593b4a 8266 2025-06-06 12:44:02 +01:00
J. Nick Koston
858ea16f91 8266 2025-06-06 12:41:25 +01:00
J. Nick Koston
160e2593cd 8266 2025-06-06 12:38:09 +01:00
J. Nick Koston
5794472828 remove debug from testing 2025-06-06 12:35:52 +01:00
J. Nick Koston
c85f7adbb6 fix footer calc 2025-06-06 12:27:41 +01:00
J. Nick Koston
9a5ddb9619 optimize 2025-06-06 12:10:40 +01:00
J. Nick Koston
a6f75ce357 optimize 2025-06-06 12:04:50 +01:00
J. Nick Koston
a89aaaf69a fixes 2025-06-06 11:56:44 +01:00
J. Nick Koston
0f3db32b46 optimize 2025-06-06 11:32:48 +01:00
J. Nick Koston
684c5a42fb lint 2025-06-06 10:40:33 +01:00
J. Nick Koston
b4198e6592 fixes 2025-06-06 10:30:32 +01:00
J. Nick Koston
b335f628e7 fixes 2025-06-06 10:29:07 +01:00
J. Nick Koston
8b12096c6a preen 2025-06-06 09:54:55 +01:00
J. Nick Koston
15b7481c4a preen 2025-06-06 09:54:44 +01:00
J. Nick Koston
bec1aa9a10 preen 2025-06-06 09:54:15 +01:00
J. Nick Koston
30ae1c860a preen 2025-06-06 09:49:40 +01:00
J. Nick Koston
413a6db11c preen 2025-06-06 09:49:25 +01:00
J. Nick Koston
fa918b4129 preen 2025-06-06 08:26:47 +01:00
J. Nick Koston
f362e1c72e preen 2025-06-06 08:25:12 +01:00
J. Nick Koston
759a92a87a preen 2025-06-06 08:19:54 +01:00
J. Nick Koston
f4adf70228 preen 2025-06-06 08:17:17 +01:00
J. Nick Koston
bad165c804 fix gen 2025-06-06 08:14:03 +01:00
J. Nick Koston
c541955298 tweak 2025-06-06 07:49:51 +01:00
J. Nick Koston
c9de67208c tweak 2025-06-06 07:43:03 +01:00
J. Nick Koston
d732cb6339 tweak 2025-06-06 07:38:22 +01:00
J. Nick Koston
ecb508ad46 tweak 2025-06-06 07:38:05 +01:00
J. Nick Koston
60ff1f6564 remove broken code 2025-06-06 07:32:44 +01:00
J. Nick Koston
a44af63baf remove broken code 2025-06-06 07:30:20 +01:00
J. Nick Koston
88414a6144 remove broken code 2025-06-06 07:28:56 +01:00
J. Nick Koston
7902382742 remove broken code 2025-06-06 07:26:11 +01:00
J. Nick Koston
3244aeba06 remove broken code 2025-06-06 07:25:01 +01:00
J. Nick Koston
fb1bc3d627 remove broken code 2025-06-06 07:24:09 +01:00
J. Nick Koston
1785fa181c remove broken code 2025-06-06 07:20:58 +01:00
J. Nick Koston
1a8a3c16e8 remove broken code 2025-06-06 07:19:55 +01:00
J. Nick Koston
856cdd47c1 remove broken code 2025-06-06 07:19:03 +01:00
J. Nick Koston
2a7f657a76 remove broken code 2025-06-06 07:17:56 +01:00
J. Nick Koston
e771b13fa5 remove broken code 2025-06-06 07:15:33 +01:00
J. Nick Koston
4091f39355 reverts 2025-06-06 07:13:36 +01:00
J. Nick Koston
d6106f9832 reverts 2025-06-06 07:13:11 +01:00
J. Nick Koston
8988234ae5 reverts 2025-06-06 07:12:35 +01:00
J. Nick Koston
de907e238d tweak 2025-06-06 07:08:19 +01:00
J. Nick Koston
9fcd6cbb4b preen 2025-06-06 07:06:16 +01:00
J. Nick Koston
2d80759c17 fixes 2025-06-06 06:13:03 +01:00
J. Nick Koston
ffa2cbeb3f fixes 2025-06-06 06:10:50 +01:00
J. Nick Koston
5ef8968149 preen 2025-06-06 06:04:08 +01:00
J. Nick Koston
efacf2110b preen 2025-06-06 06:03:59 +01:00
J. Nick Koston
f8fc6d66e3 preen 2025-06-06 06:02:27 +01:00
J. Nick Koston
5390a17298 reduce 2025-06-06 05:51:05 +01:00
J. Nick Koston
04757766a4 cleanup 2025-06-06 05:20:09 +01:00
J. Nick Koston
7c637d7ff5 adj 2025-06-06 03:44:43 +01:00
J. Nick Koston
6c913fa0c2 adj 2025-06-06 03:42:45 +01:00
J. Nick Koston
f70b826507 adj 2025-06-06 03:40:42 +01:00
J. Nick Koston
020c4af218 adj 2025-06-06 03:37:08 +01:00
J. Nick Koston
44062ea7f2 adj 2025-06-06 03:07:48 +01:00
J. Nick Koston
d87eeea439 adj 2025-06-06 03:07:07 +01:00
J. Nick Koston
71125a1137 adj 2025-06-06 03:04:00 +01:00
J. Nick Koston
7fa779be4e remove batch 2025-06-06 02:43:31 +01:00
J. Nick Koston
c90fe742b7 remove batch 2025-06-06 02:13:22 +01:00
J. Nick Koston
707346b6de remove batch 2025-06-06 02:12:04 +01:00
J. Nick Koston
fbb519140d remove batch 2025-06-06 02:11:25 +01:00
J. Nick Koston
f77544c9b5 remove batch 2025-06-06 02:10:50 +01:00
J. Nick Koston
f5611bccb6 remove batch 2025-06-06 01:49:52 +01:00
J. Nick Koston
431316cd2f remove batch 2025-06-06 01:42:10 +01:00
J. Nick Koston
da3d51f159 remove batch 2025-06-06 01:39:35 +01:00
J. Nick Koston
ce98cec9e7 remove batch 2025-06-06 01:34:44 +01:00
J. Nick Koston
e01e8302f3 remove batch 2025-06-06 01:29:51 +01:00
J. Nick Koston
782a46b777 remove batch 2025-06-06 01:23:27 +01:00
J. Nick Koston
a6dd079059 remove batch 2025-06-06 01:22:58 +01:00
J. Nick Koston
12778d28c4 remove batch 2025-06-06 01:22:44 +01:00
J. Nick Koston
411ba5f288 remove batch 2025-06-06 01:21:31 +01:00
J. Nick Koston
19dba53f07 remove batch 2025-06-06 01:20:18 +01:00
J. Nick Koston
4a85abd18f remove batch 2025-06-06 01:19:42 +01:00
J. Nick Koston
afc2dd77f0 remove batch 2025-06-06 01:19:02 +01:00
J. Nick Koston
1e3a6d121f remove batch 2025-06-06 01:15:49 +01:00
J. Nick Koston
de2176de20 remove batch 2025-06-06 01:11:25 +01:00
J. Nick Koston
c4319a8b39 remove batch 2025-06-06 01:00:57 +01:00
J. Nick Koston
e7d8501ca9 remove batch 2025-06-06 00:54:33 +01:00
J. Nick Koston
a486e92507 remove batch 2025-06-06 00:52:50 +01:00
J. Nick Koston
e4df8a70ef remove batch 2025-06-05 23:59:22 +01:00
J. Nick Koston
7cc2d059bc remove batch 2025-06-05 23:55:08 +01:00
J. Nick Koston
8c709179ce remove batch 2025-06-05 23:49:46 +01:00
J. Nick Koston
1dec3ebd3b remove batch 2025-06-05 23:47:42 +01:00
J. Nick Koston
1aad0f9b88 remove batch 2025-06-05 23:44:44 +01:00
J. Nick Koston
9902759068 remove batch 2025-06-05 23:38:10 +01:00
J. Nick Koston
84f4613ee0 tweak 2025-06-05 23:33:51 +01:00
J. Nick Koston
fdb33a893f tweak 2025-06-05 23:33:41 +01:00
J. Nick Koston
7b2e9fa7d9 tweak 2025-06-05 23:12:08 +01:00
J. Nick Koston
847ba64245 tweak 2025-06-05 23:09:45 +01:00
J. Nick Koston
4777d6b374 tweak 2025-06-05 23:08:50 +01:00
J. Nick Koston
e1c17ecac3 tweak 2025-06-05 23:07:45 +01:00
J. Nick Koston
6daca23225 tweak 2025-06-05 23:06:42 +01:00
J. Nick Koston
aa2b49178d tweak 2025-06-05 22:37:55 +01:00
J. Nick Koston
aa2f0e8ff9 tweak 2025-06-05 22:32:40 +01:00
J. Nick Koston
a4d3849ef4 avoid template func to save 3k 2025-06-05 21:56:03 +01:00
J. Nick Koston
0ff647909d fix 2025-06-05 21:40:25 +01:00
J. Nick Koston
27204e0598 fix 2025-06-05 18:12:14 +01:00
J. Nick Koston
24b2fe8375 fix 2025-06-05 18:10:55 +01:00
J. Nick Koston
50310fe494 batch 2025-06-05 17:54:03 +01:00
J. Nick Koston
99e98f5655 batch 2025-06-05 17:50:02 +01:00
J. Nick Koston
14f147fd1c batch 2025-06-05 17:47:28 +01:00
J. Nick Koston
6d982e76fe batch 2025-06-05 17:46:32 +01:00
J. Nick Koston
60dcb64da1 batch 2025-06-05 17:39:10 +01:00
J. Nick Koston
2bb7a1a9db batch 2025-06-05 17:38:41 +01:00
J. Nick Koston
29ec9da864 batch 2025-06-05 17:37:29 +01:00
J. Nick Koston
127f2a699a batch 2025-06-05 17:27:05 +01:00
J. Nick Koston
1b7e1afd9b batch state sends 2025-06-05 16:50:27 +01:00
489 changed files with 3118 additions and 5645 deletions

View File

@@ -150,7 +150,6 @@ esphome/components/esp32_improv/* @jesserockz
esphome/components/esp32_rmt/* @jesserockz esphome/components/esp32_rmt/* @jesserockz
esphome/components/esp32_rmt_led_strip/* @jesserockz esphome/components/esp32_rmt_led_strip/* @jesserockz
esphome/components/esp8266/* @esphome/core esphome/components/esp8266/* @esphome/core
esphome/components/esp_ldo/* @clydebarrow
esphome/components/ethernet_info/* @gtjadsonsantos esphome/components/ethernet_info/* @gtjadsonsantos
esphome/components/event/* @nohat esphome/components/event/* @nohat
esphome/components/event_emitter/* @Rapsssito esphome/components/event_emitter/* @Rapsssito
@@ -322,7 +321,6 @@ esphome/components/number/* @esphome/core
esphome/components/one_wire/* @ssieb esphome/components/one_wire/* @ssieb
esphome/components/online_image/* @clydebarrow @guillempages esphome/components/online_image/* @clydebarrow @guillempages
esphome/components/opentherm/* @olegtarasov esphome/components/opentherm/* @olegtarasov
esphome/components/openthread/* @mrene
esphome/components/ota/* @esphome/core esphome/components/ota/* @esphome/core
esphome/components/output/* @esphome/core esphome/components/output/* @esphome/core
esphome/components/packet_transport/* @clydebarrow esphome/components/packet_transport/* @clydebarrow

View File

@@ -48,7 +48,7 @@ PROJECT_NAME = ESPHome
# could be handy for archiving the generated documentation or if some version # could be handy for archiving the generated documentation or if some version
# control system is used. # control system is used.
PROJECT_NUMBER = 2025.7.0-dev PROJECT_NUMBER = 2025.6.0-dev
# Using the PROJECT_BRIEF tag one can provide an optional one line description # Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a # for a project that appears at the top of each page and should give viewer a

View File

@@ -134,7 +134,6 @@ def get_port_type(port):
def run_miniterm(config, port, args): def run_miniterm(config, port, args):
from aioesphomeapi import LogParser
import serial import serial
from esphome import platformio_api from esphome import platformio_api
@@ -159,7 +158,6 @@ def run_miniterm(config, port, args):
ser.dtr = False ser.dtr = False
ser.rts = False ser.rts = False
parser = LogParser()
tries = 0 tries = 0
while tries < 5: while tries < 5:
try: try:
@@ -176,7 +174,8 @@ def run_miniterm(config, port, args):
.decode("utf8", "backslashreplace") .decode("utf8", "backslashreplace")
) )
time_str = datetime.now().time().strftime("[%H:%M:%S]") time_str = datetime.now().time().strftime("[%H:%M:%S]")
safe_print(parser.parse_line(line, time_str)) message = time_str + line
safe_print(message)
backtrace_state = platformio_api.process_stacktrace( backtrace_state = platformio_api.process_stacktrace(
config, line, backtrace_state=backtrace_state config, line, backtrace_state=backtrace_state

View File

@@ -40,11 +40,9 @@ void AbsoluteHumidityComponent::dump_config() {
break; break;
} }
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, "Sources");
"Sources\n" ESP_LOGCONFIG(TAG, " Temperature: '%s'", this->temperature_sensor_->get_name().c_str());
" Temperature: '%s'\n" ESP_LOGCONFIG(TAG, " Relative Humidity: '%s'", this->humidity_sensor_->get_name().c_str());
" Relative Humidity: '%s'",
this->temperature_sensor_->get_name().c_str(), this->humidity_sensor_->get_name().c_str());
} }
float AbsoluteHumidityComponent::get_setup_priority() const { return setup_priority::DATA; } float AbsoluteHumidityComponent::get_setup_priority() const { return setup_priority::DATA; }

View File

@@ -214,10 +214,8 @@ void AcDimmer::dump_config() {
ESP_LOGCONFIG(TAG, "AcDimmer:"); ESP_LOGCONFIG(TAG, "AcDimmer:");
LOG_PIN(" Output Pin: ", this->gate_pin_); LOG_PIN(" Output Pin: ", this->gate_pin_);
LOG_PIN(" Zero-Cross Pin: ", this->zero_cross_pin_); LOG_PIN(" Zero-Cross Pin: ", this->zero_cross_pin_);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Min Power: %.1f%%", this->store_.min_power / 10.0f);
" Min Power: %.1f%%\n" ESP_LOGCONFIG(TAG, " Init with half cycle: %s", YESNO(this->init_with_half_cycle_));
" Init with half cycle: %s",
this->store_.min_power / 10.0f, YESNO(this->init_with_half_cycle_));
if (method_ == DIM_METHOD_LEADING_PULSE) { if (method_ == DIM_METHOD_LEADING_PULSE) {
ESP_LOGCONFIG(TAG, " Method: leading pulse"); ESP_LOGCONFIG(TAG, " Method: leading pulse");
} else if (method_ == DIM_METHOD_LEADING) { } else if (method_ == DIM_METHOD_LEADING) {

View File

@@ -77,10 +77,8 @@ void ADCSensor::dump_config() {
break; break;
} }
} }
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Samples: %i", this->sample_count_);
" Samples: %i\n" ESP_LOGCONFIG(TAG, " Sampling mode: %s", LOG_STR_ARG(sampling_mode_to_str(this->sampling_mode_)));
" Sampling mode: %s",
this->sample_count_, LOG_STR_ARG(sampling_mode_to_str(this->sampling_mode_)));
LOG_UPDATE_INTERVAL(this); LOG_UPDATE_INTERVAL(this);
} }

View File

@@ -30,10 +30,8 @@ void ADCSensor::dump_config() {
#else #else
LOG_PIN(" Pin: ", this->pin_); LOG_PIN(" Pin: ", this->pin_);
#endif // USE_ADC_SENSOR_VCC #endif // USE_ADC_SENSOR_VCC
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Samples: %i", this->sample_count_);
" Samples: %i\n" ESP_LOGCONFIG(TAG, " Sampling mode: %s", LOG_STR_ARG(sampling_mode_to_str(this->sampling_mode_)));
" Sampling mode: %s",
this->sample_count_, LOG_STR_ARG(sampling_mode_to_str(this->sampling_mode_)));
LOG_UPDATE_INTERVAL(this); LOG_UPDATE_INTERVAL(this);
} }

View File

@@ -22,10 +22,8 @@ void ADCSensor::dump_config() {
#else // USE_ADC_SENSOR_VCC #else // USE_ADC_SENSOR_VCC
LOG_PIN(" Pin: ", this->pin_); LOG_PIN(" Pin: ", this->pin_);
#endif // USE_ADC_SENSOR_VCC #endif // USE_ADC_SENSOR_VCC
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Samples: %i", this->sample_count_);
" Samples: %i\n" ESP_LOGCONFIG(TAG, " Sampling mode: %s", LOG_STR_ARG(sampling_mode_to_str(this->sampling_mode_)));
" Sampling mode: %s",
this->sample_count_, LOG_STR_ARG(sampling_mode_to_str(this->sampling_mode_)));
LOG_UPDATE_INTERVAL(this); LOG_UPDATE_INTERVAL(this);
} }

View File

@@ -33,10 +33,8 @@ void ADCSensor::dump_config() {
LOG_PIN(" Pin: ", this->pin_); LOG_PIN(" Pin: ", this->pin_);
#endif // USE_ADC_SENSOR_VCC #endif // USE_ADC_SENSOR_VCC
} }
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Samples: %i", this->sample_count_);
" Samples: %i\n" ESP_LOGCONFIG(TAG, " Sampling mode: %s", LOG_STR_ARG(sampling_mode_to_str(this->sampling_mode_)));
" Sampling mode: %s",
this->sample_count_, LOG_STR_ARG(sampling_mode_to_str(this->sampling_mode_)));
LOG_UPDATE_INTERVAL(this); LOG_UPDATE_INTERVAL(this);
} }

View File

@@ -177,14 +177,11 @@ void ADE7880::dump_config() {
LOG_SENSOR(" ", "Power Factor", this->channel_a_->power_factor); LOG_SENSOR(" ", "Power Factor", this->channel_a_->power_factor);
LOG_SENSOR(" ", "Forward Active Energy", this->channel_a_->forward_active_energy); LOG_SENSOR(" ", "Forward Active Energy", this->channel_a_->forward_active_energy);
LOG_SENSOR(" ", "Reverse Active Energy", this->channel_a_->reverse_active_energy); LOG_SENSOR(" ", "Reverse Active Energy", this->channel_a_->reverse_active_energy);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Calibration:");
" Calibration:\n" ESP_LOGCONFIG(TAG, " Current: %" PRId32, this->channel_a_->current_gain_calibration);
" Current: %" PRId32 "\n" ESP_LOGCONFIG(TAG, " Voltage: %" PRId32, this->channel_a_->voltage_gain_calibration);
" Voltage: %" PRId32 "\n" ESP_LOGCONFIG(TAG, " Power: %" PRId32, this->channel_a_->power_gain_calibration);
" Power: %" PRId32 "\n" ESP_LOGCONFIG(TAG, " Phase Angle: %u", this->channel_a_->phase_angle_calibration);
" Phase Angle: %u",
this->channel_a_->current_gain_calibration, this->channel_a_->voltage_gain_calibration,
this->channel_a_->power_gain_calibration, this->channel_a_->phase_angle_calibration);
} }
if (this->channel_b_ != nullptr) { if (this->channel_b_ != nullptr) {
@@ -196,14 +193,11 @@ void ADE7880::dump_config() {
LOG_SENSOR(" ", "Power Factor", this->channel_b_->power_factor); LOG_SENSOR(" ", "Power Factor", this->channel_b_->power_factor);
LOG_SENSOR(" ", "Forward Active Energy", this->channel_b_->forward_active_energy); LOG_SENSOR(" ", "Forward Active Energy", this->channel_b_->forward_active_energy);
LOG_SENSOR(" ", "Reverse Active Energy", this->channel_b_->reverse_active_energy); LOG_SENSOR(" ", "Reverse Active Energy", this->channel_b_->reverse_active_energy);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Calibration:");
" Calibration:\n" ESP_LOGCONFIG(TAG, " Current: %" PRId32, this->channel_b_->current_gain_calibration);
" Current: %" PRId32 "\n" ESP_LOGCONFIG(TAG, " Voltage: %" PRId32, this->channel_b_->voltage_gain_calibration);
" Voltage: %" PRId32 "\n" ESP_LOGCONFIG(TAG, " Power: %" PRId32, this->channel_b_->power_gain_calibration);
" Power: %" PRId32 "\n" ESP_LOGCONFIG(TAG, " Phase Angle: %u", this->channel_b_->phase_angle_calibration);
" Phase Angle: %u",
this->channel_b_->current_gain_calibration, this->channel_b_->voltage_gain_calibration,
this->channel_b_->power_gain_calibration, this->channel_b_->phase_angle_calibration);
} }
if (this->channel_c_ != nullptr) { if (this->channel_c_ != nullptr) {
@@ -215,23 +209,18 @@ void ADE7880::dump_config() {
LOG_SENSOR(" ", "Power Factor", this->channel_c_->power_factor); LOG_SENSOR(" ", "Power Factor", this->channel_c_->power_factor);
LOG_SENSOR(" ", "Forward Active Energy", this->channel_c_->forward_active_energy); LOG_SENSOR(" ", "Forward Active Energy", this->channel_c_->forward_active_energy);
LOG_SENSOR(" ", "Reverse Active Energy", this->channel_c_->reverse_active_energy); LOG_SENSOR(" ", "Reverse Active Energy", this->channel_c_->reverse_active_energy);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Calibration:");
" Calibration:\n" ESP_LOGCONFIG(TAG, " Current: %" PRId32, this->channel_c_->current_gain_calibration);
" Current: %" PRId32 "\n" ESP_LOGCONFIG(TAG, " Voltage: %" PRId32, this->channel_c_->voltage_gain_calibration);
" Voltage: %" PRId32 "\n" ESP_LOGCONFIG(TAG, " Power: %" PRId32, this->channel_c_->power_gain_calibration);
" Power: %" PRId32 "\n" ESP_LOGCONFIG(TAG, " Phase Angle: %u", this->channel_c_->phase_angle_calibration);
" Phase Angle: %u",
this->channel_c_->current_gain_calibration, this->channel_c_->voltage_gain_calibration,
this->channel_c_->power_gain_calibration, this->channel_c_->phase_angle_calibration);
} }
if (this->channel_n_ != nullptr) { if (this->channel_n_ != nullptr) {
ESP_LOGCONFIG(TAG, " Neutral:"); ESP_LOGCONFIG(TAG, " Neutral:");
LOG_SENSOR(" ", "Current", this->channel_n_->current); LOG_SENSOR(" ", "Current", this->channel_n_->current);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Calibration:");
" Calibration:\n" ESP_LOGCONFIG(TAG, " Current: %" PRId32, this->channel_n_->current_gain_calibration);
" Current: %" PRId32,
this->channel_n_->current_gain_calibration);
} }
LOG_I2C_DEVICE(this); LOG_I2C_DEVICE(this);

View File

@@ -58,18 +58,15 @@ void ADE7953::dump_config() {
LOG_SENSOR(" ", "Active Power B Sensor", this->active_power_b_sensor_); LOG_SENSOR(" ", "Active Power B Sensor", this->active_power_b_sensor_);
LOG_SENSOR(" ", "Rective Power A Sensor", this->reactive_power_a_sensor_); LOG_SENSOR(" ", "Rective Power A Sensor", this->reactive_power_a_sensor_);
LOG_SENSOR(" ", "Reactive Power B Sensor", this->reactive_power_b_sensor_); LOG_SENSOR(" ", "Reactive Power B Sensor", this->reactive_power_b_sensor_);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " USE_ACC_ENERGY_REGS: %d", this->use_acc_energy_regs_);
" USE_ACC_ENERGY_REGS: %d\n" ESP_LOGCONFIG(TAG, " PGA_V_8: 0x%X", pga_v_);
" PGA_V_8: 0x%X\n" ESP_LOGCONFIG(TAG, " PGA_IA_8: 0x%X", pga_ia_);
" PGA_IA_8: 0x%X\n" ESP_LOGCONFIG(TAG, " PGA_IB_8: 0x%X", pga_ib_);
" PGA_IB_8: 0x%X\n" ESP_LOGCONFIG(TAG, " VGAIN_32: 0x%08jX", (uintmax_t) vgain_);
" VGAIN_32: 0x%08jX\n" ESP_LOGCONFIG(TAG, " AIGAIN_32: 0x%08jX", (uintmax_t) aigain_);
" AIGAIN_32: 0x%08jX\n" ESP_LOGCONFIG(TAG, " BIGAIN_32: 0x%08jX", (uintmax_t) bigain_);
" BIGAIN_32: 0x%08jX\n" ESP_LOGCONFIG(TAG, " AWGAIN_32: 0x%08jX", (uintmax_t) awgain_);
" AWGAIN_32: 0x%08jX\n" ESP_LOGCONFIG(TAG, " BWGAIN_32: 0x%08jX", (uintmax_t) bwgain_);
" BWGAIN_32: 0x%08jX",
this->use_acc_energy_regs_, pga_v_, pga_ia_, pga_ib_, (uintmax_t) vgain_, (uintmax_t) aigain_,
(uintmax_t) bigain_, (uintmax_t) awgain_, (uintmax_t) bwgain_);
} }
#define ADE_PUBLISH_(name, val, factor) \ #define ADE_PUBLISH_(name, val, factor) \

View File

@@ -1,6 +1,6 @@
#include "ade7953_i2c.h" #include "ade7953_i2c.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/helpers.h"
namespace esphome { namespace esphome {
namespace ade7953_i2c { namespace ade7953_i2c {

View File

@@ -1,6 +1,6 @@
#include "ade7953_spi.h" #include "ade7953_spi.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/helpers.h"
namespace esphome { namespace esphome {
namespace ade7953_spi { namespace ade7953_spi {

View File

@@ -1,5 +1,4 @@
#include "ads1118.h" #include "ads1118.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
namespace esphome { namespace esphome {

View File

@@ -1,5 +1,4 @@
#include "ags10.h" #include "ags10.h"
#include "esphome/core/helpers.h"
#include <cinttypes> #include <cinttypes>

View File

@@ -13,9 +13,9 @@
// results making successive requests; the current implementation makes 3 attempts with a delay of 30ms each time. // results making successive requests; the current implementation makes 3 attempts with a delay of 30ms each time.
#include "aht10.h" #include "aht10.h"
#include "esphome/core/log.h"
#include "esphome/core/hal.h" #include "esphome/core/hal.h"
#include "esphome/core/helpers.h" #include "esphome/core/helpers.h"
#include "esphome/core/log.h"
namespace esphome { namespace esphome {
namespace aht10 { namespace aht10 {

View File

@@ -235,7 +235,6 @@ async def register_alarm_control_panel(var, config):
if not CORE.has_id(config[CONF_ID]): if not CORE.has_id(config[CONF_ID]):
var = cg.Pvariable(config[CONF_ID], var) var = cg.Pvariable(config[CONF_ID], var)
cg.add(cg.App.register_alarm_control_panel(var)) cg.add(cg.App.register_alarm_control_panel(var))
CORE.register_platform_component("alarm_control_panel", var)
await setup_alarm_control_panel_core_(var, config) await setup_alarm_control_panel_core_(var, config)

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/helpers.h"
namespace esphome { namespace esphome {
namespace am43 { namespace am43 {

View File

@@ -12,10 +12,8 @@ using namespace esphome::cover;
void Am43Component::dump_config() { void Am43Component::dump_config() {
LOG_COVER("", "AM43 Cover", this); LOG_COVER("", "AM43 Cover", this);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Device Pin: %d", this->pin_);
" Device Pin: %d\n" ESP_LOGCONFIG(TAG, " Invert Position: %d", (int) this->invert_position_);
" Invert Position: %d",
this->pin_, (int) this->invert_position_);
} }
void Am43Component::setup() { void Am43Component::setup() {

View File

@@ -34,10 +34,8 @@ void AnalogThresholdBinarySensor::set_sensor(sensor::Sensor *analog_sensor) {
void AnalogThresholdBinarySensor::dump_config() { void AnalogThresholdBinarySensor::dump_config() {
LOG_BINARY_SENSOR("", "Analog Threshold Binary Sensor", this); LOG_BINARY_SENSOR("", "Analog Threshold Binary Sensor", this);
LOG_SENSOR(" ", "Sensor", this->sensor_); LOG_SENSOR(" ", "Sensor", this->sensor_);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Upper threshold: %.11f", this->upper_threshold_.value());
" Upper threshold: %.11f\n" ESP_LOGCONFIG(TAG, " Lower threshold: %.11f", this->lower_threshold_.value());
" Lower threshold: %.11f",
this->upper_threshold_.value(), this->lower_threshold_.value());
} }
} // namespace analog_threshold } // namespace analog_threshold

View File

@@ -108,12 +108,9 @@ void APDS9306::dump_config() {
} }
} }
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Gain: %u", AMBIENT_LIGHT_GAIN_VALUES[this->gain_]);
" Gain: %u\n" ESP_LOGCONFIG(TAG, " Measurement rate: %u", MEASUREMENT_RATE_VALUES[this->measurement_rate_]);
" Measurement rate: %u\n" ESP_LOGCONFIG(TAG, " Measurement Resolution/Bit width: %d", MEASUREMENT_BIT_WIDTH_VALUES[this->bit_width_]);
" Measurement Resolution/Bit width: %d",
AMBIENT_LIGHT_GAIN_VALUES[this->gain_], MEASUREMENT_RATE_VALUES[this->measurement_rate_],
MEASUREMENT_BIT_WIDTH_VALUES[this->bit_width_]);
LOG_UPDATE_INTERVAL(this); LOG_UPDATE_INTERVAL(this);
} }

View File

@@ -239,8 +239,7 @@ DisconnectResponse APIConnection::disconnect(const DisconnectRequest &msg) {
return resp; return resp;
} }
void APIConnection::on_disconnect_response(const DisconnectResponse &value) { void APIConnection::on_disconnect_response(const DisconnectResponse &value) {
this->helper_->close(); // pass
this->remove_ = true;
} }
// Encodes a message to the buffer and returns the total number of bytes used, // Encodes a message to the buffer and returns the total number of bytes used,
@@ -270,6 +269,10 @@ uint16_t APIConnection::encode_message_to_buffer(ProtoMessage &msg, uint16_t mes
} }
#ifdef USE_BINARY_SENSOR #ifdef USE_BINARY_SENSOR
bool APIConnection::send_binary_sensor_state(binary_sensor::BinarySensor *binary_sensor, bool state) {
return this->schedule_message_(binary_sensor, MessageCreator(state, BinarySensorStateResponse::MESSAGE_TYPE),
BinarySensorStateResponse::MESSAGE_TYPE);
}
bool APIConnection::send_binary_sensor_state(binary_sensor::BinarySensor *binary_sensor) { bool APIConnection::send_binary_sensor_state(binary_sensor::BinarySensor *binary_sensor) {
return this->schedule_message_(binary_sensor, &APIConnection::try_send_binary_sensor_state, return this->schedule_message_(binary_sensor, &APIConnection::try_send_binary_sensor_state,
BinarySensorStateResponse::MESSAGE_TYPE); BinarySensorStateResponse::MESSAGE_TYPE);
@@ -278,15 +281,20 @@ void APIConnection::send_binary_sensor_info(binary_sensor::BinarySensor *binary_
this->schedule_message_(binary_sensor, &APIConnection::try_send_binary_sensor_info, this->schedule_message_(binary_sensor, &APIConnection::try_send_binary_sensor_info,
ListEntitiesBinarySensorResponse::MESSAGE_TYPE); ListEntitiesBinarySensorResponse::MESSAGE_TYPE);
} }
uint16_t APIConnection::try_send_binary_sensor_state_response(binary_sensor::BinarySensor *binary_sensor, bool state,
APIConnection *conn, uint32_t remaining_size,
bool is_single) {
BinarySensorStateResponse resp;
resp.state = state;
resp.missing_state = !binary_sensor->has_state();
resp.key = binary_sensor->get_object_id_hash();
return encode_message_to_buffer(resp, BinarySensorStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single);
}
uint16_t APIConnection::try_send_binary_sensor_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, uint16_t APIConnection::try_send_binary_sensor_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single) { bool is_single) {
auto *binary_sensor = static_cast<binary_sensor::BinarySensor *>(entity); auto *binary_sensor = static_cast<binary_sensor::BinarySensor *>(entity);
BinarySensorStateResponse resp; return try_send_binary_sensor_state_response(binary_sensor, binary_sensor->state, conn, remaining_size, is_single);
resp.state = binary_sensor->state;
resp.missing_state = !binary_sensor->has_state();
resp.key = binary_sensor->get_object_id_hash();
return encode_message_to_buffer(resp, BinarySensorStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single);
} }
uint16_t APIConnection::try_send_binary_sensor_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, uint16_t APIConnection::try_send_binary_sensor_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
@@ -523,21 +531,29 @@ void APIConnection::light_command(const LightCommandRequest &msg) {
#endif #endif
#ifdef USE_SENSOR #ifdef USE_SENSOR
bool APIConnection::send_sensor_state(sensor::Sensor *sensor, float state) {
return this->schedule_message_(sensor, MessageCreator(state, SensorStateResponse::MESSAGE_TYPE),
SensorStateResponse::MESSAGE_TYPE);
}
bool APIConnection::send_sensor_state(sensor::Sensor *sensor) { bool APIConnection::send_sensor_state(sensor::Sensor *sensor) {
return this->schedule_message_(sensor, &APIConnection::try_send_sensor_state, SensorStateResponse::MESSAGE_TYPE); return this->schedule_message_(sensor, &APIConnection::try_send_sensor_state, SensorStateResponse::MESSAGE_TYPE);
} }
void APIConnection::send_sensor_info(sensor::Sensor *sensor) { void APIConnection::send_sensor_info(sensor::Sensor *sensor) {
this->schedule_message_(sensor, &APIConnection::try_send_sensor_info, ListEntitiesSensorResponse::MESSAGE_TYPE); this->schedule_message_(sensor, &APIConnection::try_send_sensor_info, ListEntitiesSensorResponse::MESSAGE_TYPE);
} }
uint16_t APIConnection::try_send_sensor_state_response(sensor::Sensor *sensor, float state, APIConnection *conn,
uint32_t remaining_size, bool is_single) {
SensorStateResponse resp;
resp.state = state;
resp.missing_state = !sensor->has_state();
resp.key = sensor->get_object_id_hash();
return encode_message_to_buffer(resp, SensorStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single);
}
uint16_t APIConnection::try_send_sensor_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, uint16_t APIConnection::try_send_sensor_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single) { bool is_single) {
auto *sensor = static_cast<sensor::Sensor *>(entity); auto *sensor = static_cast<sensor::Sensor *>(entity);
SensorStateResponse resp; return try_send_sensor_state_response(sensor, sensor->state, conn, remaining_size, is_single);
resp.state = sensor->state;
resp.missing_state = !sensor->has_state();
resp.key = sensor->get_object_id_hash();
return encode_message_to_buffer(resp, SensorStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single);
} }
uint16_t APIConnection::try_send_sensor_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, uint16_t APIConnection::try_send_sensor_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
@@ -558,20 +574,28 @@ uint16_t APIConnection::try_send_sensor_info(EntityBase *entity, APIConnection *
#endif #endif
#ifdef USE_SWITCH #ifdef USE_SWITCH
bool APIConnection::send_switch_state(switch_::Switch *a_switch, bool state) {
return this->schedule_message_(a_switch, MessageCreator(state, SwitchStateResponse::MESSAGE_TYPE),
SwitchStateResponse::MESSAGE_TYPE);
}
bool APIConnection::send_switch_state(switch_::Switch *a_switch) { bool APIConnection::send_switch_state(switch_::Switch *a_switch) {
return this->schedule_message_(a_switch, &APIConnection::try_send_switch_state, SwitchStateResponse::MESSAGE_TYPE); return this->schedule_message_(a_switch, &APIConnection::try_send_switch_state, SwitchStateResponse::MESSAGE_TYPE);
} }
void APIConnection::send_switch_info(switch_::Switch *a_switch) { void APIConnection::send_switch_info(switch_::Switch *a_switch) {
this->schedule_message_(a_switch, &APIConnection::try_send_switch_info, ListEntitiesSwitchResponse::MESSAGE_TYPE); this->schedule_message_(a_switch, &APIConnection::try_send_switch_info, ListEntitiesSwitchResponse::MESSAGE_TYPE);
} }
uint16_t APIConnection::try_send_switch_state_response(switch_::Switch *a_switch, bool state, APIConnection *conn,
uint32_t remaining_size, bool is_single) {
SwitchStateResponse resp;
resp.state = state;
resp.key = a_switch->get_object_id_hash();
return encode_message_to_buffer(resp, SwitchStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single);
}
uint16_t APIConnection::try_send_switch_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, uint16_t APIConnection::try_send_switch_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single) { bool is_single) {
auto *a_switch = static_cast<switch_::Switch *>(entity); auto *a_switch = static_cast<switch_::Switch *>(entity);
SwitchStateResponse resp; return try_send_switch_state_response(a_switch, a_switch->state, conn, remaining_size, is_single);
resp.state = a_switch->state;
resp.key = a_switch->get_object_id_hash();
return encode_message_to_buffer(resp, SwitchStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single);
} }
uint16_t APIConnection::try_send_switch_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, uint16_t APIConnection::try_send_switch_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
@@ -598,6 +622,10 @@ void APIConnection::switch_command(const SwitchCommandRequest &msg) {
#endif #endif
#ifdef USE_TEXT_SENSOR #ifdef USE_TEXT_SENSOR
bool APIConnection::send_text_sensor_state(text_sensor::TextSensor *text_sensor, const std::string &state) {
return this->schedule_message_(text_sensor, MessageCreator(state, TextSensorStateResponse::MESSAGE_TYPE),
TextSensorStateResponse::MESSAGE_TYPE);
}
bool APIConnection::send_text_sensor_state(text_sensor::TextSensor *text_sensor) { bool APIConnection::send_text_sensor_state(text_sensor::TextSensor *text_sensor) {
return this->schedule_message_(text_sensor, &APIConnection::try_send_text_sensor_state, return this->schedule_message_(text_sensor, &APIConnection::try_send_text_sensor_state,
TextSensorStateResponse::MESSAGE_TYPE); TextSensorStateResponse::MESSAGE_TYPE);
@@ -606,15 +634,20 @@ void APIConnection::send_text_sensor_info(text_sensor::TextSensor *text_sensor)
this->schedule_message_(text_sensor, &APIConnection::try_send_text_sensor_info, this->schedule_message_(text_sensor, &APIConnection::try_send_text_sensor_info,
ListEntitiesTextSensorResponse::MESSAGE_TYPE); ListEntitiesTextSensorResponse::MESSAGE_TYPE);
} }
uint16_t APIConnection::try_send_text_sensor_state_response(text_sensor::TextSensor *text_sensor,
const std::string &state, APIConnection *conn,
uint32_t remaining_size, bool is_single) {
TextSensorStateResponse resp;
resp.state = state;
resp.missing_state = !text_sensor->has_state();
resp.key = text_sensor->get_object_id_hash();
return encode_message_to_buffer(resp, TextSensorStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single);
}
uint16_t APIConnection::try_send_text_sensor_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, uint16_t APIConnection::try_send_text_sensor_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single) { bool is_single) {
auto *text_sensor = static_cast<text_sensor::TextSensor *>(entity); auto *text_sensor = static_cast<text_sensor::TextSensor *>(entity);
TextSensorStateResponse resp; return try_send_text_sensor_state_response(text_sensor, text_sensor->get_state(), conn, remaining_size, is_single);
resp.state = text_sensor->state;
resp.missing_state = !text_sensor->has_state();
resp.key = text_sensor->get_object_id_hash();
return encode_message_to_buffer(resp, TextSensorStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single);
} }
uint16_t APIConnection::try_send_text_sensor_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, uint16_t APIConnection::try_send_text_sensor_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single) { bool is_single) {
@@ -733,21 +766,29 @@ void APIConnection::climate_command(const ClimateCommandRequest &msg) {
#endif #endif
#ifdef USE_NUMBER #ifdef USE_NUMBER
bool APIConnection::send_number_state(number::Number *number, float state) {
return this->schedule_message_(number, MessageCreator(state, NumberStateResponse::MESSAGE_TYPE),
NumberStateResponse::MESSAGE_TYPE);
}
bool APIConnection::send_number_state(number::Number *number) { bool APIConnection::send_number_state(number::Number *number) {
return this->schedule_message_(number, &APIConnection::try_send_number_state, NumberStateResponse::MESSAGE_TYPE); return this->schedule_message_(number, &APIConnection::try_send_number_state, NumberStateResponse::MESSAGE_TYPE);
} }
void APIConnection::send_number_info(number::Number *number) { void APIConnection::send_number_info(number::Number *number) {
this->schedule_message_(number, &APIConnection::try_send_number_info, ListEntitiesNumberResponse::MESSAGE_TYPE); this->schedule_message_(number, &APIConnection::try_send_number_info, ListEntitiesNumberResponse::MESSAGE_TYPE);
} }
uint16_t APIConnection::try_send_number_state_response(number::Number *number, float state, APIConnection *conn,
uint32_t remaining_size, bool is_single) {
NumberStateResponse resp;
resp.state = state;
resp.missing_state = !number->has_state();
resp.key = number->get_object_id_hash();
return encode_message_to_buffer(resp, NumberStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single);
}
uint16_t APIConnection::try_send_number_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, uint16_t APIConnection::try_send_number_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single) { bool is_single) {
auto *number = static_cast<number::Number *>(entity); auto *number = static_cast<number::Number *>(entity);
NumberStateResponse resp; return try_send_number_state_response(number, number->state, conn, remaining_size, is_single);
resp.state = number->state;
resp.missing_state = !number->has_state();
resp.key = number->get_object_id_hash();
return encode_message_to_buffer(resp, NumberStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single);
} }
uint16_t APIConnection::try_send_number_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, uint16_t APIConnection::try_send_number_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
@@ -889,21 +930,29 @@ void APIConnection::datetime_command(const DateTimeCommandRequest &msg) {
#endif #endif
#ifdef USE_TEXT #ifdef USE_TEXT
bool APIConnection::send_text_state(text::Text *text, const std::string &state) {
return this->schedule_message_(text, MessageCreator(state, TextStateResponse::MESSAGE_TYPE),
TextStateResponse::MESSAGE_TYPE);
}
bool APIConnection::send_text_state(text::Text *text) { bool APIConnection::send_text_state(text::Text *text) {
return this->schedule_message_(text, &APIConnection::try_send_text_state, TextStateResponse::MESSAGE_TYPE); return this->schedule_message_(text, &APIConnection::try_send_text_state, TextStateResponse::MESSAGE_TYPE);
} }
void APIConnection::send_text_info(text::Text *text) { void APIConnection::send_text_info(text::Text *text) {
this->schedule_message_(text, &APIConnection::try_send_text_info, ListEntitiesTextResponse::MESSAGE_TYPE); this->schedule_message_(text, &APIConnection::try_send_text_info, ListEntitiesTextResponse::MESSAGE_TYPE);
} }
uint16_t APIConnection::try_send_text_state_response(text::Text *text, const std::string &state, APIConnection *conn,
uint32_t remaining_size, bool is_single) {
TextStateResponse resp;
resp.state = state;
resp.missing_state = !text->has_state();
resp.key = text->get_object_id_hash();
return encode_message_to_buffer(resp, TextStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single);
}
uint16_t APIConnection::try_send_text_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, uint16_t APIConnection::try_send_text_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single) { bool is_single) {
auto *text = static_cast<text::Text *>(entity); auto *text = static_cast<text::Text *>(entity);
TextStateResponse resp; return try_send_text_state_response(text, text->state, conn, remaining_size, is_single);
resp.state = text->state;
resp.missing_state = !text->has_state();
resp.key = text->get_object_id_hash();
return encode_message_to_buffer(resp, TextStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single);
} }
uint16_t APIConnection::try_send_text_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, uint16_t APIConnection::try_send_text_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
@@ -930,21 +979,29 @@ void APIConnection::text_command(const TextCommandRequest &msg) {
#endif #endif
#ifdef USE_SELECT #ifdef USE_SELECT
bool APIConnection::send_select_state(select::Select *select, const std::string &state) {
return this->schedule_message_(select, MessageCreator(state, SelectStateResponse::MESSAGE_TYPE),
SelectStateResponse::MESSAGE_TYPE);
}
bool APIConnection::send_select_state(select::Select *select) { bool APIConnection::send_select_state(select::Select *select) {
return this->schedule_message_(select, &APIConnection::try_send_select_state, SelectStateResponse::MESSAGE_TYPE); return this->schedule_message_(select, &APIConnection::try_send_select_state, SelectStateResponse::MESSAGE_TYPE);
} }
void APIConnection::send_select_info(select::Select *select) { void APIConnection::send_select_info(select::Select *select) {
this->schedule_message_(select, &APIConnection::try_send_select_info, ListEntitiesSelectResponse::MESSAGE_TYPE); this->schedule_message_(select, &APIConnection::try_send_select_info, ListEntitiesSelectResponse::MESSAGE_TYPE);
} }
uint16_t APIConnection::try_send_select_state_response(select::Select *select, const std::string &state,
APIConnection *conn, uint32_t remaining_size, bool is_single) {
SelectStateResponse resp;
resp.state = state;
resp.missing_state = !select->has_state();
resp.key = select->get_object_id_hash();
return encode_message_to_buffer(resp, SelectStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single);
}
uint16_t APIConnection::try_send_select_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, uint16_t APIConnection::try_send_select_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single) { bool is_single) {
auto *select = static_cast<select::Select *>(entity); auto *select = static_cast<select::Select *>(entity);
SelectStateResponse resp; return try_send_select_state_response(select, select->state, conn, remaining_size, is_single);
resp.state = select->state;
resp.missing_state = !select->has_state();
resp.key = select->get_object_id_hash();
return encode_message_to_buffer(resp, SelectStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single);
} }
uint16_t APIConnection::try_send_select_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, uint16_t APIConnection::try_send_select_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
@@ -991,20 +1048,28 @@ void esphome::api::APIConnection::button_command(const ButtonCommandRequest &msg
#endif #endif
#ifdef USE_LOCK #ifdef USE_LOCK
bool APIConnection::send_lock_state(lock::Lock *a_lock, lock::LockState state) {
return this->schedule_message_(a_lock, MessageCreator(state, LockStateResponse::MESSAGE_TYPE),
LockStateResponse::MESSAGE_TYPE);
}
bool APIConnection::send_lock_state(lock::Lock *a_lock) { bool APIConnection::send_lock_state(lock::Lock *a_lock) {
return this->schedule_message_(a_lock, &APIConnection::try_send_lock_state, LockStateResponse::MESSAGE_TYPE); return this->schedule_message_(a_lock, &APIConnection::try_send_lock_state, LockStateResponse::MESSAGE_TYPE);
} }
void APIConnection::send_lock_info(lock::Lock *a_lock) { void APIConnection::send_lock_info(lock::Lock *a_lock) {
this->schedule_message_(a_lock, &APIConnection::try_send_lock_info, ListEntitiesLockResponse::MESSAGE_TYPE); this->schedule_message_(a_lock, &APIConnection::try_send_lock_info, ListEntitiesLockResponse::MESSAGE_TYPE);
} }
uint16_t APIConnection::try_send_lock_state_response(lock::Lock *a_lock, lock::LockState state, APIConnection *conn,
uint32_t remaining_size, bool is_single) {
LockStateResponse resp;
resp.state = static_cast<enums::LockState>(state);
resp.key = a_lock->get_object_id_hash();
return encode_message_to_buffer(resp, LockStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single);
}
uint16_t APIConnection::try_send_lock_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, uint16_t APIConnection::try_send_lock_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single) { bool is_single) {
auto *a_lock = static_cast<lock::Lock *>(entity); auto *a_lock = static_cast<lock::Lock *>(entity);
LockStateResponse resp; return try_send_lock_state_response(a_lock, a_lock->state, conn, remaining_size, is_single);
resp.state = static_cast<enums::LockState>(a_lock->state);
resp.key = a_lock->get_object_id_hash();
return encode_message_to_buffer(resp, LockStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single);
} }
uint16_t APIConnection::try_send_lock_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, uint16_t APIConnection::try_send_lock_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
@@ -1867,6 +1932,63 @@ uint16_t APIConnection::MessageCreator::operator()(EntityBase *entity, APIConnec
case 0: // Function pointer case 0: // Function pointer
return data_.ptr(entity, conn, remaining_size, is_single); return data_.ptr(entity, conn, remaining_size, is_single);
#ifdef USE_BINARY_SENSOR
case BinarySensorStateResponse::MESSAGE_TYPE: {
auto *bs = static_cast<binary_sensor::BinarySensor *>(entity);
return APIConnection::try_send_binary_sensor_state_response(bs, data_.bool_value, conn, remaining_size,
is_single);
}
#endif
#ifdef USE_SENSOR
case SensorStateResponse::MESSAGE_TYPE: {
auto *s = static_cast<sensor::Sensor *>(entity);
return APIConnection::try_send_sensor_state_response(s, data_.float_value, conn, remaining_size, is_single);
}
#endif
#ifdef USE_SWITCH
case SwitchStateResponse::MESSAGE_TYPE: {
auto *sw = static_cast<switch_::Switch *>(entity);
return APIConnection::try_send_switch_state_response(sw, data_.bool_value, conn, remaining_size, is_single);
}
#endif
#ifdef USE_TEXT_SENSOR
case TextSensorStateResponse::MESSAGE_TYPE: {
auto *ts = static_cast<text_sensor::TextSensor *>(entity);
return APIConnection::try_send_text_sensor_state_response(ts, *data_.string_ptr, conn, remaining_size, is_single);
}
#endif
#ifdef USE_SELECT
case SelectStateResponse::MESSAGE_TYPE: {
auto *s = static_cast<select::Select *>(entity);
return APIConnection::try_send_select_state_response(s, *data_.string_ptr, conn, remaining_size, is_single);
}
#endif
#ifdef USE_NUMBER
case NumberStateResponse::MESSAGE_TYPE: {
auto *n = static_cast<number::Number *>(entity);
return APIConnection::try_send_number_state_response(n, data_.float_value, conn, remaining_size, is_single);
}
#endif
#ifdef USE_TEXT
case TextStateResponse::MESSAGE_TYPE: {
auto *t = static_cast<text::Text *>(entity);
return APIConnection::try_send_text_state_response(t, *data_.string_ptr, conn, remaining_size, is_single);
}
#endif
#ifdef USE_LOCK
case LockStateResponse::MESSAGE_TYPE: {
auto *l = static_cast<lock::Lock *>(entity);
return APIConnection::try_send_lock_state_response(l, data_.lock_value, conn, remaining_size, is_single);
}
#endif
#ifdef USE_EVENT #ifdef USE_EVENT
case EventResponse::MESSAGE_TYPE: { case EventResponse::MESSAGE_TYPE: {
auto *e = static_cast<event::Event *>(entity); auto *e = static_cast<event::Event *>(entity);
@@ -1886,12 +2008,6 @@ uint16_t APIConnection::try_send_list_info_done(EntityBase *entity, APIConnectio
return encode_message_to_buffer(resp, ListEntitiesDoneResponse::MESSAGE_TYPE, conn, remaining_size, is_single); return encode_message_to_buffer(resp, ListEntitiesDoneResponse::MESSAGE_TYPE, conn, remaining_size, is_single);
} }
uint16_t APIConnection::try_send_disconnect_request(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single) {
DisconnectRequest req;
return encode_message_to_buffer(req, DisconnectRequest::MESSAGE_TYPE, conn, remaining_size, is_single);
}
uint16_t APIConnection::get_estimated_message_size(uint16_t message_type) { uint16_t APIConnection::get_estimated_message_size(uint16_t message_type) {
// Use generated ESTIMATED_SIZE constants from each message type // Use generated ESTIMATED_SIZE constants from each message type
switch (message_type) { switch (message_type) {
@@ -2027,8 +2143,6 @@ uint16_t APIConnection::get_estimated_message_size(uint16_t message_type) {
return ListEntitiesServicesResponse::ESTIMATED_SIZE; return ListEntitiesServicesResponse::ESTIMATED_SIZE;
case ListEntitiesDoneResponse::MESSAGE_TYPE: case ListEntitiesDoneResponse::MESSAGE_TYPE:
return ListEntitiesDoneResponse::ESTIMATED_SIZE; return ListEntitiesDoneResponse::ESTIMATED_SIZE;
case DisconnectRequest::MESSAGE_TYPE:
return DisconnectRequest::ESTIMATED_SIZE;
default: default:
// Fallback for unknown message types // Fallback for unknown message types
return 24; return 24;

View File

@@ -33,6 +33,7 @@ class APIConnection : public APIServerConnection {
ListEntitiesDoneResponse::MESSAGE_TYPE); ListEntitiesDoneResponse::MESSAGE_TYPE);
} }
#ifdef USE_BINARY_SENSOR #ifdef USE_BINARY_SENSOR
bool send_binary_sensor_state(binary_sensor::BinarySensor *binary_sensor, bool state);
bool send_binary_sensor_state(binary_sensor::BinarySensor *binary_sensor); bool send_binary_sensor_state(binary_sensor::BinarySensor *binary_sensor);
void send_binary_sensor_info(binary_sensor::BinarySensor *binary_sensor); void send_binary_sensor_info(binary_sensor::BinarySensor *binary_sensor);
#endif #endif
@@ -52,15 +53,18 @@ class APIConnection : public APIServerConnection {
void light_command(const LightCommandRequest &msg) override; void light_command(const LightCommandRequest &msg) override;
#endif #endif
#ifdef USE_SENSOR #ifdef USE_SENSOR
bool send_sensor_state(sensor::Sensor *sensor, float state);
bool send_sensor_state(sensor::Sensor *sensor); bool send_sensor_state(sensor::Sensor *sensor);
void send_sensor_info(sensor::Sensor *sensor); void send_sensor_info(sensor::Sensor *sensor);
#endif #endif
#ifdef USE_SWITCH #ifdef USE_SWITCH
bool send_switch_state(switch_::Switch *a_switch, bool state);
bool send_switch_state(switch_::Switch *a_switch); bool send_switch_state(switch_::Switch *a_switch);
void send_switch_info(switch_::Switch *a_switch); void send_switch_info(switch_::Switch *a_switch);
void switch_command(const SwitchCommandRequest &msg) override; void switch_command(const SwitchCommandRequest &msg) override;
#endif #endif
#ifdef USE_TEXT_SENSOR #ifdef USE_TEXT_SENSOR
bool send_text_sensor_state(text_sensor::TextSensor *text_sensor, const std::string &state);
bool send_text_sensor_state(text_sensor::TextSensor *text_sensor); bool send_text_sensor_state(text_sensor::TextSensor *text_sensor);
void send_text_sensor_info(text_sensor::TextSensor *text_sensor); void send_text_sensor_info(text_sensor::TextSensor *text_sensor);
#endif #endif
@@ -75,6 +79,7 @@ class APIConnection : public APIServerConnection {
void climate_command(const ClimateCommandRequest &msg) override; void climate_command(const ClimateCommandRequest &msg) override;
#endif #endif
#ifdef USE_NUMBER #ifdef USE_NUMBER
bool send_number_state(number::Number *number, float state);
bool send_number_state(number::Number *number); bool send_number_state(number::Number *number);
void send_number_info(number::Number *number); void send_number_info(number::Number *number);
void number_command(const NumberCommandRequest &msg) override; void number_command(const NumberCommandRequest &msg) override;
@@ -95,11 +100,13 @@ class APIConnection : public APIServerConnection {
void datetime_command(const DateTimeCommandRequest &msg) override; void datetime_command(const DateTimeCommandRequest &msg) override;
#endif #endif
#ifdef USE_TEXT #ifdef USE_TEXT
bool send_text_state(text::Text *text, const std::string &state);
bool send_text_state(text::Text *text); bool send_text_state(text::Text *text);
void send_text_info(text::Text *text); void send_text_info(text::Text *text);
void text_command(const TextCommandRequest &msg) override; void text_command(const TextCommandRequest &msg) override;
#endif #endif
#ifdef USE_SELECT #ifdef USE_SELECT
bool send_select_state(select::Select *select, const std::string &state);
bool send_select_state(select::Select *select); bool send_select_state(select::Select *select);
void send_select_info(select::Select *select); void send_select_info(select::Select *select);
void select_command(const SelectCommandRequest &msg) override; void select_command(const SelectCommandRequest &msg) override;
@@ -109,6 +116,7 @@ class APIConnection : public APIServerConnection {
void button_command(const ButtonCommandRequest &msg) override; void button_command(const ButtonCommandRequest &msg) override;
#endif #endif
#ifdef USE_LOCK #ifdef USE_LOCK
bool send_lock_state(lock::Lock *a_lock, lock::LockState state);
bool send_lock_state(lock::Lock *a_lock); bool send_lock_state(lock::Lock *a_lock);
void send_lock_info(lock::Lock *a_lock); void send_lock_info(lock::Lock *a_lock);
void lock_command(const LockCommandRequest &msg) override; void lock_command(const LockCommandRequest &msg) override;
@@ -308,7 +316,9 @@ class APIConnection : public APIServerConnection {
uint32_t remaining_size, bool is_single); uint32_t remaining_size, bool is_single);
#ifdef USE_BINARY_SENSOR #ifdef USE_BINARY_SENSOR
static uint16_t try_send_binary_sensor_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, static uint16_t try_send_binary_sensor_state_response(binary_sensor::BinarySensor *binary_sensor, bool state,
APIConnection *conn, uint32_t remaining_size, bool is_single);
static uint16_t try_send_binary_sensor_state(EntityBase *binary_sensor, APIConnection *conn, uint32_t remaining_size,
bool is_single); bool is_single);
static uint16_t try_send_binary_sensor_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, static uint16_t try_send_binary_sensor_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single); bool is_single);
@@ -328,18 +338,24 @@ class APIConnection : public APIServerConnection {
static uint16_t try_send_light_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, bool is_single); static uint16_t try_send_light_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, bool is_single);
#endif #endif
#ifdef USE_SENSOR #ifdef USE_SENSOR
static uint16_t try_send_sensor_state_response(sensor::Sensor *sensor, float state, APIConnection *conn,
uint32_t remaining_size, bool is_single);
static uint16_t try_send_sensor_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, static uint16_t try_send_sensor_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single); bool is_single);
static uint16_t try_send_sensor_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, static uint16_t try_send_sensor_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single); bool is_single);
#endif #endif
#ifdef USE_SWITCH #ifdef USE_SWITCH
static uint16_t try_send_switch_state_response(switch_::Switch *a_switch, bool state, APIConnection *conn,
uint32_t remaining_size, bool is_single);
static uint16_t try_send_switch_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, static uint16_t try_send_switch_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single); bool is_single);
static uint16_t try_send_switch_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, static uint16_t try_send_switch_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single); bool is_single);
#endif #endif
#ifdef USE_TEXT_SENSOR #ifdef USE_TEXT_SENSOR
static uint16_t try_send_text_sensor_state_response(text_sensor::TextSensor *text_sensor, const std::string &state,
APIConnection *conn, uint32_t remaining_size, bool is_single);
static uint16_t try_send_text_sensor_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, static uint16_t try_send_text_sensor_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single); bool is_single);
static uint16_t try_send_text_sensor_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, static uint16_t try_send_text_sensor_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
@@ -352,6 +368,8 @@ class APIConnection : public APIServerConnection {
bool is_single); bool is_single);
#endif #endif
#ifdef USE_NUMBER #ifdef USE_NUMBER
static uint16_t try_send_number_state_response(number::Number *number, float state, APIConnection *conn,
uint32_t remaining_size, bool is_single);
static uint16_t try_send_number_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, static uint16_t try_send_number_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single); bool is_single);
static uint16_t try_send_number_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, static uint16_t try_send_number_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
@@ -372,10 +390,14 @@ class APIConnection : public APIServerConnection {
bool is_single); bool is_single);
#endif #endif
#ifdef USE_TEXT #ifdef USE_TEXT
static uint16_t try_send_text_state_response(text::Text *text, const std::string &state, APIConnection *conn,
uint32_t remaining_size, bool is_single);
static uint16_t try_send_text_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, bool is_single); static uint16_t try_send_text_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, bool is_single);
static uint16_t try_send_text_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, bool is_single); static uint16_t try_send_text_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, bool is_single);
#endif #endif
#ifdef USE_SELECT #ifdef USE_SELECT
static uint16_t try_send_select_state_response(select::Select *select, const std::string &state, APIConnection *conn,
uint32_t remaining_size, bool is_single);
static uint16_t try_send_select_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, static uint16_t try_send_select_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single); bool is_single);
static uint16_t try_send_select_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, static uint16_t try_send_select_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
@@ -386,6 +408,8 @@ class APIConnection : public APIServerConnection {
bool is_single); bool is_single);
#endif #endif
#ifdef USE_LOCK #ifdef USE_LOCK
static uint16_t try_send_lock_state_response(lock::Lock *a_lock, lock::LockState state, APIConnection *conn,
uint32_t remaining_size, bool is_single);
static uint16_t try_send_lock_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, bool is_single); static uint16_t try_send_lock_state(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, bool is_single);
static uint16_t try_send_lock_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, bool is_single); static uint16_t try_send_lock_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, bool is_single);
#endif #endif
@@ -426,10 +450,6 @@ class APIConnection : public APIServerConnection {
static uint16_t try_send_list_info_done(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, static uint16_t try_send_list_info_done(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single); bool is_single);
// Method for DisconnectRequest batching
static uint16_t try_send_disconnect_request(EntityBase *entity, APIConnection *conn, uint32_t remaining_size,
bool is_single);
// Helper function to get estimated message size for buffer pre-allocation // Helper function to get estimated message size for buffer pre-allocation
static uint16_t get_estimated_message_size(uint16_t message_type); static uint16_t get_estimated_message_size(uint16_t message_type);
@@ -474,11 +494,22 @@ class APIConnection : public APIServerConnection {
// Constructor for function pointer (message_type = 0) // Constructor for function pointer (message_type = 0)
MessageCreator(MessageCreatorPtr ptr) : message_type_(0) { data_.ptr = ptr; } MessageCreator(MessageCreatorPtr ptr) : message_type_(0) { data_.ptr = ptr; }
// Constructor for bool state capture
MessageCreator(bool value, uint16_t msg_type) : message_type_(msg_type) { data_.bool_value = value; }
// Constructor for float state capture
MessageCreator(float value, uint16_t msg_type) : message_type_(msg_type) { data_.float_value = value; }
// Constructor for string state capture // Constructor for string state capture
MessageCreator(const std::string &value, uint16_t msg_type) : message_type_(msg_type) { MessageCreator(const std::string &value, uint16_t msg_type) : message_type_(msg_type) {
data_.string_ptr = new std::string(value); data_.string_ptr = new std::string(value);
} }
#ifdef USE_LOCK
// Constructor for lock state capture
MessageCreator(lock::LockState value, uint16_t msg_type) : message_type_(msg_type) { data_.lock_value = value; }
#endif
// Destructor // Destructor
~MessageCreator() { ~MessageCreator() {
// Clean up string data for string-based message types // Clean up string data for string-based message types
@@ -545,12 +576,21 @@ class APIConnection : public APIServerConnection {
private: private:
// Helper to check if this message type uses heap-allocated strings // Helper to check if this message type uses heap-allocated strings
bool uses_string_data_() const { return message_type_ == EventResponse::MESSAGE_TYPE; } bool uses_string_data_() const {
return message_type_ == TextSensorStateResponse::MESSAGE_TYPE ||
message_type_ == SelectStateResponse::MESSAGE_TYPE || message_type_ == TextStateResponse::MESSAGE_TYPE ||
message_type_ == EventResponse::MESSAGE_TYPE;
}
union CreatorData { union CreatorData {
MessageCreatorPtr ptr; // 8 bytes MessageCreatorPtr ptr; // 8 bytes
bool bool_value; // 1 byte
float float_value; // 4 bytes
std::string *string_ptr; // 8 bytes std::string *string_ptr; // 8 bytes
} data_; // 8 bytes #ifdef USE_LOCK
uint16_t message_type_; // 2 bytes (0 = function ptr, >0 = state capture) lock::LockState lock_value; // 4 bytes
#endif
} data_; // 8 bytes
uint16_t message_type_; // 2 bytes (0 = function ptr, >0 = state capture)
}; };
// Generic batching mechanism for both state updates and entity info // Generic batching mechanism for both state updates and entity info

View File

@@ -1,9 +1,9 @@
#include "api_frame_helper.h" #include "api_frame_helper.h"
#ifdef USE_API #ifdef USE_API
#include "esphome/core/application.h" #include "esphome/core/log.h"
#include "esphome/core/hal.h" #include "esphome/core/hal.h"
#include "esphome/core/helpers.h" #include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/application.h"
#include "proto.h" #include "proto.h"
#include "api_pb2_size.h" #include "api_pb2_size.h"
#include <cstring> #include <cstring>

View File

@@ -92,12 +92,6 @@ void APIServer::setup() {
#ifdef USE_LOGGER #ifdef USE_LOGGER
if (logger::global_logger != nullptr) { if (logger::global_logger != nullptr) {
logger::global_logger->add_on_log_callback([this](int level, const char *tag, const char *message) { logger::global_logger->add_on_log_callback([this](int level, const char *tag, const char *message) {
if (this->shutting_down_) {
// Don't try to send logs during shutdown
// as it could result in a recursion and
// we would be filling a buffer we are trying to clear
return;
}
for (auto &c : this->clients_) { for (auto &c : this->clients_) {
if (!c->remove_) if (!c->remove_)
c->try_send_log_message(level, tag, message); c->try_send_log_message(level, tag, message);
@@ -122,8 +116,8 @@ void APIServer::setup() {
} }
void APIServer::loop() { void APIServer::loop() {
// Accept new clients only if the socket exists and has incoming connections // Accept new clients only if the socket has incoming connections
if (this->socket_ && this->socket_->ready()) { if (this->socket_->ready()) {
while (true) { while (true) {
struct sockaddr_storage source_addr; struct sockaddr_storage source_addr;
socklen_t addr_len = sizeof(source_addr); socklen_t addr_len = sizeof(source_addr);
@@ -179,10 +173,8 @@ void APIServer::loop() {
} }
void APIServer::dump_config() { void APIServer::dump_config() {
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, "API Server:");
"API Server:\n" ESP_LOGCONFIG(TAG, " Address: %s:%u", network::get_use_address().c_str(), this->port_);
" Address: %s:%u",
network::get_use_address().c_str(), this->port_);
#ifdef USE_API_NOISE #ifdef USE_API_NOISE
ESP_LOGCONFIG(TAG, " Using noise encryption: %s", YESNO(this->noise_ctx_->has_psk())); ESP_LOGCONFIG(TAG, " Using noise encryption: %s", YESNO(this->noise_ctx_->has_psk()));
if (!this->noise_ctx_->has_psk()) { if (!this->noise_ctx_->has_psk()) {
@@ -227,11 +219,12 @@ bool APIServer::check_password(const std::string &password) const {
void APIServer::handle_disconnect(APIConnection *conn) {} void APIServer::handle_disconnect(APIConnection *conn) {}
#ifdef USE_BINARY_SENSOR #ifdef USE_BINARY_SENSOR
void APIServer::on_binary_sensor_update(binary_sensor::BinarySensor *obj) { void APIServer::on_binary_sensor_update(binary_sensor::BinarySensor *obj, bool state) {
if (obj->is_internal()) if (obj->is_internal())
return; return;
bool use_current = (state == obj->state);
for (auto &c : this->clients_) for (auto &c : this->clients_)
c->send_binary_sensor_state(obj); use_current ? c->send_binary_sensor_state(obj) : c->send_binary_sensor_state(obj, state);
} }
#endif #endif
@@ -266,8 +259,9 @@ void APIServer::on_light_update(light::LightState *obj) {
void APIServer::on_sensor_update(sensor::Sensor *obj, float state) { void APIServer::on_sensor_update(sensor::Sensor *obj, float state) {
if (obj->is_internal()) if (obj->is_internal())
return; return;
bool use_current = (state == obj->state);
for (auto &c : this->clients_) for (auto &c : this->clients_)
c->send_sensor_state(obj); use_current ? c->send_sensor_state(obj) : c->send_sensor_state(obj, state);
} }
#endif #endif
@@ -275,8 +269,9 @@ void APIServer::on_sensor_update(sensor::Sensor *obj, float state) {
void APIServer::on_switch_update(switch_::Switch *obj, bool state) { void APIServer::on_switch_update(switch_::Switch *obj, bool state) {
if (obj->is_internal()) if (obj->is_internal())
return; return;
bool use_current = (state == obj->state);
for (auto &c : this->clients_) for (auto &c : this->clients_)
c->send_switch_state(obj); use_current ? c->send_switch_state(obj) : c->send_switch_state(obj, state);
} }
#endif #endif
@@ -284,8 +279,9 @@ void APIServer::on_switch_update(switch_::Switch *obj, bool state) {
void APIServer::on_text_sensor_update(text_sensor::TextSensor *obj, const std::string &state) { void APIServer::on_text_sensor_update(text_sensor::TextSensor *obj, const std::string &state) {
if (obj->is_internal()) if (obj->is_internal())
return; return;
bool use_current = (state == obj->state);
for (auto &c : this->clients_) for (auto &c : this->clients_)
c->send_text_sensor_state(obj); use_current ? c->send_text_sensor_state(obj) : c->send_text_sensor_state(obj, state);
} }
#endif #endif
@@ -302,8 +298,9 @@ void APIServer::on_climate_update(climate::Climate *obj) {
void APIServer::on_number_update(number::Number *obj, float state) { void APIServer::on_number_update(number::Number *obj, float state) {
if (obj->is_internal()) if (obj->is_internal())
return; return;
bool use_current = (state == obj->state);
for (auto &c : this->clients_) for (auto &c : this->clients_)
c->send_number_state(obj); use_current ? c->send_number_state(obj) : c->send_number_state(obj, state);
} }
#endif #endif
@@ -338,8 +335,9 @@ void APIServer::on_datetime_update(datetime::DateTimeEntity *obj) {
void APIServer::on_text_update(text::Text *obj, const std::string &state) { void APIServer::on_text_update(text::Text *obj, const std::string &state) {
if (obj->is_internal()) if (obj->is_internal())
return; return;
bool use_current = (state == obj->state);
for (auto &c : this->clients_) for (auto &c : this->clients_)
c->send_text_state(obj); use_current ? c->send_text_state(obj) : c->send_text_state(obj, state);
} }
#endif #endif
@@ -347,8 +345,9 @@ void APIServer::on_text_update(text::Text *obj, const std::string &state) {
void APIServer::on_select_update(select::Select *obj, const std::string &state, size_t index) { void APIServer::on_select_update(select::Select *obj, const std::string &state, size_t index) {
if (obj->is_internal()) if (obj->is_internal())
return; return;
bool use_current = (state == obj->state);
for (auto &c : this->clients_) for (auto &c : this->clients_)
c->send_select_state(obj); use_current ? c->send_select_state(obj) : c->send_select_state(obj, state);
} }
#endif #endif
@@ -488,36 +487,10 @@ void APIServer::request_time() {
bool APIServer::is_connected() const { return !this->clients_.empty(); } bool APIServer::is_connected() const { return !this->clients_.empty(); }
void APIServer::on_shutdown() { void APIServer::on_shutdown() {
this->shutting_down_ = true;
// Close the listening socket to prevent new connections
if (this->socket_) {
this->socket_->close();
this->socket_ = nullptr;
}
// Change batch delay to 5ms for quick flushing during shutdown
this->batch_delay_ = 5;
// Send disconnect requests to all connected clients
for (auto &c : this->clients_) { for (auto &c : this->clients_) {
if (!c->send_message(DisconnectRequest())) { c->send_message(DisconnectRequest());
// If we can't send the disconnect request directly (tx_buffer full),
// schedule it in the batch so it will be sent with the 5ms timer
c->schedule_message_(nullptr, &APIConnection::try_send_disconnect_request, DisconnectRequest::MESSAGE_TYPE);
}
} }
} delay(10);
bool APIServer::teardown() {
// If network is disconnected, no point trying to flush buffers
if (!network::is_connected()) {
return true;
}
this->loop();
// Return true only when all clients have been torn down
return this->clients_.empty();
} }
} // namespace api } // namespace api

View File

@@ -34,7 +34,6 @@ class APIServer : public Component, public Controller {
void loop() override; void loop() override;
void dump_config() override; void dump_config() override;
void on_shutdown() override; void on_shutdown() override;
bool teardown() override;
bool check_password(const std::string &password) const; bool check_password(const std::string &password) const;
bool uses_password() const; bool uses_password() const;
void set_port(uint16_t port); void set_port(uint16_t port);
@@ -54,7 +53,7 @@ class APIServer : public Component, public Controller {
void handle_disconnect(APIConnection *conn); void handle_disconnect(APIConnection *conn);
#ifdef USE_BINARY_SENSOR #ifdef USE_BINARY_SENSOR
void on_binary_sensor_update(binary_sensor::BinarySensor *obj) override; void on_binary_sensor_update(binary_sensor::BinarySensor *obj, bool state) override;
#endif #endif
#ifdef USE_COVER #ifdef USE_COVER
void on_cover_update(cover::Cover *obj) override; void on_cover_update(cover::Cover *obj) override;
@@ -142,7 +141,6 @@ class APIServer : public Component, public Controller {
} }
protected: protected:
bool shutting_down_ = false;
std::unique_ptr<socket::Socket> socket_ = nullptr; std::unique_ptr<socket::Socket> socket_ = nullptr;
uint16_t port_{6053}; uint16_t port_{6053};
uint32_t reboot_timeout_{300000}; uint32_t reboot_timeout_{300000};

View File

@@ -5,7 +5,7 @@ from datetime import datetime
import logging import logging
from typing import TYPE_CHECKING, Any from typing import TYPE_CHECKING, Any
from aioesphomeapi import APIClient, parse_log_message from aioesphomeapi import APIClient
from aioesphomeapi.log_runner import async_run from aioesphomeapi.log_runner import async_run
from esphome.const import CONF_KEY, CONF_PASSWORD, CONF_PORT, __version__ from esphome.const import CONF_KEY, CONF_PASSWORD, CONF_PORT, __version__
@@ -46,10 +46,9 @@ async def async_run_logs(config: dict[str, Any], address: str) -> None:
time_ = datetime.now() time_ = datetime.now()
message: bytes = msg.message message: bytes = msg.message
text = message.decode("utf8", "backslashreplace") text = message.decode("utf8", "backslashreplace")
for parsed_msg in parse_log_message( if dashboard:
text, f"[{time_.hour:02}:{time_.minute:02}:{time_.second:02}]" text = text.replace("\033", "\\033")
): print(f"[{time_.hour:02}:{time_.minute:02}:{time_.second:02}]{text}")
print(parsed_msg.replace("\033", "\\033") if dashboard else parsed_msg)
stop = await async_run(cli, on_log, name=name) stop = await async_run(cli, on_log, name=name)
try: try:

View File

@@ -3,8 +3,8 @@
#include "api_server.h" #include "api_server.h"
#ifdef USE_API #ifdef USE_API
#include "api_pb2.h" #include "api_pb2.h"
#include "esphome/core/automation.h"
#include "esphome/core/helpers.h" #include "esphome/core/helpers.h"
#include "esphome/core/automation.h"
#include <vector> #include <vector>
namespace esphome { namespace esphome {

View File

@@ -1,6 +1,5 @@
#include "proto.h" #include "proto.h"
#include <cinttypes> #include <cinttypes>
#include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
namespace esphome { namespace esphome {

View File

@@ -1,8 +1,8 @@
#pragma once #pragma once
#include "esphome/core/component.h" #include "esphome/core/component.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/helpers.h"
#include <vector> #include <vector>

View File

@@ -95,13 +95,11 @@ void AS5600Component::dump_config() {
return; return;
} }
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Watchdog: %d", this->watchdog_);
" Watchdog: %d\n" ESP_LOGCONFIG(TAG, " Fast Filter: %d", this->fast_filter_);
" Fast Filter: %d\n" ESP_LOGCONFIG(TAG, " Slow Filter: %d", this->slow_filter_);
" Slow Filter: %d\n" ESP_LOGCONFIG(TAG, " Hysteresis: %d", this->hysteresis_);
" Hysteresis: %d\n" ESP_LOGCONFIG(TAG, " Start Position: %d", this->start_position_);
" Start Position: %d",
this->watchdog_, this->fast_filter_, this->slow_filter_, this->hysteresis_, this->start_position_);
if (this->end_mode_ == END_MODE_POSITION) { if (this->end_mode_ == END_MODE_POSITION) {
ESP_LOGCONFIG(TAG, " End Position: %d", this->end_position_); ESP_LOGCONFIG(TAG, " End Position: %d", this->end_position_);
} else { } else {

View File

@@ -41,11 +41,9 @@ void AS7341Component::dump_config() {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL); ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
} }
LOG_UPDATE_INTERVAL(this); LOG_UPDATE_INTERVAL(this);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Gain: %u", get_gain());
" Gain: %u\n" ESP_LOGCONFIG(TAG, " ATIME: %u", get_atime());
" ATIME: %u\n" ESP_LOGCONFIG(TAG, " ASTEP: %u", get_astep());
" ASTEP: %u",
get_gain(), get_atime(), get_astep());
LOG_SENSOR(" ", "F1", this->f1_); LOG_SENSOR(" ", "F1", this->f1_);
LOG_SENSOR(" ", "F2", this->f2_); LOG_SENSOR(" ", "F2", this->f2_);

View File

@@ -75,18 +75,15 @@ void AT581XComponent::setup() { ESP_LOGCONFIG(TAG, "Running setup"); }
void AT581XComponent::dump_config() { LOG_I2C_DEVICE(this); } void AT581XComponent::dump_config() { LOG_I2C_DEVICE(this); }
#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0])) #define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0]))
bool AT581XComponent::i2c_write_config() { bool AT581XComponent::i2c_write_config() {
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, "Writing new config for AT581X");
"Writing new config for AT581X\n" ESP_LOGCONFIG(TAG, "Frequency: %dMHz", this->freq_);
"Frequency: %dMHz\n" ESP_LOGCONFIG(TAG, "Sensing distance: %d", this->delta_);
"Sensing distance: %d\n" ESP_LOGCONFIG(TAG, "Power: %dµA", this->power_);
"Power: %dµA\n" ESP_LOGCONFIG(TAG, "Gain: %d", this->gain_);
"Gain: %d\n" ESP_LOGCONFIG(TAG, "Trigger base time: %dms", this->trigger_base_time_ms_);
"Trigger base time: %dms\n" ESP_LOGCONFIG(TAG, "Trigger keep time: %dms", this->trigger_keep_time_ms_);
"Trigger keep time: %dms\n" ESP_LOGCONFIG(TAG, "Protect time: %dms", this->protect_time_ms_);
"Protect time: %dms\n" ESP_LOGCONFIG(TAG, "Self check time: %dms", this->self_check_time_ms_);
"Self check time: %dms",
this->freq_, this->delta_, this->power_, this->gain_, this->trigger_base_time_ms_,
this->trigger_keep_time_ms_, this->protect_time_ms_, this->self_check_time_ms_);
// Set frequency point // Set frequency point
if (!this->i2c_write_reg(FREQ_ADDR, GAIN61_VALUE)) { if (!this->i2c_write_reg(FREQ_ADDR, GAIN61_VALUE)) {

View File

@@ -60,10 +60,8 @@ void AXS15231Touchscreen::dump_config() {
LOG_I2C_DEVICE(this); LOG_I2C_DEVICE(this);
LOG_PIN(" Interrupt Pin: ", this->interrupt_pin_); LOG_PIN(" Interrupt Pin: ", this->interrupt_pin_);
LOG_PIN(" Reset Pin: ", this->reset_pin_); LOG_PIN(" Reset Pin: ", this->reset_pin_);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Width: %d", this->x_raw_max_);
" Width: %d\n" ESP_LOGCONFIG(TAG, " Height: %d", this->y_raw_max_);
" Height: %d",
this->x_raw_max_, this->y_raw_max_);
} }
} // namespace axs15231 } // namespace axs15231

View File

@@ -194,14 +194,11 @@ Trigger<> *BangBangClimate::get_heat_trigger() const { return this->heat_trigger
void BangBangClimate::set_supports_heat(bool supports_heat) { this->supports_heat_ = supports_heat; } void BangBangClimate::set_supports_heat(bool supports_heat) { this->supports_heat_ = supports_heat; }
void BangBangClimate::dump_config() { void BangBangClimate::dump_config() {
LOG_CLIMATE("", "Bang Bang Climate", this); LOG_CLIMATE("", "Bang Bang Climate", this);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Supports HEAT: %s", YESNO(this->supports_heat_));
" Supports HEAT: %s\n" ESP_LOGCONFIG(TAG, " Supports COOL: %s", YESNO(this->supports_cool_));
" Supports COOL: %s\n" ESP_LOGCONFIG(TAG, " Supports AWAY mode: %s", YESNO(this->supports_away_));
" Supports AWAY mode: %s\n" ESP_LOGCONFIG(TAG, " Default Target Temperature Low: %.2f°C", this->normal_config_.default_temperature_low);
" Default Target Temperature Low: %.2f°C\n" ESP_LOGCONFIG(TAG, " Default Target Temperature High: %.2f°C", this->normal_config_.default_temperature_high);
" Default Target Temperature High: %.2f°C",
YESNO(this->supports_heat_), YESNO(this->supports_cool_), YESNO(this->supports_away_),
this->normal_config_.default_temperature_low, this->normal_config_.default_temperature_high);
} }
BangBangClimateTargetTempConfig::BangBangClimateTargetTempConfig() = default; BangBangClimateTargetTempConfig::BangBangClimateTargetTempConfig() = default;

View File

@@ -484,11 +484,9 @@ void BedJetHub::loop() {}
void BedJetHub::update() { this->dispatch_status_(); } void BedJetHub::update() { this->dispatch_status_(); }
void BedJetHub::dump_config() { void BedJetHub::dump_config() {
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, "BedJet Hub '%s'", this->get_name().c_str());
"BedJet Hub '%s'\n" ESP_LOGCONFIG(TAG, " ble_client.app_id: %d", this->parent()->app_id);
" ble_client.app_id: %d\n" ESP_LOGCONFIG(TAG, " ble_client.conn_id: %d", this->parent()->get_conn_id());
" ble_client.conn_id: %d",
this->get_name().c_str(), this->parent()->app_id, this->parent()->get_conn_id());
LOG_UPDATE_INTERVAL(this) LOG_UPDATE_INTERVAL(this)
ESP_LOGCONFIG(TAG, " Child components (%d):", this->children_.size()); ESP_LOGCONFIG(TAG, " Child components (%d):", this->children_.size());
for (auto *child : this->children_) { for (auto *child : this->children_) {

View File

@@ -345,10 +345,8 @@ light::ESPColorView BekenSPILEDStripLightOutput::get_view_internal(int32_t index
} }
void BekenSPILEDStripLightOutput::dump_config() { void BekenSPILEDStripLightOutput::dump_config() {
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, "Beken SPI LED Strip:");
"Beken SPI LED Strip:\n" ESP_LOGCONFIG(TAG, " Pin: %u", this->pin_);
" Pin: %u",
this->pin_);
const char *rgb_order; const char *rgb_order;
switch (this->rgb_order_) { switch (this->rgb_order_) {
case ORDER_RGB: case ORDER_RGB:
@@ -373,11 +371,9 @@ void BekenSPILEDStripLightOutput::dump_config() {
rgb_order = "UNKNOWN"; rgb_order = "UNKNOWN";
break; break;
} }
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " RGB Order: %s", rgb_order);
" RGB Order: %s\n" ESP_LOGCONFIG(TAG, " Max refresh rate: %" PRIu32, *this->max_refresh_rate_);
" Max refresh rate: %" PRIu32 "\n" ESP_LOGCONFIG(TAG, " Number of LEDs: %u", this->num_leds_);
" Number of LEDs: %u",
rgb_order, *this->max_refresh_rate_, this->num_leds_);
} }
float BekenSPILEDStripLightOutput::get_setup_priority() const { return setup_priority::HARDWARE; } float BekenSPILEDStripLightOutput::get_setup_priority() const { return setup_priority::HARDWARE; }

View File

@@ -1,10 +1,7 @@
from logging import getLogger
from esphome import automation, core from esphome import automation, core
from esphome.automation import Condition, maybe_simple_id from esphome.automation import Condition, maybe_simple_id
import esphome.codegen as cg import esphome.codegen as cg
from esphome.components import mqtt, web_server from esphome.components import mqtt, web_server
from esphome.components.const import CONF_ON_STATE_CHANGE
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_DELAY, CONF_DELAY,
@@ -101,7 +98,6 @@ IS_PLATFORM_COMPONENT = True
CONF_TIME_OFF = "time_off" CONF_TIME_OFF = "time_off"
CONF_TIME_ON = "time_on" CONF_TIME_ON = "time_on"
CONF_TRIGGER_ON_INITIAL_STATE = "trigger_on_initial_state"
DEFAULT_DELAY = "1s" DEFAULT_DELAY = "1s"
DEFAULT_TIME_OFF = "100ms" DEFAULT_TIME_OFF = "100ms"
@@ -131,17 +127,9 @@ MultiClickTriggerEvent = binary_sensor_ns.struct("MultiClickTriggerEvent")
StateTrigger = binary_sensor_ns.class_( StateTrigger = binary_sensor_ns.class_(
"StateTrigger", automation.Trigger.template(bool) "StateTrigger", automation.Trigger.template(bool)
) )
StateChangeTrigger = binary_sensor_ns.class_(
"StateChangeTrigger",
automation.Trigger.template(cg.optional.template(bool), cg.optional.template(bool)),
)
BinarySensorPublishAction = binary_sensor_ns.class_( BinarySensorPublishAction = binary_sensor_ns.class_(
"BinarySensorPublishAction", automation.Action "BinarySensorPublishAction", automation.Action
) )
BinarySensorInvalidateAction = binary_sensor_ns.class_(
"BinarySensorInvalidateAction", automation.Action
)
# Condition # Condition
BinarySensorCondition = binary_sensor_ns.class_("BinarySensorCondition", Condition) BinarySensorCondition = binary_sensor_ns.class_("BinarySensorCondition", Condition)
@@ -156,8 +144,6 @@ AutorepeatFilter = binary_sensor_ns.class_("AutorepeatFilter", Filter, cg.Compon
LambdaFilter = binary_sensor_ns.class_("LambdaFilter", Filter) LambdaFilter = binary_sensor_ns.class_("LambdaFilter", Filter)
SettleFilter = binary_sensor_ns.class_("SettleFilter", Filter, cg.Component) SettleFilter = binary_sensor_ns.class_("SettleFilter", Filter, cg.Component)
_LOGGER = getLogger(__name__)
FILTER_REGISTRY = Registry() FILTER_REGISTRY = Registry()
validate_filters = cv.validate_registry("filter", FILTER_REGISTRY) validate_filters = cv.validate_registry("filter", FILTER_REGISTRY)
@@ -400,14 +386,6 @@ def validate_click_timing(value):
return value return value
def validate_publish_initial_state(value):
value = cv.boolean(value)
_LOGGER.warning(
"The 'publish_initial_state' option has been replaced by 'trigger_on_initial_state' and will be removed in a future release"
)
return value
_BINARY_SENSOR_SCHEMA = ( _BINARY_SENSOR_SCHEMA = (
cv.ENTITY_BASE_SCHEMA.extend(web_server.WEBSERVER_SORTING_SCHEMA) cv.ENTITY_BASE_SCHEMA.extend(web_server.WEBSERVER_SORTING_SCHEMA)
.extend(cv.MQTT_COMPONENT_SCHEMA) .extend(cv.MQTT_COMPONENT_SCHEMA)
@@ -417,12 +395,7 @@ _BINARY_SENSOR_SCHEMA = (
cv.OnlyWith(CONF_MQTT_ID, "mqtt"): cv.declare_id( cv.OnlyWith(CONF_MQTT_ID, "mqtt"): cv.declare_id(
mqtt.MQTTBinarySensorComponent mqtt.MQTTBinarySensorComponent
), ),
cv.Exclusive( cv.Optional(CONF_PUBLISH_INITIAL_STATE): cv.boolean,
CONF_PUBLISH_INITIAL_STATE, CONF_TRIGGER_ON_INITIAL_STATE
): validate_publish_initial_state,
cv.Exclusive(
CONF_TRIGGER_ON_INITIAL_STATE, CONF_TRIGGER_ON_INITIAL_STATE
): cv.boolean,
cv.Optional(CONF_DEVICE_CLASS): validate_device_class, cv.Optional(CONF_DEVICE_CLASS): validate_device_class,
cv.Optional(CONF_FILTERS): validate_filters, cv.Optional(CONF_FILTERS): validate_filters,
cv.Optional(CONF_ON_PRESS): automation.validate_automation( cv.Optional(CONF_ON_PRESS): automation.validate_automation(
@@ -481,11 +454,6 @@ _BINARY_SENSOR_SCHEMA = (
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(StateTrigger), cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(StateTrigger),
} }
), ),
cv.Optional(CONF_ON_STATE_CHANGE): automation.validate_automation(
{
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(StateChangeTrigger),
}
),
} }
) )
) )
@@ -525,10 +493,8 @@ async def setup_binary_sensor_core_(var, config):
if (device_class := config.get(CONF_DEVICE_CLASS)) is not None: if (device_class := config.get(CONF_DEVICE_CLASS)) is not None:
cg.add(var.set_device_class(device_class)) cg.add(var.set_device_class(device_class))
trigger = config.get(CONF_TRIGGER_ON_INITIAL_STATE, False) or config.get( if publish_initial_state := config.get(CONF_PUBLISH_INITIAL_STATE):
CONF_PUBLISH_INITIAL_STATE, False cg.add(var.set_publish_initial_state(publish_initial_state))
)
cg.add(var.set_trigger_on_initial_state(trigger))
if inverted := config.get(CONF_INVERTED): if inverted := config.get(CONF_INVERTED):
cg.add(var.set_inverted(inverted)) cg.add(var.set_inverted(inverted))
if filters_config := config.get(CONF_FILTERS): if filters_config := config.get(CONF_FILTERS):
@@ -576,17 +542,6 @@ async def setup_binary_sensor_core_(var, config):
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
await automation.build_automation(trigger, [(bool, "x")], conf) await automation.build_automation(trigger, [(bool, "x")], conf)
for conf in config.get(CONF_ON_STATE_CHANGE, []):
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
await automation.build_automation(
trigger,
[
(cg.optional.template(bool), "x_previous"),
(cg.optional.template(bool), "x"),
],
conf,
)
if mqtt_id := config.get(CONF_MQTT_ID): if mqtt_id := config.get(CONF_MQTT_ID):
mqtt_ = cg.new_Pvariable(mqtt_id, var) mqtt_ = cg.new_Pvariable(mqtt_id, var)
await mqtt.register_mqtt_component(mqtt_, config) await mqtt.register_mqtt_component(mqtt_, config)
@@ -599,7 +554,6 @@ async def register_binary_sensor(var, config):
if not CORE.has_id(config[CONF_ID]): if not CORE.has_id(config[CONF_ID]):
var = cg.Pvariable(config[CONF_ID], var) var = cg.Pvariable(config[CONF_ID], var)
cg.add(cg.App.register_binary_sensor(var)) cg.add(cg.App.register_binary_sensor(var))
CORE.register_platform_component("binary_sensor", var)
await setup_binary_sensor_core_(var, config) await setup_binary_sensor_core_(var, config)
@@ -636,18 +590,3 @@ async def binary_sensor_is_off_to_code(config, condition_id, template_arg, args)
async def to_code(config): async def to_code(config):
cg.add_define("USE_BINARY_SENSOR") cg.add_define("USE_BINARY_SENSOR")
cg.add_global(binary_sensor_ns.using) cg.add_global(binary_sensor_ns.using)
@automation.register_action(
"binary_sensor.invalidate_state",
BinarySensorInvalidateAction,
cv.maybe_simple_value(
{
cv.Required(CONF_ID): cv.use_id(BinarySensor),
},
key=CONF_ID,
),
)
async def binary_sensor_invalidate_state_to_code(config, action_id, template_arg, args):
paren = await cg.get_variable(config[CONF_ID])
return cg.new_Pvariable(action_id, template_arg, paren)

View File

@@ -96,7 +96,7 @@ class MultiClickTrigger : public Trigger<>, public Component {
: parent_(parent), timing_(std::move(timing)) {} : parent_(parent), timing_(std::move(timing)) {}
void setup() override { void setup() override {
this->last_state_ = this->parent_->get_state_default(false); this->last_state_ = this->parent_->state;
auto f = std::bind(&MultiClickTrigger::on_state_, this, std::placeholders::_1); auto f = std::bind(&MultiClickTrigger::on_state_, this, std::placeholders::_1);
this->parent_->add_on_state_callback(f); this->parent_->add_on_state_callback(f);
} }
@@ -130,14 +130,6 @@ class StateTrigger : public Trigger<bool> {
} }
}; };
class StateChangeTrigger : public Trigger<optional<bool>, optional<bool> > {
public:
explicit StateChangeTrigger(BinarySensor *parent) {
parent->add_full_state_callback(
[this](optional<bool> old_state, optional<bool> state) { this->trigger(old_state, state); });
}
};
template<typename... Ts> class BinarySensorCondition : public Condition<Ts...> { template<typename... Ts> class BinarySensorCondition : public Condition<Ts...> {
public: public:
BinarySensorCondition(BinarySensor *parent, bool state) : parent_(parent), state_(state) {} BinarySensorCondition(BinarySensor *parent, bool state) : parent_(parent), state_(state) {}
@@ -162,15 +154,5 @@ template<typename... Ts> class BinarySensorPublishAction : public Action<Ts...>
BinarySensor *sensor_; BinarySensor *sensor_;
}; };
template<typename... Ts> class BinarySensorInvalidateAction : public Action<Ts...> {
public:
explicit BinarySensorInvalidateAction(BinarySensor *sensor) : sensor_(sensor) {}
void play(Ts... x) override { this->sensor_->invalidate_state(); }
protected:
BinarySensor *sensor_;
};
} // namespace binary_sensor } // namespace binary_sensor
} // namespace esphome } // namespace esphome

View File

@@ -7,25 +7,42 @@ namespace binary_sensor {
static const char *const TAG = "binary_sensor"; static const char *const TAG = "binary_sensor";
void BinarySensor::publish_state(bool new_state) { void BinarySensor::add_on_state_callback(std::function<void(bool)> &&callback) {
this->state_callback_.add(std::move(callback));
}
void BinarySensor::publish_state(bool state) {
if (!this->publish_dedup_.next(state))
return;
if (this->filter_list_ == nullptr) { if (this->filter_list_ == nullptr) {
this->send_state_internal(new_state); this->send_state_internal(state, false);
} else { } else {
this->filter_list_->input(new_state); this->filter_list_->input(state, false);
} }
} }
void BinarySensor::publish_initial_state(bool new_state) { void BinarySensor::publish_initial_state(bool state) {
this->invalidate_state(); if (!this->publish_dedup_.next(state))
this->publish_state(new_state); return;
} if (this->filter_list_ == nullptr) {
void BinarySensor::send_state_internal(bool new_state) { this->send_state_internal(state, true);
// copy the new state to the visible property for backwards compatibility, before any callbacks } else {
this->state = new_state; this->filter_list_->input(state, true);
// Note that set_state_ de-dups and will only trigger callbacks if the state has actually changed
if (this->set_state_(new_state)) {
ESP_LOGD(TAG, "'%s': New state is %s", this->get_name().c_str(), ONOFF(new_state));
} }
} }
void BinarySensor::send_state_internal(bool state, bool is_initial) {
if (is_initial) {
ESP_LOGD(TAG, "'%s': Sending initial state %s", this->get_name().c_str(), ONOFF(state));
} else {
ESP_LOGD(TAG, "'%s': Sending state %s", this->get_name().c_str(), ONOFF(state));
}
this->has_state_ = true;
this->state = state;
if (!is_initial || this->publish_initial_state_) {
this->state_callback_.call(state);
}
}
BinarySensor::BinarySensor() : state(false) {}
void BinarySensor::add_filter(Filter *filter) { void BinarySensor::add_filter(Filter *filter) {
filter->parent_ = this; filter->parent_ = this;
@@ -43,6 +60,7 @@ void BinarySensor::add_filters(const std::vector<Filter *> &filters) {
this->add_filter(filter); this->add_filter(filter);
} }
} }
bool BinarySensor::has_state() const { return this->has_state_; }
bool BinarySensor::is_status_binary_sensor() const { return false; } bool BinarySensor::is_status_binary_sensor() const { return false; }
} // namespace binary_sensor } // namespace binary_sensor

View File

@@ -1,5 +1,6 @@
#pragma once #pragma once
#include "esphome/core/component.h"
#include "esphome/core/entity_base.h" #include "esphome/core/entity_base.h"
#include "esphome/core/helpers.h" #include "esphome/core/helpers.h"
#include "esphome/components/binary_sensor/filter.h" #include "esphome/components/binary_sensor/filter.h"
@@ -33,39 +34,52 @@ namespace binary_sensor {
* The sub classes should notify the front-end of new states via the publish_state() method which * The sub classes should notify the front-end of new states via the publish_state() method which
* handles inverted inputs for you. * handles inverted inputs for you.
*/ */
class BinarySensor : public StatefulEntityBase<bool>, public EntityBase_DeviceClass { class BinarySensor : public EntityBase, public EntityBase_DeviceClass {
public: public:
explicit BinarySensor(){}; explicit BinarySensor();
/** Add a callback to be notified of state changes.
*
* @param callback The void(bool) callback.
*/
void add_on_state_callback(std::function<void(bool)> &&callback);
/** Publish a new state to the front-end. /** Publish a new state to the front-end.
* *
* @param new_state The new state. * @param state The new state.
*/ */
void publish_state(bool new_state); void publish_state(bool state);
/** Publish the initial state, this will not make the callback manager send callbacks /** Publish the initial state, this will not make the callback manager send callbacks
* and is meant only for the initial state on boot. * and is meant only for the initial state on boot.
* *
* @param new_state The new state. * @param state The new state.
*/ */
void publish_initial_state(bool new_state); void publish_initial_state(bool state);
/// The current reported state of the binary sensor.
bool state{false};
void add_filter(Filter *filter); void add_filter(Filter *filter);
void add_filters(const std::vector<Filter *> &filters); void add_filters(const std::vector<Filter *> &filters);
void set_publish_initial_state(bool publish_initial_state) { this->publish_initial_state_ = publish_initial_state; }
// ========== INTERNAL METHODS ========== // ========== INTERNAL METHODS ==========
// (In most use cases you won't need these) // (In most use cases you won't need these)
void send_state_internal(bool new_state); void send_state_internal(bool state, bool is_initial);
/// Return whether this binary sensor has outputted a state. /// Return whether this binary sensor has outputted a state.
virtual bool has_state() const;
virtual bool is_status_binary_sensor() const; virtual bool is_status_binary_sensor() const;
// For backward compatibility, provide an accessible property
bool state{};
protected: protected:
CallbackManager<void(bool)> state_callback_{};
Filter *filter_list_{nullptr}; Filter *filter_list_{nullptr};
bool has_state_{false};
bool publish_initial_state_{false};
Deduplicator<bool> publish_dedup_;
}; };
class BinarySensorInitiallyOff : public BinarySensor { class BinarySensorInitiallyOff : public BinarySensor {

View File

@@ -9,36 +9,37 @@ namespace binary_sensor {
static const char *const TAG = "sensor.filter"; static const char *const TAG = "sensor.filter";
void Filter::output(bool value) { void Filter::output(bool value, bool is_initial) {
if (this->next_ == nullptr) {
this->parent_->send_state_internal(value);
} else {
this->next_->input(value);
}
}
void Filter::input(bool value) {
if (!this->dedup_.next(value)) if (!this->dedup_.next(value))
return; return;
auto b = this->new_value(value);
if (this->next_ == nullptr) {
this->parent_->send_state_internal(value, is_initial);
} else {
this->next_->input(value, is_initial);
}
}
void Filter::input(bool value, bool is_initial) {
auto b = this->new_value(value, is_initial);
if (b.has_value()) { if (b.has_value()) {
this->output(*b); this->output(*b, is_initial);
} }
} }
optional<bool> DelayedOnOffFilter::new_value(bool value) { optional<bool> DelayedOnOffFilter::new_value(bool value, bool is_initial) {
if (value) { if (value) {
this->set_timeout("ON_OFF", this->on_delay_.value(), [this]() { this->output(true); }); this->set_timeout("ON_OFF", this->on_delay_.value(), [this, is_initial]() { this->output(true, is_initial); });
} else { } else {
this->set_timeout("ON_OFF", this->off_delay_.value(), [this]() { this->output(false); }); this->set_timeout("ON_OFF", this->off_delay_.value(), [this, is_initial]() { this->output(false, is_initial); });
} }
return {}; return {};
} }
float DelayedOnOffFilter::get_setup_priority() const { return setup_priority::HARDWARE; } float DelayedOnOffFilter::get_setup_priority() const { return setup_priority::HARDWARE; }
optional<bool> DelayedOnFilter::new_value(bool value) { optional<bool> DelayedOnFilter::new_value(bool value, bool is_initial) {
if (value) { if (value) {
this->set_timeout("ON", this->delay_.value(), [this]() { this->output(true); }); this->set_timeout("ON", this->delay_.value(), [this, is_initial]() { this->output(true, is_initial); });
return {}; return {};
} else { } else {
this->cancel_timeout("ON"); this->cancel_timeout("ON");
@@ -48,9 +49,9 @@ optional<bool> DelayedOnFilter::new_value(bool value) {
float DelayedOnFilter::get_setup_priority() const { return setup_priority::HARDWARE; } float DelayedOnFilter::get_setup_priority() const { return setup_priority::HARDWARE; }
optional<bool> DelayedOffFilter::new_value(bool value) { optional<bool> DelayedOffFilter::new_value(bool value, bool is_initial) {
if (!value) { if (!value) {
this->set_timeout("OFF", this->delay_.value(), [this]() { this->output(false); }); this->set_timeout("OFF", this->delay_.value(), [this, is_initial]() { this->output(false, is_initial); });
return {}; return {};
} else { } else {
this->cancel_timeout("OFF"); this->cancel_timeout("OFF");
@@ -60,11 +61,11 @@ optional<bool> DelayedOffFilter::new_value(bool value) {
float DelayedOffFilter::get_setup_priority() const { return setup_priority::HARDWARE; } float DelayedOffFilter::get_setup_priority() const { return setup_priority::HARDWARE; }
optional<bool> InvertFilter::new_value(bool value) { return !value; } optional<bool> InvertFilter::new_value(bool value, bool is_initial) { return !value; }
AutorepeatFilter::AutorepeatFilter(std::vector<AutorepeatFilterTiming> timings) : timings_(std::move(timings)) {} AutorepeatFilter::AutorepeatFilter(std::vector<AutorepeatFilterTiming> timings) : timings_(std::move(timings)) {}
optional<bool> AutorepeatFilter::new_value(bool value) { optional<bool> AutorepeatFilter::new_value(bool value, bool is_initial) {
if (value) { if (value) {
// Ignore if already running // Ignore if already running
if (this->active_timing_ != 0) if (this->active_timing_ != 0)
@@ -100,7 +101,7 @@ void AutorepeatFilter::next_timing_() {
void AutorepeatFilter::next_value_(bool val) { void AutorepeatFilter::next_value_(bool val) {
const AutorepeatFilterTiming &timing = this->timings_[this->active_timing_ - 2]; const AutorepeatFilterTiming &timing = this->timings_[this->active_timing_ - 2];
this->output(val); // This is at least the second one so not initial this->output(val, false); // This is at least the second one so not initial
this->set_timeout("ON_OFF", val ? timing.time_on : timing.time_off, [this, val]() { this->next_value_(!val); }); this->set_timeout("ON_OFF", val ? timing.time_on : timing.time_off, [this, val]() { this->next_value_(!val); });
} }
@@ -108,18 +109,18 @@ float AutorepeatFilter::get_setup_priority() const { return setup_priority::HARD
LambdaFilter::LambdaFilter(std::function<optional<bool>(bool)> f) : f_(std::move(f)) {} LambdaFilter::LambdaFilter(std::function<optional<bool>(bool)> f) : f_(std::move(f)) {}
optional<bool> LambdaFilter::new_value(bool value) { return this->f_(value); } optional<bool> LambdaFilter::new_value(bool value, bool is_initial) { return this->f_(value); }
optional<bool> SettleFilter::new_value(bool value) { optional<bool> SettleFilter::new_value(bool value, bool is_initial) {
if (!this->steady_) { if (!this->steady_) {
this->set_timeout("SETTLE", this->delay_.value(), [this, value]() { this->set_timeout("SETTLE", this->delay_.value(), [this, value, is_initial]() {
this->steady_ = true; this->steady_ = true;
this->output(value); this->output(value, is_initial);
}); });
return {}; return {};
} else { } else {
this->steady_ = false; this->steady_ = false;
this->output(value); this->output(value, is_initial);
this->set_timeout("SETTLE", this->delay_.value(), [this]() { this->steady_ = true; }); this->set_timeout("SETTLE", this->delay_.value(), [this]() { this->steady_ = true; });
return value; return value;
} }

View File

@@ -14,11 +14,11 @@ class BinarySensor;
class Filter { class Filter {
public: public:
virtual optional<bool> new_value(bool value) = 0; virtual optional<bool> new_value(bool value, bool is_initial) = 0;
void input(bool value); void input(bool value, bool is_initial);
void output(bool value); void output(bool value, bool is_initial);
protected: protected:
friend BinarySensor; friend BinarySensor;
@@ -30,7 +30,7 @@ class Filter {
class DelayedOnOffFilter : public Filter, public Component { class DelayedOnOffFilter : public Filter, public Component {
public: public:
optional<bool> new_value(bool value) override; optional<bool> new_value(bool value, bool is_initial) override;
float get_setup_priority() const override; float get_setup_priority() const override;
@@ -44,7 +44,7 @@ class DelayedOnOffFilter : public Filter, public Component {
class DelayedOnFilter : public Filter, public Component { class DelayedOnFilter : public Filter, public Component {
public: public:
optional<bool> new_value(bool value) override; optional<bool> new_value(bool value, bool is_initial) override;
float get_setup_priority() const override; float get_setup_priority() const override;
@@ -56,7 +56,7 @@ class DelayedOnFilter : public Filter, public Component {
class DelayedOffFilter : public Filter, public Component { class DelayedOffFilter : public Filter, public Component {
public: public:
optional<bool> new_value(bool value) override; optional<bool> new_value(bool value, bool is_initial) override;
float get_setup_priority() const override; float get_setup_priority() const override;
@@ -68,7 +68,7 @@ class DelayedOffFilter : public Filter, public Component {
class InvertFilter : public Filter { class InvertFilter : public Filter {
public: public:
optional<bool> new_value(bool value) override; optional<bool> new_value(bool value, bool is_initial) override;
}; };
struct AutorepeatFilterTiming { struct AutorepeatFilterTiming {
@@ -86,7 +86,7 @@ class AutorepeatFilter : public Filter, public Component {
public: public:
explicit AutorepeatFilter(std::vector<AutorepeatFilterTiming> timings); explicit AutorepeatFilter(std::vector<AutorepeatFilterTiming> timings);
optional<bool> new_value(bool value) override; optional<bool> new_value(bool value, bool is_initial) override;
float get_setup_priority() const override; float get_setup_priority() const override;
@@ -102,7 +102,7 @@ class LambdaFilter : public Filter {
public: public:
explicit LambdaFilter(std::function<optional<bool>(bool)> f); explicit LambdaFilter(std::function<optional<bool>(bool)> f);
optional<bool> new_value(bool value) override; optional<bool> new_value(bool value, bool is_initial) override;
protected: protected:
std::function<optional<bool>(bool)> f_; std::function<optional<bool>(bool)> f_;
@@ -110,7 +110,7 @@ class LambdaFilter : public Filter {
class SettleFilter : public Filter, public Component { class SettleFilter : public Filter, public Component {
public: public:
optional<bool> new_value(bool value) override; optional<bool> new_value(bool value, bool is_initial) override;
float get_setup_priority() const override; float get_setup_priority() const override;

View File

@@ -196,17 +196,14 @@ void BL0942::received_package_(DataPacket *data) {
} }
void BL0942::dump_config() { // NOLINT(readability-function-cognitive-complexity) void BL0942::dump_config() { // NOLINT(readability-function-cognitive-complexity)
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, "BL0942:");
"BL0942:\n" ESP_LOGCONFIG(TAG, " Reset: %s", TRUEFALSE(this->reset_));
" Reset: %s\n" ESP_LOGCONFIG(TAG, " Address: %d", this->address_);
" Address: %d\n" ESP_LOGCONFIG(TAG, " Nominal line frequency: %d Hz", this->line_freq_);
" Nominal line frequency: %d Hz\n" ESP_LOGCONFIG(TAG, " Current reference: %f", this->current_reference_);
" Current reference: %f\n" ESP_LOGCONFIG(TAG, " Energy reference: %f", this->energy_reference_);
" Energy reference: %f\n" ESP_LOGCONFIG(TAG, " Power reference: %f", this->power_reference_);
" Power reference: %f\n" ESP_LOGCONFIG(TAG, " Voltage reference: %f", this->voltage_reference_);
" Voltage reference: %f",
TRUEFALSE(this->reset_), this->address_, this->line_freq_, this->current_reference_,
this->energy_reference_, this->power_reference_, this->voltage_reference_);
LOG_SENSOR("", "Voltage", this->voltage_sensor_); LOG_SENSOR("", "Voltage", this->voltage_sensor_);
LOG_SENSOR("", "Current", this->current_sensor_); LOG_SENSOR("", "Current", this->current_sensor_);
LOG_SENSOR("", "Power", this->power_sensor_); LOG_SENSOR("", "Power", this->power_sensor_);

View File

@@ -1,8 +1,7 @@
from esphome import automation from esphome import automation
from esphome.automation import maybe_simple_id from esphome.automation import maybe_simple_id
import esphome.codegen as cg import esphome.codegen as cg
from esphome.components import esp32_ble, esp32_ble_client, esp32_ble_tracker from esphome.components import esp32_ble_client, esp32_ble_tracker
from esphome.components.esp32_ble import BTLoggers
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_CHARACTERISTIC_UUID, CONF_CHARACTERISTIC_UUID,
@@ -288,9 +287,6 @@ async def remove_bond_to_code(config, action_id, template_arg, args):
async def to_code(config): async def to_code(config):
# Register the loggers this component needs
esp32_ble.register_bt_logger(BTLoggers.GATT, BTLoggers.SMP)
var = cg.new_Pvariable(config[CONF_ID]) var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config) await cg.register_component(var, config)
await esp32_ble_tracker.register_client(var, config) await esp32_ble_tracker.register_client(var, config)

View File

@@ -10,12 +10,9 @@ static const char *const TAG = "ble_binary_output";
void BLEBinaryOutput::dump_config() { void BLEBinaryOutput::dump_config() {
ESP_LOGCONFIG(TAG, "BLE Binary Output:"); ESP_LOGCONFIG(TAG, "BLE Binary Output:");
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " MAC address : %s", this->parent_->address_str().c_str());
" MAC address : %s\n" ESP_LOGCONFIG(TAG, " Service UUID : %s", this->service_uuid_.to_string().c_str());
" Service UUID : %s\n" ESP_LOGCONFIG(TAG, " Characteristic UUID: %s", this->char_uuid_.to_string().c_str());
" Characteristic UUID: %s",
this->parent_->address_str().c_str(), this->service_uuid_.to_string().c_str(),
this->char_uuid_.to_string().c_str());
LOG_BINARY_OUTPUT(this); LOG_BINARY_OUTPUT(this);
} }

View File

@@ -1,7 +1,7 @@
#include "ble_sensor.h" #include "ble_sensor.h"
#include "esphome/core/log.h"
#include "esphome/core/application.h" #include "esphome/core/application.h"
#include "esphome/core/helpers.h" #include "esphome/core/helpers.h"
#include "esphome/core/log.h"
#include "esphome/components/esp32_ble_tracker/esp32_ble_tracker.h" #include "esphome/components/esp32_ble_tracker/esp32_ble_tracker.h"
#ifdef USE_ESP32 #ifdef USE_ESP32
@@ -15,14 +15,11 @@ void BLESensor::loop() {}
void BLESensor::dump_config() { void BLESensor::dump_config() {
LOG_SENSOR("", "BLE Sensor", this); LOG_SENSOR("", "BLE Sensor", this);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " MAC address : %s", this->parent()->address_str().c_str());
" MAC address : %s\n" ESP_LOGCONFIG(TAG, " Service UUID : %s", this->service_uuid_.to_string().c_str());
" Service UUID : %s\n" ESP_LOGCONFIG(TAG, " Characteristic UUID: %s", this->char_uuid_.to_string().c_str());
" Characteristic UUID: %s\n" ESP_LOGCONFIG(TAG, " Descriptor UUID : %s", this->descr_uuid_.to_string().c_str());
" Descriptor UUID : %s\n" ESP_LOGCONFIG(TAG, " Notifications : %s", YESNO(this->notify_));
" Notifications : %s",
this->parent()->address_str().c_str(), this->service_uuid_.to_string().c_str(),
this->char_uuid_.to_string().c_str(), this->descr_uuid_.to_string().c_str(), YESNO(this->notify_));
LOG_UPDATE_INTERVAL(this); LOG_UPDATE_INTERVAL(this);
} }

View File

@@ -18,14 +18,11 @@ void BLETextSensor::loop() {}
void BLETextSensor::dump_config() { void BLETextSensor::dump_config() {
LOG_TEXT_SENSOR("", "BLE Text Sensor", this); LOG_TEXT_SENSOR("", "BLE Text Sensor", this);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " MAC address : %s", this->parent()->address_str().c_str());
" MAC address : %s\n" ESP_LOGCONFIG(TAG, " Service UUID : %s", this->service_uuid_.to_string().c_str());
" Service UUID : %s\n" ESP_LOGCONFIG(TAG, " Characteristic UUID: %s", this->char_uuid_.to_string().c_str());
" Characteristic UUID: %s\n" ESP_LOGCONFIG(TAG, " Descriptor UUID : %s", this->descr_uuid_.to_string().c_str());
" Descriptor UUID : %s\n" ESP_LOGCONFIG(TAG, " Notifications : %s", YESNO(this->notify_));
" Notifications : %s",
this->parent()->address_str().c_str(), this->service_uuid_.to_string().c_str(),
this->char_uuid_.to_string().c_str(), this->descr_uuid_.to_string().c_str(), YESNO(this->notify_));
LOG_UPDATE_INTERVAL(this); LOG_UPDATE_INTERVAL(this);
} }

View File

@@ -1,7 +1,6 @@
import esphome.codegen as cg import esphome.codegen as cg
from esphome.components import esp32_ble, esp32_ble_client, esp32_ble_tracker from esphome.components import esp32_ble_client, esp32_ble_tracker
from esphome.components.esp32 import add_idf_sdkconfig_option from esphome.components.esp32 import add_idf_sdkconfig_option
from esphome.components.esp32_ble import BTLoggers
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.const import CONF_ACTIVE, CONF_ID from esphome.const import CONF_ACTIVE, CONF_ID
@@ -78,9 +77,6 @@ CONFIG_SCHEMA = cv.All(
async def to_code(config): async def to_code(config):
# Register the loggers this component needs
esp32_ble.register_bt_logger(BTLoggers.GATT, BTLoggers.L2CAP, BTLoggers.SMP)
var = cg.new_Pvariable(config[CONF_ID]) var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config) await cg.register_component(var, config)

View File

@@ -146,11 +146,9 @@ void BluetoothProxy::send_api_packet_(const esp32_ble_tracker::ESPBTDevice &devi
void BluetoothProxy::dump_config() { void BluetoothProxy::dump_config() {
ESP_LOGCONFIG(TAG, "Bluetooth Proxy:"); ESP_LOGCONFIG(TAG, "Bluetooth Proxy:");
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Active: %s", YESNO(this->active_));
" Active: %s\n" ESP_LOGCONFIG(TAG, " Connections: %d", this->connections_.size());
" Connections: %d\n" ESP_LOGCONFIG(TAG, " Raw advertisements: %s", YESNO(this->raw_advertisements_));
" Raw advertisements: %s",
YESNO(this->active_), this->connections_.size(), YESNO(this->raw_advertisements_));
} }
int BluetoothProxy::get_bluetooth_connections_free() { int BluetoothProxy::get_bluetooth_connections_free() {

View File

@@ -1,6 +1,6 @@
#include "bme680_bsec.h" #include "bme680_bsec.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/helpers.h"
#include <string> #include <string>
namespace esphome { namespace esphome {
@@ -159,15 +159,11 @@ void BME680BSECComponent::dump_config() {
this->bme680_status_); this->bme680_status_);
} }
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Temperature Offset: %.2f", this->temperature_offset_);
" Temperature Offset: %.2f\n" ESP_LOGCONFIG(TAG, " IAQ Mode: %s", this->iaq_mode_ == IAQ_MODE_STATIC ? "Static" : "Mobile");
" IAQ Mode: %s\n" ESP_LOGCONFIG(TAG, " Supply Voltage: %sV", this->supply_voltage_ == SUPPLY_VOLTAGE_3V3 ? "3.3" : "1.8");
" Supply Voltage: %sV\n" ESP_LOGCONFIG(TAG, " Sample Rate: %s", BME680_BSEC_SAMPLE_RATE_LOG(this->sample_rate_));
" Sample Rate: %s\n" ESP_LOGCONFIG(TAG, " State Save Interval: %ims", this->state_save_interval_ms_);
" State Save Interval: %ims",
this->temperature_offset_, this->iaq_mode_ == IAQ_MODE_STATIC ? "Static" : "Mobile",
this->supply_voltage_ == SUPPLY_VOLTAGE_3V3 ? "3.3" : "1.8",
BME680_BSEC_SAMPLE_RATE_LOG(this->sample_rate_), this->state_save_interval_ms_);
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_); LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
ESP_LOGCONFIG(TAG, " Sample Rate: %s", BME680_BSEC_SAMPLE_RATE_LOG(this->temperature_sample_rate_)); ESP_LOGCONFIG(TAG, " Sample Rate: %s", BME680_BSEC_SAMPLE_RATE_LOG(this->temperature_sample_rate_));

View File

@@ -58,13 +58,13 @@ void BME68xBSEC2Component::setup() {
} }
void BME68xBSEC2Component::dump_config() { void BME68xBSEC2Component::dump_config() {
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, "BME68X via BSEC2:");
"BME68X via BSEC2:\n"
" BSEC2 version: %d.%d.%d.%d\n" ESP_LOGCONFIG(TAG, " BSEC2 version: %d.%d.%d.%d", this->version_.major, this->version_.minor,
" BSEC2 configuration blob:\n" this->version_.major_bugfix, this->version_.minor_bugfix);
" Configured: %s",
this->version_.major, this->version_.minor, this->version_.major_bugfix, this->version_.minor_bugfix, ESP_LOGCONFIG(TAG, " BSEC2 configuration blob:");
YESNO(this->bsec2_blob_configured_)); ESP_LOGCONFIG(TAG, " Configured: %s", YESNO(this->bsec2_blob_configured_));
if (this->bsec2_configuration_ != nullptr && this->bsec2_configuration_length_) { if (this->bsec2_configuration_ != nullptr && this->bsec2_configuration_length_) {
ESP_LOGCONFIG(TAG, " Size: %" PRIu32, this->bsec2_configuration_length_); ESP_LOGCONFIG(TAG, " Size: %" PRIu32, this->bsec2_configuration_length_);
} }
@@ -77,14 +77,11 @@ void BME68xBSEC2Component::dump_config() {
if (this->algorithm_output_ != ALGORITHM_OUTPUT_IAQ) { if (this->algorithm_output_ != ALGORITHM_OUTPUT_IAQ) {
ESP_LOGCONFIG(TAG, " Algorithm output: %s", BME68X_BSEC2_ALGORITHM_OUTPUT_LOG(this->algorithm_output_)); ESP_LOGCONFIG(TAG, " Algorithm output: %s", BME68X_BSEC2_ALGORITHM_OUTPUT_LOG(this->algorithm_output_));
} }
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Operating age: %s", BME68X_BSEC2_OPERATING_AGE_LOG(this->operating_age_));
" Operating age: %s\n" ESP_LOGCONFIG(TAG, " Sample rate: %s", BME68X_BSEC2_SAMPLE_RATE_LOG(this->sample_rate_));
" Sample rate: %s\n" ESP_LOGCONFIG(TAG, " Voltage: %s", BME68X_BSEC2_VOLTAGE_LOG(this->voltage_));
" Voltage: %s\n" ESP_LOGCONFIG(TAG, " State save interval: %ims", this->state_save_interval_ms_);
" State save interval: %ims\n" ESP_LOGCONFIG(TAG, " Temperature offset: %.2f", this->temperature_offset_);
" 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_);
#ifdef USE_SENSOR #ifdef USE_SENSOR
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_); LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);

View File

@@ -148,10 +148,8 @@ void BMP3XXComponent::setup() {
} }
void BMP3XXComponent::dump_config() { void BMP3XXComponent::dump_config() {
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, "BMP3XX:");
"BMP3XX:\n" ESP_LOGCONFIG(TAG, " Type: %s (0x%X)", LOG_STR_ARG(chip_type_to_str(this->chip_id_.reg)), this->chip_id_.reg);
" Type: %s (0x%X)",
LOG_STR_ARG(chip_type_to_str(this->chip_id_.reg)), this->chip_id_.reg);
switch (this->error_code_) { switch (this->error_code_) {
case NONE: case NONE:
break; break;

View File

@@ -98,20 +98,14 @@ void BMP581Component::dump_config() {
if (this->temperature_sensor_) { if (this->temperature_sensor_) {
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_); LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " IIR Filter: %s", LOG_STR_ARG(iir_filter_to_str(this->iir_temperature_level_)));
" IIR Filter: %s\n" ESP_LOGCONFIG(TAG, " Oversampling: %s", LOG_STR_ARG(oversampling_to_str(this->temperature_oversampling_)));
" Oversampling: %s",
LOG_STR_ARG(iir_filter_to_str(this->iir_temperature_level_)),
LOG_STR_ARG(oversampling_to_str(this->temperature_oversampling_)));
} }
if (this->pressure_sensor_) { if (this->pressure_sensor_) {
LOG_SENSOR(" ", "Pressure", this->pressure_sensor_); LOG_SENSOR(" ", "Pressure", this->pressure_sensor_);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " IIR Filter: %s", LOG_STR_ARG(iir_filter_to_str(this->iir_pressure_level_)));
" IIR Filter: %s\n" ESP_LOGCONFIG(TAG, " Oversampling: %s", LOG_STR_ARG(oversampling_to_str(this->pressure_oversampling_)));
" Oversampling: %s",
LOG_STR_ARG(iir_filter_to_str(this->iir_pressure_level_)),
LOG_STR_ARG(oversampling_to_str(this->pressure_oversampling_)));
} }
} }

View File

@@ -26,10 +26,8 @@ void BP1658CJ::dump_config() {
ESP_LOGCONFIG(TAG, "BP1658CJ:"); ESP_LOGCONFIG(TAG, "BP1658CJ:");
LOG_PIN(" Data Pin: ", this->data_pin_); LOG_PIN(" Data Pin: ", this->data_pin_);
LOG_PIN(" Clock Pin: ", this->clock_pin_); LOG_PIN(" Clock Pin: ", this->clock_pin_);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Color Channels Max Power: %u", this->max_power_color_channels_);
" Color Channels Max Power: %u\n" ESP_LOGCONFIG(TAG, " White Channels Max Power: %u", this->max_power_white_channels_);
" White Channels Max Power: %u",
this->max_power_color_channels_, this->max_power_white_channels_);
} }
void BP1658CJ::loop() { void BP1658CJ::loop() {

View File

@@ -108,7 +108,6 @@ async def register_button(var, config):
if not CORE.has_id(config[CONF_ID]): if not CORE.has_id(config[CONF_ID]):
var = cg.Pvariable(config[CONF_ID], var) var = cg.Pvariable(config[CONF_ID], var)
cg.add(cg.App.register_button(var)) cg.add(cg.App.register_button(var))
CORE.register_platform_component("button", var)
await setup_button_core_(var, config) await setup_button_core_(var, config)

View File

@@ -52,11 +52,9 @@ void CAP1188Component::dump_config() {
ESP_LOGCONFIG(TAG, "CAP1188:"); ESP_LOGCONFIG(TAG, "CAP1188:");
LOG_I2C_DEVICE(this); LOG_I2C_DEVICE(this);
LOG_PIN(" Reset Pin: ", this->reset_pin_); LOG_PIN(" Reset Pin: ", this->reset_pin_);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Product ID: 0x%x", this->cap1188_product_id_);
" Product ID: 0x%x\n" ESP_LOGCONFIG(TAG, " Manufacture ID: 0x%x", this->cap1188_manufacture_id_);
" Manufacture ID: 0x%x\n" ESP_LOGCONFIG(TAG, " Revision ID: 0x%x", this->cap1188_revision_);
" Revision ID: 0x%x",
this->cap1188_product_id_, this->cap1188_manufacture_id_, this->cap1188_revision_);
switch (this->error_code_) { switch (this->error_code_) {
case COMMUNICATION_FAILED: case COMMUNICATION_FAILED:

View File

@@ -1,7 +1,6 @@
#include "ccs811.h" #include "ccs811.h"
#include "esphome/core/hal.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/hal.h"
namespace esphome { namespace esphome {
namespace ccs811 { namespace ccs811 {

View File

@@ -38,11 +38,9 @@ void CHSC6XTouchscreen::dump_config() {
ESP_LOGCONFIG(TAG, "CHSC6X Touchscreen:"); ESP_LOGCONFIG(TAG, "CHSC6X Touchscreen:");
LOG_I2C_DEVICE(this); LOG_I2C_DEVICE(this);
LOG_PIN(" Interrupt Pin: ", this->interrupt_pin_); LOG_PIN(" Interrupt Pin: ", this->interrupt_pin_);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Touch timeout: %d", this->touch_timeout_);
" Touch timeout: %d\n" ESP_LOGCONFIG(TAG, " x_raw_max_: %d", this->x_raw_max_);
" x_raw_max_: %d\n" ESP_LOGCONFIG(TAG, " y_raw_max_: %d", this->y_raw_max_);
" y_raw_max_: %d",
this->touch_timeout_, this->x_raw_max_, this->y_raw_max_);
} }
} // namespace chsc6x } // namespace chsc6x

View File

@@ -443,7 +443,6 @@ async def register_climate(var, config):
if not CORE.has_id(config[CONF_ID]): if not CORE.has_id(config[CONF_ID]):
var = cg.Pvariable(config[CONF_ID], var) var = cg.Pvariable(config[CONF_ID], var)
cg.add(cg.App.register_climate(var)) cg.add(cg.App.register_climate(var))
CORE.register_platform_component("climate", var)
await setup_climate_core_(var, config) await setup_climate_core_(var, config)

View File

@@ -569,22 +569,17 @@ bool Climate::set_custom_preset_(const std::string &preset) {
void Climate::dump_traits_(const char *tag) { void Climate::dump_traits_(const char *tag) {
auto traits = this->get_traits(); auto traits = this->get_traits();
ESP_LOGCONFIG(tag, "ClimateTraits:"); ESP_LOGCONFIG(tag, "ClimateTraits:");
ESP_LOGCONFIG(tag, ESP_LOGCONFIG(tag, " [x] Visual settings:");
" [x] Visual settings:\n" ESP_LOGCONFIG(tag, " - Min temperature: %.1f", traits.get_visual_min_temperature());
" - Min temperature: %.1f\n" ESP_LOGCONFIG(tag, " - Max temperature: %.1f", traits.get_visual_max_temperature());
" - Max temperature: %.1f\n" ESP_LOGCONFIG(tag, " - Temperature step:");
" - Temperature step:\n" ESP_LOGCONFIG(tag, " Target: %.1f", traits.get_visual_target_temperature_step());
" Target: %.1f",
traits.get_visual_min_temperature(), traits.get_visual_max_temperature(),
traits.get_visual_target_temperature_step());
if (traits.get_supports_current_temperature()) { if (traits.get_supports_current_temperature()) {
ESP_LOGCONFIG(tag, " Current: %.1f", traits.get_visual_current_temperature_step()); ESP_LOGCONFIG(tag, " Current: %.1f", traits.get_visual_current_temperature_step());
} }
if (traits.get_supports_target_humidity() || traits.get_supports_current_humidity()) { if (traits.get_supports_target_humidity() || traits.get_supports_current_humidity()) {
ESP_LOGCONFIG(tag, ESP_LOGCONFIG(tag, " - Min humidity: %.0f", traits.get_visual_min_humidity());
" - Min humidity: %.0f\n" ESP_LOGCONFIG(tag, " - Max humidity: %.0f", traits.get_visual_max_humidity());
" - Max humidity: %.0f",
traits.get_visual_min_humidity(), traits.get_visual_max_humidity());
} }
if (traits.get_supports_two_point_target_temperature()) { if (traits.get_supports_two_point_target_temperature()) {
ESP_LOGCONFIG(tag, " [x] Supports two-point target temperature"); ESP_LOGCONFIG(tag, " [x] Supports two-point target temperature");

View File

@@ -3,8 +3,8 @@
#include "esphome/core/component.h" #include "esphome/core/component.h"
#include "esphome/core/entity_base.h" #include "esphome/core/entity_base.h"
#include "esphome/core/helpers.h" #include "esphome/core/helpers.h"
#include "esphome/core/log.h"
#include "esphome/core/preferences.h" #include "esphome/core/preferences.h"
#include "esphome/core/log.h"
#include "climate_mode.h" #include "climate_mode.h"
#include "climate_traits.h" #include "climate_traits.h"

View File

@@ -75,13 +75,10 @@ void ClimateIR::control(const climate::ClimateCall &call) {
} }
void ClimateIR::dump_config() { void ClimateIR::dump_config() {
LOG_CLIMATE("", "IR Climate", this); LOG_CLIMATE("", "IR Climate", this);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Min. Temperature: %.1f°C", this->minimum_temperature_);
" Min. Temperature: %.1f°C\n" ESP_LOGCONFIG(TAG, " Max. Temperature: %.1f°C", this->maximum_temperature_);
" Max. Temperature: %.1f°C\n" ESP_LOGCONFIG(TAG, " Supports HEAT: %s", YESNO(this->supports_heat_));
" Supports HEAT: %s\n" ESP_LOGCONFIG(TAG, " Supports COOL: %s", YESNO(this->supports_cool_));
" Supports COOL: %s",
this->minimum_temperature_, this->maximum_temperature_, YESNO(this->supports_heat_),
YESNO(this->supports_cool_));
} }
} // namespace climate_ir } // namespace climate_ir

View File

@@ -3,5 +3,4 @@
CODEOWNERS = ["@esphome/core"] CODEOWNERS = ["@esphome/core"]
CONF_DRAW_ROUNDING = "draw_rounding" CONF_DRAW_ROUNDING = "draw_rounding"
CONF_ON_STATE_CHANGE = "on_state_change"
CONF_REQUEST_HEADERS = "request_headers" CONF_REQUEST_HEADERS = "request_headers"

View File

@@ -189,7 +189,6 @@ async def register_cover(var, config):
if not CORE.has_id(config[CONF_ID]): if not CORE.has_id(config[CONF_ID]):
var = cg.Pvariable(config[CONF_ID], var) var = cg.Pvariable(config[CONF_ID], var)
cg.add(cg.App.register_cover(var)) cg.add(cg.App.register_cover(var))
CORE.register_platform_component("cover", var)
await setup_cover_core_(var, config) await setup_cover_core_(var, config)

View File

@@ -319,23 +319,18 @@ bool CS5460AComponent::check_status_() {
void CS5460AComponent::dump_config() { void CS5460AComponent::dump_config() {
uint32_t state = this->get_component_state(); uint32_t state = this->get_component_state();
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, "CS5460A:");
"CS5460A:\n" ESP_LOGCONFIG(TAG, " Init status: %s",
" Init status: %s",
state == COMPONENT_STATE_LOOP ? "OK" : (state == COMPONENT_STATE_FAILED ? "failed" : "other")); state == COMPONENT_STATE_LOOP ? "OK" : (state == COMPONENT_STATE_FAILED ? "failed" : "other"));
LOG_PIN(" CS Pin: ", cs_); LOG_PIN(" CS Pin: ", cs_);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Samples / cycle: %" PRIu32, samples_);
" Samples / cycle: %" PRIu32 "\n" ESP_LOGCONFIG(TAG, " Phase offset: %i", phase_offset_);
" Phase offset: %i\n" ESP_LOGCONFIG(TAG, " PGA Gain: %s", pga_gain_ == CS5460A_PGA_GAIN_50X ? "50x" : "10x");
" PGA Gain: %s\n" ESP_LOGCONFIG(TAG, " Current gain: %.5f", current_gain_);
" Current gain: %.5f\n" ESP_LOGCONFIG(TAG, " Voltage gain: %.5f", voltage_gain_);
" Voltage gain: %.5f\n" ESP_LOGCONFIG(TAG, " Current HPF: %s", current_hpf_ ? "enabled" : "disabled");
" Current HPF: %s\n" ESP_LOGCONFIG(TAG, " Voltage HPF: %s", voltage_hpf_ ? "enabled" : "disabled");
" Voltage HPF: %s\n" ESP_LOGCONFIG(TAG, " Pulse energy: %.2f Wh", pulse_energy_wh_);
" Pulse energy: %.2f Wh",
samples_, phase_offset_, pga_gain_ == CS5460A_PGA_GAIN_50X ? "50x" : "10x", current_gain_,
voltage_gain_, current_hpf_ ? "enabled" : "disabled", voltage_hpf_ ? "enabled" : "disabled",
pulse_energy_wh_);
LOG_SENSOR(" ", "Voltage", voltage_sensor_); LOG_SENSOR(" ", "Voltage", voltage_sensor_);
LOG_SENSOR(" ", "Current", current_sensor_); LOG_SENSOR(" ", "Current", current_sensor_);
LOG_SENSOR(" ", "Power", power_sensor_); LOG_SENSOR(" ", "Power", power_sensor_);

View File

@@ -223,6 +223,11 @@ void CSE7766Component::parse_data_() {
#endif #endif
} }
uint32_t CSE7766Component::get_24_bit_uint_(uint8_t start_index) {
return (uint32_t(this->raw_data_[start_index]) << 16) | (uint32_t(this->raw_data_[start_index + 1]) << 8) |
uint32_t(this->raw_data_[start_index + 2]);
}
void CSE7766Component::dump_config() { void CSE7766Component::dump_config() {
ESP_LOGCONFIG(TAG, "CSE7766:"); ESP_LOGCONFIG(TAG, "CSE7766:");
LOG_SENSOR(" ", "Voltage", this->voltage_sensor_); LOG_SENSOR(" ", "Voltage", this->voltage_sensor_);

View File

@@ -1,7 +1,6 @@
#pragma once #pragma once
#include "esphome/core/component.h" #include "esphome/core/component.h"
#include "esphome/core/helpers.h"
#include "esphome/components/sensor/sensor.h" #include "esphome/components/sensor/sensor.h"
#include "esphome/components/uart/uart.h" #include "esphome/components/uart/uart.h"
@@ -29,10 +28,7 @@ class CSE7766Component : public Component, public uart::UARTDevice {
protected: protected:
bool check_byte_(); bool check_byte_();
void parse_data_(); void parse_data_();
uint32_t get_24_bit_uint_(uint8_t start_index) const { uint32_t get_24_bit_uint_(uint8_t start_index);
return encode_uint24(this->raw_data_[start_index], this->raw_data_[start_index + 1],
this->raw_data_[start_index + 2]);
}
uint8_t raw_data_[24]; uint8_t raw_data_[24];
uint8_t raw_data_index_{0}; uint8_t raw_data_index_{0};

View File

@@ -1,5 +1,4 @@
#include "cst816_touchscreen.h" #include "cst816_touchscreen.h"
#include "esphome/core/helpers.h"
namespace esphome { namespace esphome {
namespace cst816 { namespace cst816 {
@@ -75,10 +74,8 @@ void CST816Touchscreen::dump_config() {
LOG_I2C_DEVICE(this); LOG_I2C_DEVICE(this);
LOG_PIN(" Interrupt Pin: ", this->interrupt_pin_); LOG_PIN(" Interrupt Pin: ", this->interrupt_pin_);
LOG_PIN(" Reset Pin: ", this->reset_pin_); LOG_PIN(" Reset Pin: ", this->reset_pin_);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " X Raw Min: %d, X Raw Max: %d", this->x_raw_min_, this->x_raw_max_);
" X Raw Min: %d, X Raw Max: %d\n" ESP_LOGCONFIG(TAG, " Y Raw Min: %d, Y Raw Max: %d", this->y_raw_min_, this->y_raw_max_);
" Y Raw Min: %d, Y Raw Max: %d",
this->x_raw_min_, this->x_raw_max_, this->y_raw_min_, this->y_raw_max_);
const char *name; const char *name;
switch (this->chip_id_) { switch (this->chip_id_) {
case CST820_CHIP_ID: case CST820_CHIP_ID:

View File

@@ -151,10 +151,8 @@ void CurrentBasedCover::dump_config() {
if (this->max_duration_ != UINT32_MAX) { if (this->max_duration_ != UINT32_MAX) {
ESP_LOGCONFIG(TAG, "Maximum duration: %.1fs", this->max_duration_ / 1e3f); ESP_LOGCONFIG(TAG, "Maximum duration: %.1fs", this->max_duration_ / 1e3f);
} }
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, "Start sensing delay: %.1fs", this->start_sensing_delay_ / 1e3f);
"Start sensing delay: %.1fs\n" ESP_LOGCONFIG(TAG, "Malfunction detection: %s", YESNO(this->malfunction_detection_));
"Malfunction detection: %s",
this->start_sensing_delay_ / 1e3f, YESNO(this->malfunction_detection_));
} }
float CurrentBasedCover::get_setup_priority() const { return setup_priority::DATA; } float CurrentBasedCover::get_setup_priority() const { return setup_priority::DATA; }

View File

@@ -1,7 +1,7 @@
#include "dac7678_output.h" #include "dac7678_output.h"
#include "esphome/core/hal.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/helpers.h"
#include "esphome/core/hal.h"
namespace esphome { namespace esphome {
namespace dac7678 { namespace dac7678 {

View File

@@ -1,8 +1,7 @@
#include "daly_bms.h" #include "daly_bms.h"
#include <vector> #include <vector>
#include "esphome/core/application.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/application.h"
namespace esphome { namespace esphome {
namespace daly_bms { namespace daly_bms {

View File

@@ -158,9 +158,7 @@ async def setup_datetime_core_(var, config):
async def register_datetime(var, config): async def register_datetime(var, config):
if not CORE.has_id(config[CONF_ID]): if not CORE.has_id(config[CONF_ID]):
var = cg.Pvariable(config[CONF_ID], var) var = cg.Pvariable(config[CONF_ID], var)
entity_type = config[CONF_TYPE].lower() cg.add(getattr(cg.App, f"register_{config[CONF_TYPE].lower()}")(var))
cg.add(getattr(cg.App, f"register_{entity_type}")(var))
CORE.register_platform_component(entity_type, var)
await setup_datetime_core_(var, config) await setup_datetime_core_(var, config)
cg.add_define(f"USE_DATETIME_{config[CONF_TYPE]}") cg.add_define(f"USE_DATETIME_{config[CONF_TYPE]}")

View File

@@ -2,9 +2,9 @@
#include <algorithm> #include <algorithm>
#include "esphome/core/application.h" #include "esphome/core/application.h"
#include "esphome/core/log.h"
#include "esphome/core/hal.h" #include "esphome/core/hal.h"
#include "esphome/core/helpers.h" #include "esphome/core/helpers.h"
#include "esphome/core/log.h"
#include "esphome/core/version.h" #include "esphome/core/version.h"
#include <cinttypes> #include <cinttypes>
#include <climits> #include <climits>

View File

@@ -2,8 +2,8 @@
#include "esphome/core/component.h" #include "esphome/core/component.h"
#include "esphome/core/defines.h" #include "esphome/core/defines.h"
#include "esphome/core/helpers.h"
#include "esphome/core/macros.h" #include "esphome/core/macros.h"
#include "esphome/core/helpers.h"
#ifdef USE_SENSOR #ifdef USE_SENSOR
#include "esphome/components/sensor/sensor.h" #include "esphome/components/sensor/sensor.h"

View File

@@ -107,10 +107,8 @@ std::string DebugComponent::get_wakeup_cause_() {
} }
void DebugComponent::log_partition_info_() { void DebugComponent::log_partition_info_() {
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, "Partition table:");
"Partition table:\n" ESP_LOGCONFIG(TAG, " %-12s %-4s %-8s %-10s %-10s", "Name", "Type", "Subtype", "Address", "Size");
" %-12s %-4s %-8s %-10s %-10s",
"Name", "Type", "Subtype", "Address", "Size");
esp_partition_iterator_t it = esp_partition_find(ESP_PARTITION_TYPE_ANY, ESP_PARTITION_SUBTYPE_ANY, NULL); esp_partition_iterator_t it = esp_partition_find(ESP_PARTITION_TYPE_ANY, ESP_PARTITION_SUBTYPE_ANY, NULL);
while (it != NULL) { while (it != NULL) {
const esp_partition_t *partition = esp_partition_get(it); const esp_partition_t *partition = esp_partition_get(it);

View File

@@ -6,8 +6,6 @@ namespace esphome {
namespace deep_sleep { namespace deep_sleep {
static const char *const TAG = "deep_sleep"; static const char *const TAG = "deep_sleep";
// 5 seconds for deep sleep to ensure clean disconnect from Home Assistant
static const uint32_t TEARDOWN_TIMEOUT_DEEP_SLEEP_MS = 5000;
bool global_has_deep_sleep = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) bool global_has_deep_sleep = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
@@ -64,10 +62,6 @@ void DeepSleepComponent::begin_sleep(bool manual) {
ESP_LOGI(TAG, "Sleeping for %" PRId64 "us", *this->sleep_duration_); ESP_LOGI(TAG, "Sleeping for %" PRId64 "us", *this->sleep_duration_);
} }
App.run_safe_shutdown_hooks(); App.run_safe_shutdown_hooks();
// It's critical to teardown components cleanly for deep sleep to ensure
// Home Assistant sees a clean disconnect instead of marking the device unavailable
App.teardown_components(TEARDOWN_TIMEOUT_DEEP_SLEEP_MS);
App.run_powerdown_hooks();
this->deep_sleep_(); this->deep_sleep_();
} }

View File

@@ -46,12 +46,10 @@ void DeepSleepComponent::dump_config_platform_() {
LOG_PIN(" Wakeup Pin: ", this->wakeup_pin_); LOG_PIN(" Wakeup Pin: ", this->wakeup_pin_);
} }
if (this->wakeup_cause_to_run_duration_.has_value()) { if (this->wakeup_cause_to_run_duration_.has_value()) {
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Default Wakeup Run Duration: %" PRIu32 " ms",
" Default Wakeup Run Duration: %" PRIu32 " ms\n" this->wakeup_cause_to_run_duration_->default_cause);
" Touch Wakeup Run Duration: %" PRIu32 " ms\n" ESP_LOGCONFIG(TAG, " Touch Wakeup Run Duration: %" PRIu32 " ms", this->wakeup_cause_to_run_duration_->touch_cause);
" GPIO Wakeup Run Duration: %" PRIu32 " ms", ESP_LOGCONFIG(TAG, " GPIO Wakeup Run Duration: %" PRIu32 " ms", this->wakeup_cause_to_run_duration_->gpio_cause);
this->wakeup_cause_to_run_duration_->default_cause, this->wakeup_cause_to_run_duration_->touch_cause,
this->wakeup_cause_to_run_duration_->gpio_cause);
} }
} }

View File

@@ -1,6 +1,6 @@
#include "dht.h" #include "dht.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/helpers.h"
namespace esphome { namespace esphome {
namespace dht { namespace dht {

View File

@@ -182,11 +182,9 @@ using display_writer_t = std::function<void(Display &)>;
#define LOG_DISPLAY(prefix, type, obj) \ #define LOG_DISPLAY(prefix, type, obj) \
if ((obj) != nullptr) { \ if ((obj) != nullptr) { \
ESP_LOGCONFIG(TAG, \ ESP_LOGCONFIG(TAG, prefix type); \
prefix type "\n" \ ESP_LOGCONFIG(TAG, "%s Rotations: %d °", prefix, (obj)->rotation_); \
"%s Rotations: %d °\n" \ ESP_LOGCONFIG(TAG, "%s Dimensions: %dpx x %dpx", prefix, (obj)->get_width(), (obj)->get_height()); \
"%s Dimensions: %dpx x %dpx", \
prefix, (obj)->rotation_, prefix, (obj)->get_width(), (obj)->get_height()); \
} }
/// Turn the pixel OFF. /// Turn the pixel OFF.

View File

@@ -86,11 +86,9 @@ void DPS310Component::setup() {
} }
void DPS310Component::dump_config() { void DPS310Component::dump_config() {
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, "DPS310:");
"DPS310:\n" ESP_LOGCONFIG(TAG, " Product ID: %u", this->prod_rev_id_ & 0x0F);
" Product ID: %u\n" ESP_LOGCONFIG(TAG, " Revision ID: %u", (this->prod_rev_id_ >> 4) & 0x0F);
" Revision ID: %u",
this->prod_rev_id_ & 0x0F, (this->prod_rev_id_ >> 4) & 0x0F);
LOG_I2C_DEVICE(this); LOG_I2C_DEVICE(this);
if (this->is_failed()) { if (this->is_failed()) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL); ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);

View File

@@ -278,11 +278,9 @@ bool Dsmr::parse_telegram() {
} }
void Dsmr::dump_config() { void Dsmr::dump_config() {
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, "DSMR:");
"DSMR:\n" ESP_LOGCONFIG(TAG, " Max telegram length: %d", this->max_telegram_len_);
" Max telegram length: %d\n" ESP_LOGCONFIG(TAG, " Receive timeout: %.1fs", this->receive_timeout_ / 1e3f);
" Receive timeout: %.1fs",
this->max_telegram_len_, this->receive_timeout_ / 1e3f);
if (this->request_pin_ != nullptr) { if (this->request_pin_ != nullptr) {
LOG_PIN(" Request Pin: ", this->request_pin_); LOG_PIN(" Request Pin: ", this->request_pin_);
} }

View File

@@ -1,6 +1,6 @@
#include "duty_cycle_sensor.h" #include "duty_cycle_sensor.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/helpers.h"
namespace esphome { namespace esphome {
namespace duty_cycle { namespace duty_cycle {

View File

@@ -94,11 +94,9 @@ void DutyTimeSensor::publish_and_save_(const uint32_t sec, const uint32_t ms) {
} }
void DutyTimeSensor::dump_config() { void DutyTimeSensor::dump_config() {
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, "Duty Time:");
"Duty Time:\n" ESP_LOGCONFIG(TAG, " Update Interval: %" PRId32 "ms", this->get_update_interval());
" Update Interval: %" PRId32 "ms\n" ESP_LOGCONFIG(TAG, " Restore: %s", ONOFF(this->restore_));
" Restore: %s",
this->get_update_interval(), ONOFF(this->restore_));
LOG_SENSOR(" ", "Duty Time Sensor:", this); LOG_SENSOR(" ", "Duty Time Sensor:", this);
LOG_SENSOR(" ", "Last Duty Time Sensor:", this->last_duty_time_sensor_); LOG_SENSOR(" ", "Last Duty Time Sensor:", this->last_duty_time_sensor_);
} }

View File

@@ -1,6 +1,6 @@
#include "ee895.h" #include "ee895.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/helpers.h"
namespace esphome { namespace esphome {
namespace ee895 { namespace ee895 {

View File

@@ -100,10 +100,8 @@ void Emc2101Component::dump_config() {
if (this->dac_mode_) { if (this->dac_mode_) {
ESP_LOGCONFIG(TAG, " DAC Conversion Rate: %X", this->dac_conversion_rate_); ESP_LOGCONFIG(TAG, " DAC Conversion Rate: %X", this->dac_conversion_rate_);
} else { } else {
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " PWM Resolution: %02X", this->pwm_resolution_);
" PWM Resolution: %02X\n" ESP_LOGCONFIG(TAG, " PWM Divider: %02X", this->pwm_divider_);
" PWM Divider: %02X",
this->pwm_resolution_, this->pwm_divider_);
} }
ESP_LOGCONFIG(TAG, " Inverted: %s", YESNO(this->inverted_)); ESP_LOGCONFIG(TAG, " Inverted: %s", YESNO(this->inverted_));
} }

View File

@@ -25,11 +25,9 @@ static const size_t MCLK_DIV_FRE = 256;
} }
void ES7210::dump_config() { void ES7210::dump_config() {
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, "ES7210 audio ADC:");
"ES7210 audio ADC:\n" ESP_LOGCONFIG(TAG, " Bits Per Sample: %" PRIu8, this->bits_per_sample_);
" Bits Per Sample: %" PRIu8 "\n" ESP_LOGCONFIG(TAG, " Sample Rate: %" PRIu32, this->sample_rate_);
" Sample Rate: %" PRIu32,
this->bits_per_sample_, this->sample_rate_);
if (this->is_failed()) { if (this->is_failed()) {
ESP_LOGE(TAG, " Failed to initialize"); ESP_LOGE(TAG, " Failed to initialize");

View File

@@ -52,13 +52,11 @@ void ES8311::setup() {
} }
void ES8311::dump_config() { void ES8311::dump_config() {
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, "ES8311 Audio Codec:");
"ES8311 Audio Codec:\n" ESP_LOGCONFIG(TAG, " Use MCLK: %s", YESNO(this->use_mclk_));
" Use MCLK: %s\n" ESP_LOGCONFIG(TAG, " Use Microphone: %s", YESNO(this->use_mic_));
" Use Microphone: %s\n" ESP_LOGCONFIG(TAG, " DAC Bits per Sample: %" PRIu8, this->resolution_out_);
" DAC Bits per Sample: %" PRIu8 "\n" ESP_LOGCONFIG(TAG, " Sample Rate: %" PRIu32, this->sample_frequency_);
" Sample Rate: %" PRIu32,
YESNO(this->use_mclk_), YESNO(this->use_mic_), this->resolution_out_, this->sample_frequency_);
if (this->is_failed()) { if (this->is_failed()) {
ESP_LOGCONFIG(TAG, " Failed to initialize!"); ESP_LOGCONFIG(TAG, " Failed to initialize!");

View File

@@ -71,28 +71,12 @@ from .const import ( # noqa
from .gpio import esp32_pin_to_code # noqa from .gpio import esp32_pin_to_code # noqa
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
AUTO_LOAD = ["preferences"]
CODEOWNERS = ["@esphome/core"] CODEOWNERS = ["@esphome/core"]
AUTO_LOAD = ["preferences"]
IS_TARGET_PLATFORM = True IS_TARGET_PLATFORM = True
CONF_ASSERTION_LEVEL = "assertion_level"
CONF_COMPILER_OPTIMIZATION = "compiler_optimization"
CONF_ENABLE_IDF_EXPERIMENTAL_FEATURES = "enable_idf_experimental_features"
CONF_ENABLE_LWIP_ASSERT = "enable_lwip_assert"
CONF_RELEASE = "release" CONF_RELEASE = "release"
CONF_ENABLE_IDF_EXPERIMENTAL_FEATURES = "enable_idf_experimental_features"
ASSERTION_LEVELS = {
"DISABLE": "CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE",
"ENABLE": "CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE",
"SILENT": "CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT",
}
COMPILER_OPTIMIZATIONS = {
"DEBUG": "CONFIG_COMPILER_OPTIMIZATION_DEBUG",
"NONE": "CONFIG_COMPILER_OPTIMIZATION_NONE",
"PERF": "CONFIG_COMPILER_OPTIMIZATION_PERF",
"SIZE": "CONFIG_COMPILER_OPTIMIZATION_SIZE",
}
def get_cpu_frequencies(*frequencies): def get_cpu_frequencies(*frequencies):
@@ -467,8 +451,8 @@ def _parse_platform_version(value):
if ver.major >= 50: # a pioarduino version if ver.major >= 50: # a pioarduino version
if "-" in value: if "-" in value:
# maybe a release candidate?...definitely not our default, just use it as-is... # maybe a release candidate?...definitely not our default, just use it as-is...
return f"https://github.com/pioarduino/platform-espressif32/releases/download/{value}/platform-espressif32.zip" return f"https://github.com/pioarduino/platform-espressif32.git#{value}"
return f"https://github.com/pioarduino/platform-espressif32/releases/download/{ver.major}.{ver.minor:02d}.{ver.patch:02d}/platform-espressif32.zip" return f"https://github.com/pioarduino/platform-espressif32.git#{ver.major}.{ver.minor:02d}.{ver.patch:02d}"
# if platform version is a valid version constraint, prefix the default package # if platform version is a valid version constraint, prefix the default package
cv.platformio_version_constraint(value) cv.platformio_version_constraint(value)
return f"platformio/espressif32@{value}" return f"platformio/espressif32@{value}"
@@ -558,10 +542,6 @@ ARDUINO_FRAMEWORK_SCHEMA = cv.All(
) )
CONF_SDKCONFIG_OPTIONS = "sdkconfig_options" CONF_SDKCONFIG_OPTIONS = "sdkconfig_options"
CONF_ENABLE_LWIP_DHCP_SERVER = "enable_lwip_dhcp_server"
CONF_ENABLE_LWIP_MDNS_QUERIES = "enable_lwip_mdns_queries"
CONF_ENABLE_LWIP_BRIDGE_INTERFACE = "enable_lwip_bridge_interface"
ESP_IDF_FRAMEWORK_SCHEMA = cv.All( ESP_IDF_FRAMEWORK_SCHEMA = cv.All(
cv.Schema( cv.Schema(
{ {
@@ -574,30 +554,11 @@ ESP_IDF_FRAMEWORK_SCHEMA = cv.All(
}, },
cv.Optional(CONF_ADVANCED, default={}): cv.Schema( cv.Optional(CONF_ADVANCED, default={}): cv.Schema(
{ {
cv.Optional(CONF_ASSERTION_LEVEL): cv.one_of(
*ASSERTION_LEVELS, upper=True
),
cv.Optional(CONF_COMPILER_OPTIMIZATION, default="SIZE"): cv.one_of(
*COMPILER_OPTIMIZATIONS, upper=True
),
cv.Optional(CONF_ENABLE_IDF_EXPERIMENTAL_FEATURES): cv.boolean,
cv.Optional(CONF_ENABLE_LWIP_ASSERT, default=True): cv.boolean,
cv.Optional( cv.Optional(
CONF_IGNORE_EFUSE_CUSTOM_MAC, default=False CONF_IGNORE_EFUSE_CUSTOM_MAC, default=False
): cv.boolean, ): cv.boolean,
cv.Optional(CONF_IGNORE_EFUSE_MAC_CRC): cv.boolean, cv.Optional(CONF_IGNORE_EFUSE_MAC_CRC): cv.boolean,
# DHCP server is needed for WiFi AP mode. When WiFi component is used, cv.Optional(CONF_ENABLE_IDF_EXPERIMENTAL_FEATURES): cv.boolean,
# it will handle disabling DHCP server when AP is not configured.
# Default to false (disabled) when WiFi is not used.
cv.OnlyWithout(
CONF_ENABLE_LWIP_DHCP_SERVER, "wifi", default=False
): cv.boolean,
cv.Optional(
CONF_ENABLE_LWIP_MDNS_QUERIES, default=False
): cv.boolean,
cv.Optional(
CONF_ENABLE_LWIP_BRIDGE_INTERFACE, default=False
): cv.boolean,
} }
), ),
cv.Optional(CONF_COMPONENTS, default=[]): cv.ensure_list( cv.Optional(CONF_COMPONENTS, default=[]): cv.ensure_list(
@@ -680,7 +641,7 @@ async def to_code(config):
conf = config[CONF_FRAMEWORK] conf = config[CONF_FRAMEWORK]
cg.add_platformio_option("platform", conf[CONF_PLATFORM_VERSION]) cg.add_platformio_option("platform", conf[CONF_PLATFORM_VERSION])
if conf[CONF_ADVANCED][CONF_IGNORE_EFUSE_CUSTOM_MAC]: if CONF_ADVANCED in conf and conf[CONF_ADVANCED][CONF_IGNORE_EFUSE_CUSTOM_MAC]:
cg.add_define("USE_ESP32_IGNORE_EFUSE_CUSTOM_MAC") cg.add_define("USE_ESP32_IGNORE_EFUSE_CUSTOM_MAC")
add_extra_script( add_extra_script(
@@ -711,6 +672,8 @@ async def to_code(config):
add_idf_sdkconfig_option( add_idf_sdkconfig_option(
"CONFIG_PARTITION_TABLE_CUSTOM_FILENAME", "partitions.csv" "CONFIG_PARTITION_TABLE_CUSTOM_FILENAME", "partitions.csv"
) )
add_idf_sdkconfig_option("CONFIG_COMPILER_OPTIMIZATION_DEFAULT", False)
add_idf_sdkconfig_option("CONFIG_COMPILER_OPTIMIZATION_SIZE", True)
# Increase freertos tick speed from 100Hz to 1kHz so that delay() resolution is 1ms # Increase freertos tick speed from 100Hz to 1kHz so that delay() resolution is 1ms
add_idf_sdkconfig_option("CONFIG_FREERTOS_HZ", 1000) add_idf_sdkconfig_option("CONFIG_FREERTOS_HZ", 1000)
@@ -724,41 +687,16 @@ async def to_code(config):
# Set default CPU frequency # Set default CPU frequency
add_idf_sdkconfig_option(f"CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_{freq}", True) add_idf_sdkconfig_option(f"CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_{freq}", True)
# Apply LWIP optimization settings
advanced = conf[CONF_ADVANCED]
# DHCP server: only disable if explicitly set to false
# WiFi component handles its own optimization when AP mode is not used
if (
CONF_ENABLE_LWIP_DHCP_SERVER in advanced
and not advanced[CONF_ENABLE_LWIP_DHCP_SERVER]
):
add_idf_sdkconfig_option("CONFIG_LWIP_DHCPS", False)
if not advanced.get(CONF_ENABLE_LWIP_MDNS_QUERIES, False):
add_idf_sdkconfig_option("CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES", False)
if not advanced.get(CONF_ENABLE_LWIP_BRIDGE_INTERFACE, False):
add_idf_sdkconfig_option("CONFIG_LWIP_BRIDGEIF_MAX_PORTS", 0)
cg.add_platformio_option("board_build.partitions", "partitions.csv") cg.add_platformio_option("board_build.partitions", "partitions.csv")
if CONF_PARTITIONS in config: if CONF_PARTITIONS in config:
add_extra_build_file( add_extra_build_file(
"partitions.csv", CORE.relative_config_path(config[CONF_PARTITIONS]) "partitions.csv", CORE.relative_config_path(config[CONF_PARTITIONS])
) )
if assertion_level := advanced.get(CONF_ASSERTION_LEVEL): for name, value in conf[CONF_SDKCONFIG_OPTIONS].items():
for key, flag in ASSERTION_LEVELS.items(): add_idf_sdkconfig_option(name, RawSdkconfigValue(value))
add_idf_sdkconfig_option(flag, assertion_level == key)
add_idf_sdkconfig_option("CONFIG_COMPILER_OPTIMIZATION_DEFAULT", False) if conf[CONF_ADVANCED].get(CONF_IGNORE_EFUSE_MAC_CRC):
compiler_optimization = advanced.get(CONF_COMPILER_OPTIMIZATION)
for key, flag in COMPILER_OPTIMIZATIONS.items():
add_idf_sdkconfig_option(flag, compiler_optimization == key)
add_idf_sdkconfig_option(
"CONFIG_LWIP_ESP_LWIP_ASSERT",
conf[CONF_ADVANCED][CONF_ENABLE_LWIP_ASSERT],
)
if advanced.get(CONF_IGNORE_EFUSE_MAC_CRC):
add_idf_sdkconfig_option("CONFIG_ESP_MAC_IGNORE_MAC_CRC_ERROR", True) add_idf_sdkconfig_option("CONFIG_ESP_MAC_IGNORE_MAC_CRC_ERROR", True)
if (framework_ver.major, framework_ver.minor) >= (4, 4): if (framework_ver.major, framework_ver.minor) >= (4, 4):
add_idf_sdkconfig_option( add_idf_sdkconfig_option(
@@ -768,7 +706,7 @@ async def to_code(config):
add_idf_sdkconfig_option( add_idf_sdkconfig_option(
"CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE", False "CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE", False
) )
if advanced.get(CONF_ENABLE_IDF_EXPERIMENTAL_FEATURES): if conf[CONF_ADVANCED].get(CONF_ENABLE_IDF_EXPERIMENTAL_FEATURES):
_LOGGER.warning( _LOGGER.warning(
"Using experimental features in ESP-IDF may result in unexpected failures." "Using experimental features in ESP-IDF may result in unexpected failures."
) )
@@ -781,9 +719,6 @@ async def to_code(config):
), ),
) )
for name, value in conf[CONF_SDKCONFIG_OPTIONS].items():
add_idf_sdkconfig_option(name, RawSdkconfigValue(value))
for component in conf[CONF_COMPONENTS]: for component in conf[CONF_COMPONENTS]:
source = component[CONF_SOURCE] source = component[CONF_SOURCE]
if source[CONF_TYPE] == TYPE_GIT: if source[CONF_TYPE] == TYPE_GIT:

View File

@@ -1,8 +1,8 @@
#ifdef USE_ESP32 #ifdef USE_ESP32
#include "esphome/core/preferences.h"
#include "esphome/core/helpers.h" #include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/preferences.h"
#include <nvs_flash.h> #include <nvs_flash.h>
#include <cstring> #include <cstring>
#include <cinttypes> #include <cinttypes>

View File

@@ -1,4 +1,3 @@
from enum import Enum
import re import re
from esphome import automation from esphome import automation
@@ -13,110 +12,9 @@ import esphome.final_validate as fv
DEPENDENCIES = ["esp32"] DEPENDENCIES = ["esp32"]
CODEOWNERS = ["@jesserockz", "@Rapsssito"] CODEOWNERS = ["@jesserockz", "@Rapsssito"]
class BTLoggers(Enum):
"""Bluetooth logger categories available in ESP-IDF.
Each logger controls debug output for a specific Bluetooth subsystem.
The value is the ESP-IDF sdkconfig option name for controlling the log level.
"""
# Core Stack Layers
HCI = "CONFIG_BT_LOG_HCI_TRACE_LEVEL"
"""Host Controller Interface - Low-level interface between host and controller"""
BTM = "CONFIG_BT_LOG_BTM_TRACE_LEVEL"
"""Bluetooth Manager - Core device control, connections, and security"""
L2CAP = "CONFIG_BT_LOG_L2CAP_TRACE_LEVEL"
"""Logical Link Control and Adaptation Protocol - Connection multiplexing"""
RFCOMM = "CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL"
"""Serial port emulation over Bluetooth (Classic only)"""
SDP = "CONFIG_BT_LOG_SDP_TRACE_LEVEL"
"""Service Discovery Protocol - Service discovery (Classic only)"""
GAP = "CONFIG_BT_LOG_GAP_TRACE_LEVEL"
"""Generic Access Profile - Device discovery and connections"""
# Network Protocols
BNEP = "CONFIG_BT_LOG_BNEP_TRACE_LEVEL"
"""Bluetooth Network Encapsulation Protocol - IP over Bluetooth"""
PAN = "CONFIG_BT_LOG_PAN_TRACE_LEVEL"
"""Personal Area Networking - Ethernet over Bluetooth"""
# Audio/Video Profiles (Classic Bluetooth)
A2D = "CONFIG_BT_LOG_A2D_TRACE_LEVEL"
"""Advanced Audio Distribution - A2DP audio streaming"""
AVDT = "CONFIG_BT_LOG_AVDT_TRACE_LEVEL"
"""Audio/Video Distribution Transport - A2DP transport protocol"""
AVCT = "CONFIG_BT_LOG_AVCT_TRACE_LEVEL"
"""Audio/Video Control Transport - AVRCP transport protocol"""
AVRC = "CONFIG_BT_LOG_AVRC_TRACE_LEVEL"
"""Audio/Video Remote Control - Media playback control"""
# Security
SMP = "CONFIG_BT_LOG_SMP_TRACE_LEVEL"
"""Security Manager Protocol - BLE pairing and encryption"""
# Application Layer
BTIF = "CONFIG_BT_LOG_BTIF_TRACE_LEVEL"
"""Bluetooth Interface - Application interface layer"""
BTC = "CONFIG_BT_LOG_BTC_TRACE_LEVEL"
"""Bluetooth Common - Task handling and coordination"""
# BLE Specific
BLE_SCAN = "CONFIG_BT_LOG_BLE_SCAN_TRACE_LEVEL"
"""BLE scanning operations"""
GATT = "CONFIG_BT_LOG_GATT_TRACE_LEVEL"
"""Generic Attribute Profile - BLE data exchange protocol"""
# Other Profiles
MCA = "CONFIG_BT_LOG_MCA_TRACE_LEVEL"
"""Multi-Channel Adaptation - Health device profile"""
HID = "CONFIG_BT_LOG_HID_TRACE_LEVEL"
"""Human Interface Device - Keyboards, mice, controllers"""
APPL = "CONFIG_BT_LOG_APPL_TRACE_LEVEL"
"""Application layer logging"""
OSI = "CONFIG_BT_LOG_OSI_TRACE_LEVEL"
"""OS abstraction layer - Threading, memory, timers"""
BLUFI = "CONFIG_BT_LOG_BLUFI_TRACE_LEVEL"
"""ESP32 WiFi provisioning over Bluetooth"""
# Set to track which loggers are needed by components
_required_loggers: set[BTLoggers] = set()
def register_bt_logger(*loggers: BTLoggers) -> None:
"""Register Bluetooth logger categories that a component needs.
Args:
*loggers: One or more BTLoggers enum members
"""
for logger in loggers:
if not isinstance(logger, BTLoggers):
raise TypeError(
f"Logger must be a BTLoggers enum member, got {type(logger)}"
)
_required_loggers.add(logger)
CONF_BLE_ID = "ble_id" CONF_BLE_ID = "ble_id"
CONF_IO_CAPABILITY = "io_capability" CONF_IO_CAPABILITY = "io_capability"
CONF_ADVERTISING_CYCLE_TIME = "advertising_cycle_time" CONF_ADVERTISING_CYCLE_TIME = "advertising_cycle_time"
CONF_DISABLE_BT_LOGS = "disable_bt_logs"
NO_BLUETOOTH_VARIANTS = [const.VARIANT_ESP32S2] NO_BLUETOOTH_VARIANTS = [const.VARIANT_ESP32S2]
@@ -164,9 +62,6 @@ CONFIG_SCHEMA = cv.Schema(
cv.Optional( cv.Optional(
CONF_ADVERTISING_CYCLE_TIME, default="10s" CONF_ADVERTISING_CYCLE_TIME, default="10s"
): cv.positive_time_period_milliseconds, ): cv.positive_time_period_milliseconds,
cv.SplitDefault(CONF_DISABLE_BT_LOGS, esp32_idf=True): cv.All(
cv.only_with_esp_idf, cv.boolean
),
} }
).extend(cv.COMPONENT_SCHEMA) ).extend(cv.COMPONENT_SCHEMA)
@@ -245,16 +140,6 @@ async def to_code(config):
add_idf_sdkconfig_option("CONFIG_BT_ENABLED", True) add_idf_sdkconfig_option("CONFIG_BT_ENABLED", True)
add_idf_sdkconfig_option("CONFIG_BT_BLE_42_FEATURES_SUPPORTED", True) add_idf_sdkconfig_option("CONFIG_BT_BLE_42_FEATURES_SUPPORTED", True)
# Register the core BLE loggers that are always needed
register_bt_logger(BTLoggers.GAP, BTLoggers.BTM, BTLoggers.HCI)
# Apply logger settings if log disabling is enabled
if config.get(CONF_DISABLE_BT_LOGS, False):
# Disable all Bluetooth loggers that are not required
for logger in BTLoggers:
if logger not in _required_loggers:
add_idf_sdkconfig_option(f"{logger.value}_NONE", True)
cg.add_define("USE_ESP32_BLE") cg.add_define("USE_ESP32_BLE")

View File

@@ -408,12 +408,10 @@ void ESP32BLE::dump_config() {
io_capability_s = "invalid"; io_capability_s = "invalid";
break; break;
} }
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, "ESP32 BLE:");
"ESP32 BLE:\n" ESP_LOGCONFIG(TAG, " MAC address: %02X:%02X:%02X:%02X:%02X:%02X", mac_address[0], mac_address[1], mac_address[2],
" MAC address: %02X:%02X:%02X:%02X:%02X:%02X\n" mac_address[3], mac_address[4], mac_address[5]);
" IO Capability: %s", ESP_LOGCONFIG(TAG, " IO Capability: %s", io_capability_s);
mac_address[0], mac_address[1], mac_address[2], mac_address[3], mac_address[4], mac_address[5],
io_capability_s);
} else { } else {
ESP_LOGCONFIG(TAG, "ESP32 BLE: bluetooth stack is not enabled"); ESP_LOGCONFIG(TAG, "ESP32 BLE: bluetooth stack is not enabled");
} }

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#include "esphome/core/hal.h"
#include "esphome/core/helpers.h" #include "esphome/core/helpers.h"
#include "esphome/core/hal.h"
#ifdef USE_ESP32 #ifdef USE_ESP32

View File

@@ -45,10 +45,8 @@ void BLEClientBase::loop() {
float BLEClientBase::get_setup_priority() const { return setup_priority::AFTER_BLUETOOTH; } float BLEClientBase::get_setup_priority() const { return setup_priority::AFTER_BLUETOOTH; }
void BLEClientBase::dump_config() { void BLEClientBase::dump_config() {
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Address: %s", this->address_str().c_str());
" Address: %s\n" ESP_LOGCONFIG(TAG, " Auto-Connect: %s", TRUEFALSE(this->auto_connect_));
" Auto-Connect: %s",
this->address_str().c_str(), TRUEFALSE(this->auto_connect_));
std::string state_name; std::string state_name;
switch (this->state()) { switch (this->state()) {
case espbt::ClientState::INIT: case espbt::ClientState::INIT:

View File

@@ -4,7 +4,7 @@ from esphome import automation
import esphome.codegen as cg import esphome.codegen as cg
from esphome.components import esp32_ble from esphome.components import esp32_ble
from esphome.components.esp32 import add_idf_sdkconfig_option from esphome.components.esp32 import add_idf_sdkconfig_option
from esphome.components.esp32_ble import BTLoggers, bt_uuid from esphome.components.esp32_ble import bt_uuid
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.config_validation import UNDEFINED from esphome.config_validation import UNDEFINED
from esphome.const import ( from esphome.const import (
@@ -525,9 +525,6 @@ async def to_code_characteristic(service_var, char_conf):
async def to_code(config): async def to_code(config):
# Register the loggers this component needs
esp32_ble.register_bt_logger(BTLoggers.GATT, BTLoggers.SMP)
var = cg.new_Pvariable(config[CONF_ID]) var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config) await cg.register_component(var, config)

View File

@@ -2,7 +2,6 @@
#include "ble_server.h" #include "ble_server.h"
#include "ble_service.h" #include "ble_service.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#ifdef USE_ESP32 #ifdef USE_ESP32

View File

@@ -43,6 +43,7 @@ class BLEServer : public Component,
float get_setup_priority() const override; float get_setup_priority() const override;
bool can_proceed() override; bool can_proceed() override;
void teardown();
bool is_running(); bool is_running();
void set_manufacturer_data(const std::vector<uint8_t> &data) { void set_manufacturer_data(const std::vector<uint8_t> &data) {

View File

@@ -9,7 +9,6 @@ import esphome.codegen as cg
from esphome.components import esp32_ble from esphome.components import esp32_ble
from esphome.components.esp32 import add_idf_sdkconfig_option from esphome.components.esp32 import add_idf_sdkconfig_option
from esphome.components.esp32_ble import ( from esphome.components.esp32_ble import (
BTLoggers,
bt_uuid, bt_uuid,
bt_uuid16_format, bt_uuid16_format,
bt_uuid32_format, bt_uuid32_format,
@@ -260,9 +259,6 @@ ESP_BLE_DEVICE_SCHEMA = cv.Schema(
async def to_code(config): async def to_code(config):
# Register the loggers this component needs
esp32_ble.register_bt_logger(BTLoggers.BLE_SCAN)
var = cg.new_Pvariable(config[CONF_ID]) var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config) await cg.register_component(var, config)

View File

@@ -731,14 +731,11 @@ uint64_t ESPBTDevice::address_uint64() const { return esp32_ble::ble_addr_to_uin
void ESP32BLETracker::dump_config() { void ESP32BLETracker::dump_config() {
ESP_LOGCONFIG(TAG, "BLE Tracker:"); ESP_LOGCONFIG(TAG, "BLE Tracker:");
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Scan Duration: %" PRIu32 " s", this->scan_duration_);
" Scan Duration: %" PRIu32 " s\n" ESP_LOGCONFIG(TAG, " Scan Interval: %.1f ms", this->scan_interval_ * 0.625f);
" Scan Interval: %.1f ms\n" ESP_LOGCONFIG(TAG, " Scan Window: %.1f ms", this->scan_window_ * 0.625f);
" Scan Window: %.1f ms\n" ESP_LOGCONFIG(TAG, " Scan Type: %s", this->scan_active_ ? "ACTIVE" : "PASSIVE");
" Scan Type: %s\n" ESP_LOGCONFIG(TAG, " Continuous Scanning: %s", YESNO(this->scan_continuous_));
" Continuous Scanning: %s",
this->scan_duration_, this->scan_interval_ * 0.625f, this->scan_window_ * 0.625f,
this->scan_active_ ? "ACTIVE" : "PASSIVE", YESNO(this->scan_continuous_));
switch (this->scanner_state_) { switch (this->scanner_state_) {
case ScannerState::IDLE: case ScannerState::IDLE:
ESP_LOGCONFIG(TAG, " Scanner State: IDLE"); ESP_LOGCONFIG(TAG, " Scanner State: IDLE");

View File

@@ -46,20 +46,17 @@ void ESP32Camera::setup() {
void ESP32Camera::dump_config() { void ESP32Camera::dump_config() {
auto conf = this->config_; auto conf = this->config_;
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, "ESP32 Camera:");
"ESP32 Camera:\n" ESP_LOGCONFIG(TAG, " Name: %s", this->name_.c_str());
" Name: %s\n" ESP_LOGCONFIG(TAG, " Internal: %s", YESNO(this->internal_));
" Internal: %s\n" ESP_LOGCONFIG(TAG, " Data Pins: D0:%d D1:%d D2:%d D3:%d D4:%d D5:%d D6:%d D7:%d", conf.pin_d0, conf.pin_d1,
" Data Pins: D0:%d D1:%d D2:%d D3:%d D4:%d D5:%d D6:%d D7:%d\n" conf.pin_d2, conf.pin_d3, conf.pin_d4, conf.pin_d5, conf.pin_d6, conf.pin_d7);
" VSYNC Pin: %d\n" ESP_LOGCONFIG(TAG, " VSYNC Pin: %d", conf.pin_vsync);
" HREF Pin: %d\n" ESP_LOGCONFIG(TAG, " HREF Pin: %d", conf.pin_href);
" Pixel Clock Pin: %d\n" ESP_LOGCONFIG(TAG, " Pixel Clock Pin: %d", conf.pin_pclk);
" External Clock: Pin:%d Frequency:%u\n" ESP_LOGCONFIG(TAG, " External Clock: Pin:%d Frequency:%u", conf.pin_xclk, conf.xclk_freq_hz);
" I2C Pins: SDA:%d SCL:%d\n" ESP_LOGCONFIG(TAG, " I2C Pins: SDA:%d SCL:%d", conf.pin_sccb_sda, conf.pin_sccb_scl);
" Reset Pin: %d", ESP_LOGCONFIG(TAG, " Reset Pin: %d", conf.pin_reset);
this->name_.c_str(), YESNO(this->internal_), conf.pin_d0, conf.pin_d1, conf.pin_d2, conf.pin_d3,
conf.pin_d4, conf.pin_d5, conf.pin_d6, conf.pin_d7, conf.pin_vsync, conf.pin_href, conf.pin_pclk,
conf.pin_xclk, conf.xclk_freq_hz, conf.pin_sccb_sda, conf.pin_sccb_scl, conf.pin_reset);
switch (this->config_.frame_size) { switch (this->config_.frame_size) {
case FRAMESIZE_QQVGA: case FRAMESIZE_QQVGA:
ESP_LOGCONFIG(TAG, " Resolution: 160x120 (QQVGA)"); ESP_LOGCONFIG(TAG, " Resolution: 160x120 (QQVGA)");
@@ -126,29 +123,24 @@ void ESP32Camera::dump_config() {
sensor_t *s = esp_camera_sensor_get(); sensor_t *s = esp_camera_sensor_get();
auto st = s->status; auto st = s->status;
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " JPEG Quality: %u", st.quality);
" JPEG Quality: %u\n" ESP_LOGCONFIG(TAG, " Framebuffer Count: %u", conf.fb_count);
" Framebuffer Count: %u\n" ESP_LOGCONFIG(TAG, " Contrast: %d", st.contrast);
" Contrast: %d\n" ESP_LOGCONFIG(TAG, " Brightness: %d", st.brightness);
" Brightness: %d\n" ESP_LOGCONFIG(TAG, " Saturation: %d", st.saturation);
" Saturation: %d\n" ESP_LOGCONFIG(TAG, " Vertical Flip: %s", ONOFF(st.vflip));
" Vertical Flip: %s\n" ESP_LOGCONFIG(TAG, " Horizontal Mirror: %s", ONOFF(st.hmirror));
" Horizontal Mirror: %s\n" ESP_LOGCONFIG(TAG, " Special Effect: %u", st.special_effect);
" Special Effect: %u\n" ESP_LOGCONFIG(TAG, " White Balance Mode: %u", st.wb_mode);
" White Balance Mode: %u",
st.quality, conf.fb_count, st.contrast, st.brightness, st.saturation, ONOFF(st.vflip),
ONOFF(st.hmirror), st.special_effect, st.wb_mode);
// ESP_LOGCONFIG(TAG, " Auto White Balance: %u", st.awb); // ESP_LOGCONFIG(TAG, " Auto White Balance: %u", st.awb);
// ESP_LOGCONFIG(TAG, " Auto White Balance Gain: %u", st.awb_gain); // ESP_LOGCONFIG(TAG, " Auto White Balance Gain: %u", st.awb_gain);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG, " Auto Exposure Control: %u", st.aec);
" Auto Exposure Control: %u\n" ESP_LOGCONFIG(TAG, " Auto Exposure Control 2: %u", st.aec2);
" Auto Exposure Control 2: %u\n" ESP_LOGCONFIG(TAG, " Auto Exposure Level: %d", st.ae_level);
" Auto Exposure Level: %d\n" ESP_LOGCONFIG(TAG, " Auto Exposure Value: %u", st.aec_value);
" Auto Exposure Value: %u\n" ESP_LOGCONFIG(TAG, " AGC: %u", st.agc);
" AGC: %u\n" ESP_LOGCONFIG(TAG, " AGC Gain: %u", st.agc_gain);
" AGC Gain: %u\n" ESP_LOGCONFIG(TAG, " Gain Ceiling: %u", st.gainceiling);
" Gain Ceiling: %u",
st.aec, st.aec2, st.ae_level, st.aec_value, st.agc, st.agc_gain, st.gainceiling);
// ESP_LOGCONFIG(TAG, " BPC: %u", st.bpc); // ESP_LOGCONFIG(TAG, " BPC: %u", st.bpc);
// ESP_LOGCONFIG(TAG, " WPC: %u", st.wpc); // ESP_LOGCONFIG(TAG, " WPC: %u", st.wpc);
// ESP_LOGCONFIG(TAG, " RAW_GMA: %u", st.raw_gma); // ESP_LOGCONFIG(TAG, " RAW_GMA: %u", st.raw_gma);

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