Commit Graph
23181 Commits
Author SHA1 Message Date
tronikos 52af92d4b5 Add On/Off and Away mode support to template platform
Implemented support for On/Off and Away modes in the template water heater
platform, including optimistic control and lambda-based state reporting.

Refactored the base 'WaterHeaterCall' to replace the 'state_' bitmask with
'optional<bool>' for 'on' and 'away' fields. This change was necessary to
enable partial (delta) updates. The previous bitmask implementation did not
distinguish between a field being "set to false" and "not set at all,"
causing unintended state resets (e.g., turning the device off when only
adjusting temperature).
2026-02-07 01:35:37 -08:00
J. Nick Koston 0fa7050b1c remove temp test 2026-02-07 10:01:57 +01:00
J. Nick Koston fa1554cac0 [scheduler] Eliminate heap allocation in full_cleanup_removed_items_
Replace the temporary std::vector copy with in-place compaction using a
read/write pointer pattern. This avoids a heap allocation+deallocation
cycle during scheduler cleanup, reducing heap fragmentation on
long-running ESP devices.

The new approach compacts valid items forward in the existing vector,
recycles removed items as they are encountered, then resizes the vector
(no reallocation since size only shrinks). Same O(n) complexity, same
behavior, zero allocations.
2026-02-07 09:54:43 +01:00
J. Nick Koston 14071086bb Merge branch 'logger_thread_name_cleanup' into integration 2026-02-07 09:02:06 +01:00
J. Nick Koston 30f9bfaf83 [logger] Resolve thread name once and pass through logging chain
Eliminate redundant xTaskGetCurrentTaskHandle() and pcTaskGetName()
calls on the hot path by resolving the thread name once in log_vprintf_
and passing it through as const char* to all downstream functions.

- Main task fast path passes nullptr (no task handle lookup needed)
- Non-main thread path resolves name once, passes to both ring buffer
  and emergency console fallback
- Unify log_vprintf_non_main_thread_ to single signature across platforms
- Change send_message_thread_safe() on all platforms from TaskHandle_t
  to const char* thread_name
- Add TaskHandle_t overload for get_thread_name_ as primary on
  ESP32/LibreTiny, with no-arg convenience wrapper
- Use std::span<char> for Host/Zephyr get_thread_name_ buffer parameter
- Document Zephyr single-task path thread safety limitation
2026-02-07 07:47:00 +01:00
J. Nick Koston daebc2cc39 Merge branch 'dashboard-ws-close-on-exit' into integration 2026-02-07 06:15:23 +01:00
J. Nick Koston 6b089a611c [dashboard] Close WebSocket after process exit to prevent zombie connections
When a subprocess exited, _proc_on_exit sent the exit event but never
closed the server-side WebSocket. This left zombie connections open
until the client eventually disconnected.
2026-02-07 06:14:44 +01:00
J. Nick Koston 836bfc625d restore original byte-at-a-time read in send_cmd_from_array ack loop
The ack polling loop has a tight timing requirement with
delay_microseconds_safe(1450) between iterations. Snapshotting
available() once could leave partial ack response bytes unread
until after the delay, potentially breaking cold boot timing
on some ld2420 units. Keep batch reads only in loop().
2026-02-07 01:01:03 +01:00
J. Nick Koston 2a17592d57 dfplayer: batch UART reads to reduce per-loop overhead 2026-02-07 00:38:54 +01:00
J. Nick Koston 04697ac223 rf_bridge: batch UART reads to reduce per-loop overhead 2026-02-07 00:36:27 +01:00
J. Nick Koston 3f3cf83aab rd03d: batch UART reads to reduce per-loop overhead 2026-02-07 00:32:33 +01:00
J. Nick Koston 39013388dd pipsolar: batch UART reads to reduce per-loop overhead 2026-02-07 00:26:33 +01:00
J. Nick Koston cfbeea9983 [dlms_meter] Batch UART reads to reduce per-loop overhead
Replace byte-at-a-time read_byte() calls with batched read_array()
in loop(). Each read_byte() internally chains through
read_array(data, 1) -> check_read_timeout_(1) -> available(),
resulting in ~3 UART driver calls per byte. Batching into a 64-byte
stack buffer reduces this to ~3 calls per loop iteration regardless
of how many bytes are available.

Also uses vector insert() for bulk append instead of per-byte
push_back(), and caps reads to remaining buffer capacity upfront
to avoid over-reading from UART.
2026-02-07 00:22:00 +01:00
J. Nick Koston 8f6e1abbce Check read_array return value in drain_rx_buffer_ 2026-02-07 00:18:51 +01:00
J. Nick Koston c77d70c093 [tuya] Batch UART reads to reduce per-loop overhead
Replace byte-at-a-time read_byte() calls with batched read_array()
in loop(). Each read_byte() internally chains through
read_array(data, 1) -> check_read_timeout_(1) -> available(),
resulting in ~3 UART driver calls per byte. Batching into a 64-byte
stack buffer reduces this to ~3 calls per loop iteration regardless
of how many bytes are available.
2026-02-07 00:17:26 +01:00
J. Nick Koston 25762c62f8 [dsmr] Batch UART reads to reduce per-loop overhead
Replace byte-at-a-time read() calls with batched read_array() in all
four UART read sites: receive_telegram_(), receive_encrypted_telegram_(),
and two drain loops. Each read() internally chains through
read_array(data, 1) -> check_read_timeout_(1) -> available(), resulting
in ~3 UART driver calls per byte. Batching into a 64-byte stack buffer
reduces this to ~3 calls per batch regardless of byte count.

Extract drain_rx_buffer_() helper to deduplicate the two drain sites
in ready_to_request_data_() and stop_requesting_data_().
2026-02-07 00:11:50 +01:00
J. Nick Koston 441ec35d9f [seeed_mr24hpc1/mr60fda2/mr60bha2] Batch UART reads to reduce per-loop overhead
Replace byte-at-a-time read_byte() calls with batched read_array()
in all three Seeed MR sensor components. Each read_byte() internally
chains through read_array(data, 1) -> check_read_timeout_(1) ->
available(), resulting in ~3 UART driver calls per byte. Batching
into a 64-byte stack buffer reduces this to ~3 calls per loop
iteration regardless of how many bytes are available.
2026-02-07 00:07:44 +01:00
J. Nick KostonandCopilot 33c831dbb8 Update esphome/components/nextion/nextion.cpp
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-07 00:07:05 +01:00
J. Nick Koston 38aeb9be37 [pylontech] Batch UART reads to reduce loop overhead 2026-02-07 00:04:22 +01:00
J. Nick Koston 6b7c52799d [nextion] Batch UART reads to reduce loop overhead 2026-02-07 00:02:10 +01:00
J. Nick Koston f19bb2cd0a [modbus] Batch UART reads to reduce loop overhead 2026-02-06 23:59:38 +01:00
J. Nick Koston 26c98a1e25 [ld2420] Batch UART reads to reduce loop overhead 2026-02-06 23:54:52 +01:00
J. Nick Koston 8a2c5407d8 Merge branch 'ld2450_batch_read' into integration 2026-02-06 23:40:24 +01:00
J. Nick Koston 52a039585d Merge branch 'ld2410_batch_read' into integration 2026-02-06 23:40:20 +01:00
J. Nick Koston fd6bd7fb67 Merge branch 'ld2412_batch_read' into integration 2026-02-06 23:40:15 +01:00
J. Nick Koston b544cf2ffe [ld2410] Batch UART reads to reduce loop overhead 2026-02-06 23:39:31 +01:00
J. Nick Koston 6d1281301f [ld2412] Batch UART reads to reduce loop overhead
Read all available bytes in batches via read_array() instead of
byte-at-a-time read() calls. Each read() internally chains through
read_byte -> read_array(1) -> check_read_timeout_ -> available(),
resulting in 3 UART calls per byte. Batching reduces this
significantly.
2026-02-06 23:36:01 +01:00
J. Nick Koston 901192cca1 [ld2450] Batch UART reads to reduce loop overhead
Read all available bytes in batches via read_array() instead of
byte-at-a-time read() calls. Each read() internally chains through
read_byte -> read_array(1) -> check_read_timeout_ -> available(),
resulting in 3 UART calls per byte. At 256000 baud with ~235 bytes
per loop iteration, this was ~706 UART operations per loop call.
Batching reduces this to ~12.

Measured 33% reduction in loop time (2348ms -> 1577ms per 60s).
2026-02-06 23:33:21 +01:00
J. Nick Koston 3478c68af7 Merge branch 'cse7766_batch_read' into integration 2026-02-06 23:12:14 +01:00
J. Nick Koston 67e7ba4812 handle unlikely 2026-02-06 23:12:00 +01:00
J. Nick Koston 981c132cf4 Merge branch 'cse7766_batch_read' into integration 2026-02-06 23:07:21 +01:00
J. Nick Koston 572376091e loop 2026-02-06 23:07:02 +01:00
J. Nick Koston 803e73fdec Merge branch 'cse7766_batch_read' into integration 2026-02-06 22:59:59 +01:00
J. Nick Koston e7c9808b87 [cse7766] Batch UART reads to reduce loop overhead 2026-02-06 22:53:31 +01:00
J. Nick Koston 82eb8e3492 Merge branch 'ssd1306-progmem-tables' into integration 2026-02-06 21:39:50 +01:00
J. Nick Koston 21a5c2891e Merge branch 'i2c-arduino-cswtch' into integration 2026-02-06 21:39:46 +01:00
J. Nick Koston 96289775f2 [i2c] Replace switch with if-else to avoid CSWTCH table in RAM
Replace the Wire status-to-ErrorCode switch with if-else to prevent
the compiler from generating a 6-byte lookup table in DRAM on ESP8266.
2026-02-06 21:38:41 +01:00
J. Nick Koston 3e4269d32a Address review: add SSD1306_MODEL_COUNT sentinel and bounds checks
- Add SSD1306_MODEL_COUNT sentinel to enum for compile-time table size validation
- Replace 14 individual static_asserts with table size checks against SSD1306_MODEL_COUNT
- Add bounds checks in get_height_internal()/get_width_internal() to preserve default return 0
2026-02-06 21:37:51 +01:00
J. Nick Koston bd6d43de52 Merge branch 'ssd1306-progmem-tables' into integration 2026-02-06 21:28:11 +01:00
J. Nick Koston 8da986d41a [ssd1306_base] Move switch tables to PROGMEM with lookup tables
Replace three compiler-generated switch tables (CSWTCH) with PROGMEM
lookup tables, saving 84 bytes of DRAM on ESP8266.

- model_str_(): 56B string pointer table → PROGMEM_STRING_TABLE
- get_height_internal(): 14B byte table → PROGMEM struct array
- get_width_internal(): 14B byte table → PROGMEM struct array

Width and height use a single ModelDimensions struct array for
maintainability. All 14 enum values verified with static_assert.
2026-02-06 21:26:10 +01:00
tronikosandJ. Nick Koston eb7aa3420f Add target_temperature to the template water heater (#13661)
Co-authored-by: J. Nick Koston <nick@koston.org>
2026-02-06 21:23:42 +01:00
J. Nick Koston 4fb851954b Merge branch 'debug_progmem' into integration 2026-02-06 21:10:55 +01:00
J. Nick Koston d1399d9145 [debug] Move ESP8266 switch tables to flash with PROGMEM_STRING_TABLE 2026-02-06 21:10:23 +01:00
J. Nick Koston ba40fbc53d Merge remote-tracking branch 'origin/mqtt-custom-topic-no-alloc' into integration 2026-02-06 21:01:53 +01:00
J. Nick Koston c8d4d870e8 [mqtt] Use .c_str() for StringRef payloads to match non-allocating publish overload 2026-02-06 21:00:53 +01:00
J. Nick Koston fcb458e449 Merge branch 'mqtt-discovery-topic-no-alloc' into integration 2026-02-06 20:57:47 +01:00
J. Nick Koston 48a8f753f5 Merge branch 'mqtt-custom-topic-no-alloc' into integration 2026-02-06 20:57:40 +01:00
J. Nick Koston 6293f3110c Merge branch 'mqtt-friendly-name-const-ref' into integration 2026-02-06 20:57:35 +01:00
J. Nick Koston ce34b37e02 Merge branch 'mqtt-on-log-no-heap' into integration 2026-02-06 20:57:29 +01:00
J. Nick Koston b454cac1dc [mqtt] Use stack buffer for discovery topic to avoid heap allocation 2026-02-06 20:48:18 +01:00