From 8749c3d18d29ba1c63b7790e0f3f7a783d7c9c84 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 25 Aug 2026 12:40:57 -0500 Subject: [PATCH 1/3] [esp32_ble_tracker] Warn when the scan window is above 600ms with wifi (#18725) --- .../components/esp32_ble_tracker/__init__.py | 47 +++++++++++++++++ .../test_scan_window_default.py | 52 +++++++++++++++++++ 2 files changed, 99 insertions(+) diff --git a/esphome/components/esp32_ble_tracker/__init__.py b/esphome/components/esp32_ble_tracker/__init__.py index c6e34f37ca..906144e5fd 100644 --- a/esphome/components/esp32_ble_tracker/__init__.py +++ b/esphome/components/esp32_ble_tracker/__init__.py @@ -143,6 +143,13 @@ def validate_max_connections_deprecated(config: ConfigType) -> ConfigType: # BLE uses the airtime wifi does not claim. IDF_SCAN_WINDOW_FIX_VERSION = cv.Version(5, 5, 5) +# Above this the scanner holds the shared radio long enough that wifi drops +# packets and connections on some access points (others cope fine, which is +# why this is a warning and not an error); old proxy configs with 1100 ms +# windows are a recurring cause of instability (esphome/esphome#18655). Only +# wifi shares the radio; long windows are fine on ethernet builds. +MAX_RECOMMENDED_WIFI_SCAN_WINDOW = TimePeriod(milliseconds=600) + @dataclass class TrackerData: @@ -209,6 +216,45 @@ def _raise_defaulted_scan_window(config: ConfigType) -> ConfigType: return config +def _warn_long_scan_window_with_wifi(config: ConfigType) -> ConfigType: + """Warn when the scan window is long enough to starve wifi. + + Runs after _raise_defaulted_scan_window so it sees the final window. + software_coexistence is only present when wifi is configured, so ethernet + builds never warn: BLE has the radio to itself there. Presence is what + matters, not the value; with the arbiter disabled a long window starves + wifi outright. + """ + params = config[CONF_SCAN_PARAMETERS] + window = params[CONF_WINDOW] + if CONF_SOFTWARE_COEXISTENCE not in config: + return config + if window <= MAX_RECOMMENDED_WIFI_SCAN_WINDOW: + return config + if _get_data().scan_window_defaulted: + # The window was raised to match the interval, so point at the key the + # user actually set. + _LOGGER.warning( + "BLE scan interval of %s sets the scan window to the same value, " + "which starves wifi on the same radio and can cause wifi disconnects " + "depending on the access point; keep the interval at or below %s " + "(for example interval: 320ms). Long windows are only a problem with " + "wifi, they are fine on ethernet", + params[CONF_INTERVAL], + MAX_RECOMMENDED_WIFI_SCAN_WINDOW, + ) + return config + _LOGGER.warning( + "BLE scan window of %s with wifi on the same radio starves wifi and " + "can cause wifi disconnects depending on the access point; keep the " + "window at or below %s (for example interval: 320ms, window: 300ms). " + "Long windows are only a problem with wifi, they are fine on ethernet", + window, + MAX_RECOMMENDED_WIFI_SCAN_WINDOW, + ) + return config + + # 320 ms is the ESP-IDF reference scan interval; the shared schema also # tightens validation to the controller's 2.5 ms .. 10240 ms range and rejects # window/interval pairs that collapse to the same 0.625 ms unit count. @@ -271,6 +317,7 @@ CONFIG_SCHEMA = cv.All( ).extend(cv.COMPONENT_SCHEMA), validate_max_connections_deprecated, _raise_defaulted_scan_window, + _warn_long_scan_window_with_wifi, ) diff --git a/tests/component_tests/esp32_ble_tracker/test_scan_window_default.py b/tests/component_tests/esp32_ble_tracker/test_scan_window_default.py index 8612ac6732..1381aaf4c2 100644 --- a/tests/component_tests/esp32_ble_tracker/test_scan_window_default.py +++ b/tests/component_tests/esp32_ble_tracker/test_scan_window_default.py @@ -12,6 +12,7 @@ arbiter a full-duty scan would starve wifi, so the 30 ms default is kept. from __future__ import annotations from collections.abc import Callable +import logging from pathlib import Path import pytest @@ -221,3 +222,54 @@ def test_connection_scan_window_codegen( assert window_call in main_cpp assert ("set_connection_scan_window(48)" in main_cpp) == connection_call assert ("'connection_scan_window' has no effect" in caplog.text) == warns + + +@pytest.mark.parametrize( + ("wifi", "params", "expect_warning"), + [ + (True, {"interval": "1100ms", "window": "1100ms"}, True), + (True, {"interval": "1100ms", "window": "601ms"}, True), + (True, {"interval": "1100ms", "window": "600ms"}, False), + (False, {"interval": "1100ms", "window": "1100ms"}, False), + ], +) +def test_long_window_with_wifi_warns( + stage_esp32: Callable[..., None], + caplog: pytest.LogCaptureFixture, + wifi: bool, + params: ConfigType, + expect_warning: bool, +) -> None: + """A scan window above 600 ms warns only when wifi shares the radio.""" + stage_esp32("5.5.5", wifi=wifi) + with caplog.at_level(logging.WARNING): + _scan_params({"scan_parameters": params}) + assert ("starves wifi" in caplog.text) is expect_warning + + +def test_long_window_warns_with_coexistence_disabled( + stage_esp32: Callable[..., None], + caplog: pytest.LogCaptureFixture, +) -> None: + """Disabling the arbiter is the worst case for a long window, so it still warns.""" + stage_esp32("5.5.5", wifi=True) + with caplog.at_level(logging.WARNING): + _scan_params( + { + CONF_SOFTWARE_COEXISTENCE: False, + "scan_parameters": {"interval": "1100ms", "window": "1100ms"}, + } + ) + assert "BLE scan window of 1100ms" in caplog.text + + +def test_raised_window_warning_points_at_interval( + stage_esp32: Callable[..., None], + caplog: pytest.LogCaptureFixture, +) -> None: + """When the window was raised to a long interval, the warning names the interval.""" + stage_esp32("5.5.5", wifi=True) + with caplog.at_level(logging.WARNING): + _scan_params({"scan_parameters": {"interval": "1s"}}) + assert "BLE scan interval of 1s" in caplog.text + assert "BLE scan window of" not in caplog.text From 145373ed134c1a40c8d9e9f53d6d3cff44cda99c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 25 Aug 2026 13:04:41 -0500 Subject: [PATCH 2/3] [api] Widen message type storage to uint16_t (#18526) --- esphome/components/api/api_connection.cpp | 16 +- esphome/components/api/api_connection.h | 37 +-- esphome/components/api/api_frame_helper.h | 18 +- .../components/api/api_frame_helper_noise.cpp | 4 +- .../components/api/api_frame_helper_noise.h | 4 +- .../api/api_frame_helper_plaintext.cpp | 24 +- .../api/api_frame_helper_plaintext.h | 5 +- esphome/components/api/api_pb2.h | 284 +++++++++--------- esphome/components/api/proto.h | 5 - script/api_protobuf/api_protobuf.py | 29 +- .../api/test_api_protobuf_generator.py | 18 +- 11 files changed, 238 insertions(+), 206 deletions(-) diff --git a/esphome/components/api/api_connection.cpp b/esphome/components/api/api_connection.cpp index 05abbf0b75..9b1026d2a9 100644 --- a/esphome/components/api/api_connection.cpp +++ b/esphome/components/api/api_connection.cpp @@ -1790,10 +1790,12 @@ void APIConnection::complete_authentication_() { bool APIConnection::send_hello_response_(const HelloRequest &msg) { // Copy client name with truncation if needed (set_client_name handles truncation) this->helper_->set_client_name(msg.client_info.c_str(), msg.client_info.size()); - this->client_api_version_major_ = msg.api_version_major; - this->client_api_version_minor_ = msg.api_version_minor; + this->client_api_version_major_ = + static_cast(std::min(msg.api_version_major, std::numeric_limits::max())); + this->client_api_version_minor_ = + static_cast(std::min(msg.api_version_minor, std::numeric_limits::max())); char peername[socket::SOCKADDR_STR_LEN]; - ESP_LOGV(TAG, "Hello from client: '%s' | %s | API Version %" PRIu16 ".%" PRIu16, this->helper_->get_client_name(), + ESP_LOGV(TAG, "Hello from client: '%s' | %s | API Version %u.%u", this->helper_->get_client_name(), this->helper_->get_peername_to(peername), this->client_api_version_major_, this->client_api_version_minor_); HelloResponse resp; @@ -2224,7 +2226,7 @@ bool APIConnection::try_to_clear_buffer_slow_(bool log_out_of_space) { } return false; } -bool APIConnection::send_message_(uint32_t payload_size, uint8_t message_type, MessageEncodeFn encode_fn, +bool APIConnection::send_message_(uint32_t payload_size, uint16_t message_type, MessageEncodeFn encode_fn, const void *msg) { #ifdef HAS_PROTO_MESSAGE_DUMP // Skip dump for log messages (recursive logging risk) and camera frames (high-frequency noise) @@ -2253,7 +2255,7 @@ uint16_t APIConnection::encode_to_buffer_slow(uint32_t calculated_size, MessageE APIConnection *conn, uint32_t remaining_size) { return encode_to_buffer(calculated_size, encode_fn, msg, conn, remaining_size); } -bool APIConnection::send_buffer(ProtoWriteBuffer buffer, uint8_t message_type) { +bool APIConnection::send_buffer(ProtoWriteBuffer buffer, uint16_t message_type) { const bool is_log_message = (message_type == SubscribeLogsResponse::MESSAGE_TYPE); if (!this->try_to_clear_buffer(!is_log_message)) { @@ -2283,12 +2285,12 @@ void APIConnection::on_fatal_error() { this->flags_.remove = true; } -bool APIConnection::schedule_message_front_(EntityBase *entity, uint8_t message_type, uint8_t estimated_size) { +bool APIConnection::schedule_message_front_(EntityBase *entity, uint16_t message_type, uint8_t estimated_size) { this->deferred_batch_.add_item_front(entity, message_type, estimated_size); return this->schedule_batch_(); } -bool APIConnection::send_message_smart_(EntityBase *entity, uint8_t message_type, uint8_t estimated_size, +bool APIConnection::send_message_smart_(EntityBase *entity, uint16_t message_type, uint8_t estimated_size, uint8_t aux_data_index) { if (this->should_send_immediately_(message_type) && this->helper_->can_write_without_blocking()) { auto &shared_buf = this->parent_->get_shared_buffer_ref(); diff --git a/esphome/components/api/api_connection.h b/esphome/components/api/api_connection.h index 1b47c23cfe..5a554f4857 100644 --- a/esphome/components/api/api_connection.h +++ b/esphome/components/api/api_connection.h @@ -326,8 +326,10 @@ class APIConnection final : public APIServerConnectionBase { bool is_marked_for_removal() const { return this->flags_.remove; } uint8_t get_log_subscription_level() const { return this->flags_.log_subscription; } - // Get client API version for feature detection - bool client_supports_api_version(uint16_t major, uint16_t minor) const { + // Get client API version for feature detection. + // Stored versions saturate at 255 (see send_hello_response_), so requesting + // a minimum above that can never match. + bool client_supports_api_version(uint8_t major, uint8_t minor) const { return this->client_api_version_major_ > major || (this->client_api_version_major_ == major && this->client_api_version_minor_ >= minor); } @@ -374,7 +376,7 @@ class APIConnection final : public APIServerConnectionBase { return true; return this->try_to_clear_buffer_slow_(log_out_of_space); } - bool send_buffer(ProtoWriteBuffer buffer, uint8_t message_type); + bool send_buffer(ProtoWriteBuffer buffer, uint16_t message_type); const char *get_name() const { return this->helper_->get_client_name(); } /// Get peer name (IP address) into caller-provided buffer, returns buf for convenience @@ -423,7 +425,7 @@ class APIConnection final : public APIServerConnectionBase { } // Non-template buffer management for send_message - bool send_message_(uint32_t payload_size, uint8_t message_type, MessageEncodeFn encode_fn, const void *msg); + bool send_message_(uint32_t payload_size, uint16_t message_type, MessageEncodeFn encode_fn, const void *msg); // Core batch encoding logic. ALWAYS_INLINE so encode_fn devirtualizes at hot call sites. // Defined in api_connection_buffer.h (needs APIServer complete). @@ -664,10 +666,9 @@ class APIConnection final : public APIServerConnectionBase { struct BatchItem { EntityBase *entity; // 4 bytes - Entity pointer - uint8_t message_type; // 1 byte - Message type for protocol and dispatch + uint16_t message_type; // 2 bytes - Message type for protocol and dispatch uint8_t estimated_size; // 1 byte - Estimated message size (max 255 bytes) uint8_t aux_data_index{AUX_DATA_UNUSED}; // 1 byte - For events: index into entity's event_types - // 1 byte padding }; std::vector items; @@ -677,7 +678,7 @@ class APIConnection final : public APIServerConnectionBase { // connections that do, buffers are released after initial sync anyway // Add item to the batch (with deduplication) - void add_item(EntityBase *entity, uint8_t message_type, uint8_t estimated_size, + void add_item(EntityBase *entity, uint16_t message_type, uint8_t estimated_size, uint8_t aux_data_index = AUX_DATA_UNUSED) { // Dedup: O(n) scan but optimized for RAM over performance // Skip deduplication for events - they are edge-triggered, every occurrence matters @@ -693,7 +694,7 @@ class APIConnection final : public APIServerConnectionBase { this->items.push_back({entity, message_type, estimated_size, aux_data_index}); } // Add item to the front of the batch (for high priority messages like ping) - void add_item_front(EntityBase *entity, uint8_t message_type, uint8_t estimated_size) { + void add_item_front(EntityBase *entity, uint16_t message_type, uint8_t estimated_size) { // Swap to front avoids expensive vector::insert which shifts all elements this->items.push_back({entity, message_type, estimated_size, AUX_DATA_UNUSED}); if (this->items.size() > 1) { @@ -758,13 +759,15 @@ class APIConnection final : public APIServerConnectionBase { #endif } flags_{}; // 2 bytes total - // 2-byte types immediately after flags_ (no padding between them) - uint16_t client_api_version_major_{0}; - uint16_t client_api_version_minor_{0}; + // 2-byte type immediately after flags_ (no padding between them) + uint16_t batch_message_type_{0}; // Current message type during batch encoding // 1-byte types to fill remaining space before next 4-byte boundary + // Client API versions are clamped to 255 on receive (see send_hello_response_) + uint8_t client_api_version_major_{0}; + uint8_t client_api_version_minor_{0}; ActiveIterator active_iterator_{ActiveIterator::NONE}; - uint8_t batch_message_type_{0}; // Current message type during batch encoding - // Total: 2 (flags) + 2 + 2 + 1 + 1 = 8 bytes, aligned to 4-byte boundary + // Total: 2 (flags) + 2 + 1 + 1 + 1 + 1 (batch_header_size_ below) = 8 bytes, + // aligned to 4-byte boundary // Actual header size used by encode_to_buffer for the current message. // Read by process_batch_multi_ to pass into MessageInfo. @@ -813,7 +816,7 @@ class APIConnection final : public APIServerConnectionBase { // 2. It's an EventResponse (events are edge-triggered - every occurrence matters) // 3. OR: User has opted into immediate sending (should_try_send_immediately = true // AND batch_delay = 0) - inline bool should_send_immediately_(uint8_t message_type) const { + inline bool should_send_immediately_(uint16_t message_type) const { return ( #ifdef USE_UPDATE message_type == UpdateStateResponse::MESSAGE_TYPE || @@ -827,11 +830,11 @@ class APIConnection final : public APIServerConnectionBase { // Helper method to send a message either immediately or via batching // Tries immediate send if should_send_immediately_() returns true and buffer has space // Falls back to batching if immediate send fails or isn't applicable - bool send_message_smart_(EntityBase *entity, uint8_t message_type, uint8_t estimated_size, + bool send_message_smart_(EntityBase *entity, uint16_t message_type, uint8_t estimated_size, uint8_t aux_data_index = DeferredBatch::AUX_DATA_UNUSED); // Helper function to schedule a deferred message with known message type - bool schedule_message_(EntityBase *entity, uint8_t message_type, uint8_t estimated_size, + bool schedule_message_(EntityBase *entity, uint16_t message_type, uint8_t estimated_size, uint8_t aux_data_index = DeferredBatch::AUX_DATA_UNUSED) { this->deferred_batch_.add_item(entity, message_type, estimated_size, aux_data_index); return this->schedule_batch_(); @@ -839,7 +842,7 @@ class APIConnection final : public APIServerConnectionBase { // Helper function to schedule a high priority message at the front of the batch // Out-of-line: callers (on_shutdown, check_keepalive_) are cold paths - bool schedule_message_front_(EntityBase *entity, uint8_t message_type, uint8_t estimated_size); + bool schedule_message_front_(EntityBase *entity, uint16_t message_type, uint8_t estimated_size); // Helper function to log client messages with name and peername void log_client_(int level, const LogString *message); diff --git a/esphome/components/api/api_frame_helper.h b/esphome/components/api/api_frame_helper.h index 1c60bb87a5..ff8aa7834c 100644 --- a/esphome/components/api/api_frame_helper.h +++ b/esphome/components/api/api_frame_helper.h @@ -49,16 +49,16 @@ struct ReadPacketBuffer { }; // Packed message info structure to minimize memory usage -// Note: message_type is uint8_t — all current protobuf message types fit in 8 bits. -// The noise wire format encodes types as 16-bit, but the high byte is always 0. -// If message types ever exceed 255, this and encrypt_noise_message_ must be updated. +// message_type matches the wire formats: noise carries a fixed 16-bit type +// field, plaintext a type varint. The proto codegen caps message IDs at 16383 +// so the plaintext type varint fits the 2 bytes budgeted in HEADER_PADDING. struct MessageInfo { uint16_t offset; // Offset in buffer where message starts uint16_t payload_size; // Size of the message payload - uint8_t message_type; // Message type (0-255) + uint16_t message_type; // Message type (0-16383) uint8_t header_size; // Actual header size used (avoids recomputation in write path) - MessageInfo(uint8_t type, uint16_t off, uint16_t size, uint8_t hdr) + MessageInfo(uint16_t type, uint16_t off, uint16_t size, uint8_t hdr) : offset(off), payload_size(size), message_type(type), header_size(hdr) {} }; @@ -173,7 +173,7 @@ class APIFrameHelper { } // Write a single protobuf message - the hot path (87-100% of all writes). // Caller must ensure state is DATA before calling. - virtual APIError write_protobuf_packet(uint8_t type, ProtoWriteBuffer buffer) = 0; + virtual APIError write_protobuf_packet(uint16_t type, ProtoWriteBuffer buffer) = 0; // Write multiple protobuf messages in a single batched operation. // Caller must ensure state is DATA and messages is not empty. // messages contains (message_type, offset, length) for each message in the buffer. @@ -187,15 +187,15 @@ class APIFrameHelper { // Distinguishes protocols via frame_footer_size_ (noise always has a non-zero MAC // footer, plaintext has footer=0). If a protocol with a plaintext footer is ever // added, this should become a virtual method. - uint8_t frame_header_size(uint16_t payload_size, uint8_t message_type) const { + uint8_t frame_header_size(uint16_t payload_size, uint16_t message_type) const { #if defined(USE_API_NOISE) && defined(USE_API_PLAINTEXT) return this->frame_footer_size_ ? this->frame_header_padding_ - : static_cast(1 + ProtoSize::varint16(payload_size) + ProtoSize::varint8(message_type)); + : static_cast(1 + ProtoSize::varint16(payload_size) + ProtoSize::varint16(message_type)); #elif defined(USE_API_NOISE) return this->frame_header_padding_; #else // USE_API_PLAINTEXT only - return static_cast(1 + ProtoSize::varint16(payload_size) + ProtoSize::varint8(message_type)); + return static_cast(1 + ProtoSize::varint16(payload_size) + ProtoSize::varint16(message_type)); #endif } // Get the frame footer size required by this protocol diff --git a/esphome/components/api/api_frame_helper_noise.cpp b/esphome/components/api/api_frame_helper_noise.cpp index d7554e62c5..9c4cc2aa78 100644 --- a/esphome/components/api/api_frame_helper_noise.cpp +++ b/esphome/components/api/api_frame_helper_noise.cpp @@ -442,7 +442,7 @@ APIError APINoiseFrameHelper::read_packet(ReadPacketBuffer *buffer) { } // Encrypt a single noise message in place and return the encrypted frame length. // Returns APIError::OK on success. -APIError APINoiseFrameHelper::encrypt_noise_message_(uint8_t *buf_start, uint16_t payload_size, uint8_t message_type, +APIError APINoiseFrameHelper::encrypt_noise_message_(uint8_t *buf_start, uint16_t payload_size, uint16_t message_type, uint16_t &encrypted_len_out) { // The noise frame header is written after encryption, when the size is known @@ -472,7 +472,7 @@ APIError APINoiseFrameHelper::encrypt_noise_message_(uint8_t *buf_start, uint16_ return APIError::OK; } -APIError APINoiseFrameHelper::write_protobuf_packet(uint8_t type, ProtoWriteBuffer buffer) { +APIError APINoiseFrameHelper::write_protobuf_packet(uint16_t type, ProtoWriteBuffer buffer) { #ifdef ESPHOME_DEBUG_API assert(this->state_ == State::DATA); #endif diff --git a/esphome/components/api/api_frame_helper_noise.h b/esphome/components/api/api_frame_helper_noise.h index 05060c77de..366751738e 100644 --- a/esphome/components/api/api_frame_helper_noise.h +++ b/esphome/components/api/api_frame_helper_noise.h @@ -31,7 +31,7 @@ class APINoiseFrameHelper final : public APIFrameHelper { #endif APIError loop() override; APIError read_packet(ReadPacketBuffer *buffer) override; - APIError write_protobuf_packet(uint8_t type, ProtoWriteBuffer buffer) override; + APIError write_protobuf_packet(uint16_t type, ProtoWriteBuffer buffer) override; APIError write_protobuf_messages(ProtoWriteBuffer buffer, std::span messages) override; protected: @@ -44,7 +44,7 @@ class APINoiseFrameHelper final : public APIFrameHelper { APIError state_action_handshake_write_(); APIError try_read_frame_(); APIError write_frame_(const uint8_t *data, uint16_t len); - APIError encrypt_noise_message_(uint8_t *buf_start, uint16_t payload_size, uint8_t message_type, + APIError encrypt_noise_message_(uint8_t *buf_start, uint16_t payload_size, uint16_t message_type, uint16_t &encrypted_len_out); APIError init_handshake_(); APIError check_handshake_finished_(); diff --git a/esphome/components/api/api_frame_helper_plaintext.cpp b/esphome/components/api/api_frame_helper_plaintext.cpp index 9359f568fb..09ace7294a 100644 --- a/esphome/components/api/api_frame_helper_plaintext.cpp +++ b/esphome/components/api/api_frame_helper_plaintext.cpp @@ -5,6 +5,7 @@ #include "esphome/core/hal.h" #include "esphome/core/helpers.h" #include "esphome/core/log.h" +#include "api_pb2.h" #include "proto.h" #include #include @@ -252,24 +253,21 @@ ESPHOME_ALWAYS_INLINE static inline void encode_varint_16(uint16_t value, uint8_ *p = static_cast(value); } -// Encode an 8-bit varint (1-2 bytes) using pre-computed length. -ESPHOME_ALWAYS_INLINE static inline void encode_varint_8(uint8_t value, uint8_t varint_len, uint8_t *p) { - if (varint_len == 2) { - *p++ = static_cast(value | 0x80); - *p = static_cast(value >> 7); - } else { - *p = value; - } -} +// The generator rejects message IDs above MAX_MESSAGE_TYPE, so the type varint +// can never outgrow the 2 bytes HEADER_PADDING budgets for it. Without this +// bound, write_plaintext_header's header_offset would underflow for the first +// message in a batch and the header write would land outside the buffer. +static_assert(1 + 3 + ProtoSize::varint16(MAX_MESSAGE_TYPE) <= APIPlaintextFrameHelper::HEADER_PADDING, + "HEADER_PADDING cannot fit the type varint of the largest message ID"); // Write plaintext header into pre-allocated padding before payload. // padding_size: bytes reserved before payload (HEADER_PADDING for first/single msg, // actual header size for contiguous batch messages). // Returns the total header length (indicator + varints). ESPHOME_ALWAYS_INLINE static inline uint8_t write_plaintext_header(uint8_t *buf_start, uint16_t payload_size, - uint8_t message_type, uint8_t padding_size) { + uint16_t message_type, uint8_t padding_size) { uint8_t size_varint_len = ProtoSize::varint16(payload_size); - uint8_t type_varint_len = ProtoSize::varint8(message_type); + uint8_t type_varint_len = ProtoSize::varint16(message_type); uint8_t total_header_len = 1 + size_varint_len + type_varint_len; // The header is right-justified within the padding so it sits immediately before payload. @@ -292,12 +290,12 @@ ESPHOME_ALWAYS_INLINE static inline uint8_t write_plaintext_header(uint8_t *buf_ // Encode varints directly into buffer using pre-computed lengths encode_varint_16(payload_size, size_varint_len, buf_start + header_offset + 1); - encode_varint_8(message_type, type_varint_len, buf_start + header_offset + 1 + size_varint_len); + encode_varint_16(message_type, type_varint_len, buf_start + header_offset + 1 + size_varint_len); return total_header_len; } -APIError APIPlaintextFrameHelper::write_protobuf_packet(uint8_t type, ProtoWriteBuffer buffer) { +APIError APIPlaintextFrameHelper::write_protobuf_packet(uint16_t type, ProtoWriteBuffer buffer) { #ifdef ESPHOME_DEBUG_API assert(this->state_ == State::DATA); #endif diff --git a/esphome/components/api/api_frame_helper_plaintext.h b/esphome/components/api/api_frame_helper_plaintext.h index ea3f6d7280..00e7c7b1bc 100644 --- a/esphome/components/api/api_frame_helper_plaintext.h +++ b/esphome/components/api/api_frame_helper_plaintext.h @@ -10,7 +10,8 @@ class APIPlaintextFrameHelper final : public APIFrameHelper { // Plaintext header structure (worst case): // Pos 0: indicator (0x00) // Pos 1-3: payload size varint (up to 3 bytes) - // Pos 4-5: message type varint (up to 2 bytes) + // Pos 4-5: message type varint (up to 2 bytes; covers message IDs up to + // 16383, enforced by the proto codegen) // Pos 6+: actual payload data static constexpr uint8_t HEADER_PADDING = 1 + 3 + 2; // indicator + size varint + type varint @@ -21,7 +22,7 @@ class APIPlaintextFrameHelper final : public APIFrameHelper { APIError init() override; APIError loop() override; APIError read_packet(ReadPacketBuffer *buffer) override; - APIError write_protobuf_packet(uint8_t type, ProtoWriteBuffer buffer) override; + APIError write_protobuf_packet(uint16_t type, ProtoWriteBuffer buffer) override; APIError write_protobuf_messages(ProtoWriteBuffer buffer, std::span messages) override; #ifdef USE_API_NOISE // After try_read_frame_ returned PROTOCOL_SWITCH_TO_NOISE: copy out the diff --git a/esphome/components/api/api_pb2.h b/esphome/components/api/api_pb2.h index cd2f32deaf..48e277fce1 100644 --- a/esphome/components/api/api_pb2.h +++ b/esphome/components/api/api_pb2.h @@ -9,6 +9,10 @@ namespace esphome::api { +// Upper bound on message IDs, enforced by the code generator: the plaintext +// frame header budgets 2 varint bytes for the type (HEADER_PADDING). +static constexpr uint16_t MAX_MESSAGE_TYPE = 16383; + namespace enums { enum DisconnectReason : uint32_t { @@ -407,7 +411,7 @@ class CommandProtoMessage : public ProtoDecodableMessage { }; class HelloRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 1; + static constexpr uint16_t MESSAGE_TYPE = 1; static constexpr uint8_t ESTIMATED_SIZE = 17; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("hello_request"); } @@ -425,7 +429,7 @@ class HelloRequest final : public ProtoDecodableMessage { }; class HelloResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 2; + static constexpr uint16_t MESSAGE_TYPE = 2; static constexpr uint8_t ESTIMATED_SIZE = 26; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("hello_response"); } @@ -444,7 +448,7 @@ class HelloResponse final : public ProtoMessage { }; class DisconnectRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 5; + static constexpr uint16_t MESSAGE_TYPE = 5; static constexpr uint8_t ESTIMATED_SIZE = 2; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("disconnect_request"); } @@ -461,7 +465,7 @@ class DisconnectRequest final : public ProtoDecodableMessage { }; class DisconnectResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 6; + static constexpr uint16_t MESSAGE_TYPE = 6; static constexpr uint8_t ESTIMATED_SIZE = 0; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("disconnect_response"); } @@ -474,7 +478,7 @@ class DisconnectResponse final : public ProtoMessage { }; class PingRequest final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 7; + static constexpr uint16_t MESSAGE_TYPE = 7; static constexpr uint8_t ESTIMATED_SIZE = 0; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("ping_request"); } @@ -487,7 +491,7 @@ class PingRequest final : public ProtoMessage { }; class PingResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 8; + static constexpr uint16_t MESSAGE_TYPE = 8; static constexpr uint8_t ESTIMATED_SIZE = 0; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("ping_response"); } @@ -544,7 +548,7 @@ class SerialProxyInfo final : public ProtoMessage { #endif class DeviceInfoResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 10; + static constexpr uint16_t MESSAGE_TYPE = 10; static constexpr uint16_t ESTIMATED_SIZE = 312; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("device_info_response"); } @@ -655,7 +659,7 @@ class ZWaveProxyCapabilities final : public ProtoMessage { #endif class DeviceCapabilitiesResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 150; + static constexpr uint16_t MESSAGE_TYPE = 150; static constexpr uint8_t ESTIMATED_SIZE = 102; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("device_capabilities_response"); } @@ -682,7 +686,7 @@ class DeviceCapabilitiesResponse final : public ProtoMessage { }; class ListEntitiesDoneResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 19; + static constexpr uint16_t MESSAGE_TYPE = 19; static constexpr uint8_t ESTIMATED_SIZE = 0; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_done_response"); } @@ -696,7 +700,7 @@ class ListEntitiesDoneResponse final : public ProtoMessage { #ifdef USE_BINARY_SENSOR class ListEntitiesBinarySensorResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 12; + static constexpr uint16_t MESSAGE_TYPE = 12; static constexpr uint8_t ESTIMATED_SIZE = 51; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_binary_sensor_response"); } @@ -713,7 +717,7 @@ class ListEntitiesBinarySensorResponse final : public InfoResponseProtoMessage { }; class BinarySensorStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 21; + static constexpr uint16_t MESSAGE_TYPE = 21; static constexpr uint8_t ESTIMATED_SIZE = 13; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("binary_sensor_state_response"); } @@ -732,7 +736,7 @@ class BinarySensorStateResponse final : public StateResponseProtoMessage { #ifdef USE_COVER class ListEntitiesCoverResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 13; + static constexpr uint16_t MESSAGE_TYPE = 13; static constexpr uint8_t ESTIMATED_SIZE = 57; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_cover_response"); } @@ -752,7 +756,7 @@ class ListEntitiesCoverResponse final : public InfoResponseProtoMessage { }; class CoverStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 22; + static constexpr uint16_t MESSAGE_TYPE = 22; static constexpr uint8_t ESTIMATED_SIZE = 21; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("cover_state_response"); } @@ -770,7 +774,7 @@ class CoverStateResponse final : public StateResponseProtoMessage { }; class CoverCommandRequest final : public CommandProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 30; + static constexpr uint16_t MESSAGE_TYPE = 30; static constexpr uint8_t ESTIMATED_SIZE = 25; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("cover_command_request"); } @@ -792,7 +796,7 @@ class CoverCommandRequest final : public CommandProtoMessage { #ifdef USE_FAN class ListEntitiesFanResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 14; + static constexpr uint16_t MESSAGE_TYPE = 14; static constexpr uint8_t ESTIMATED_SIZE = 68; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_fan_response"); } @@ -812,7 +816,7 @@ class ListEntitiesFanResponse final : public InfoResponseProtoMessage { }; class FanStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 23; + static constexpr uint16_t MESSAGE_TYPE = 23; static constexpr uint8_t ESTIMATED_SIZE = 28; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("fan_state_response"); } @@ -832,7 +836,7 @@ class FanStateResponse final : public StateResponseProtoMessage { }; class FanCommandRequest final : public CommandProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 31; + static constexpr uint16_t MESSAGE_TYPE = 31; static constexpr uint8_t ESTIMATED_SIZE = 38; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("fan_command_request"); } @@ -860,7 +864,7 @@ class FanCommandRequest final : public CommandProtoMessage { #ifdef USE_LIGHT class ListEntitiesLightResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 15; + static constexpr uint16_t MESSAGE_TYPE = 15; static constexpr uint8_t ESTIMATED_SIZE = 73; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_light_response"); } @@ -879,7 +883,7 @@ class ListEntitiesLightResponse final : public InfoResponseProtoMessage { }; class LightStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 24; + static constexpr uint16_t MESSAGE_TYPE = 24; static constexpr uint8_t ESTIMATED_SIZE = 67; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("light_state_response"); } @@ -906,7 +910,7 @@ class LightStateResponse final : public StateResponseProtoMessage { }; class LightCommandRequest final : public CommandProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 32; + static constexpr uint16_t MESSAGE_TYPE = 32; static constexpr uint8_t ESTIMATED_SIZE = 112; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("light_command_request"); } @@ -950,7 +954,7 @@ class LightCommandRequest final : public CommandProtoMessage { #ifdef USE_SENSOR class ListEntitiesSensorResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 16; + static constexpr uint16_t MESSAGE_TYPE = 16; static constexpr uint8_t ESTIMATED_SIZE = 66; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_sensor_response"); } @@ -970,7 +974,7 @@ class ListEntitiesSensorResponse final : public InfoResponseProtoMessage { }; class SensorStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 25; + static constexpr uint16_t MESSAGE_TYPE = 25; static constexpr uint8_t ESTIMATED_SIZE = 16; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("sensor_state_response"); } @@ -989,7 +993,7 @@ class SensorStateResponse final : public StateResponseProtoMessage { #ifdef USE_SWITCH class ListEntitiesSwitchResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 17; + static constexpr uint16_t MESSAGE_TYPE = 17; static constexpr uint8_t ESTIMATED_SIZE = 51; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_switch_response"); } @@ -1006,7 +1010,7 @@ class ListEntitiesSwitchResponse final : public InfoResponseProtoMessage { }; class SwitchStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 26; + static constexpr uint16_t MESSAGE_TYPE = 26; static constexpr uint8_t ESTIMATED_SIZE = 11; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("switch_state_response"); } @@ -1022,7 +1026,7 @@ class SwitchStateResponse final : public StateResponseProtoMessage { }; class SwitchCommandRequest final : public CommandProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 33; + static constexpr uint16_t MESSAGE_TYPE = 33; static constexpr uint8_t ESTIMATED_SIZE = 11; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("switch_command_request"); } @@ -1040,7 +1044,7 @@ class SwitchCommandRequest final : public CommandProtoMessage { #ifdef USE_TEXT_SENSOR class ListEntitiesTextSensorResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 18; + static constexpr uint16_t MESSAGE_TYPE = 18; static constexpr uint8_t ESTIMATED_SIZE = 49; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_text_sensor_response"); } @@ -1056,7 +1060,7 @@ class ListEntitiesTextSensorResponse final : public InfoResponseProtoMessage { }; class TextSensorStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 27; + static constexpr uint16_t MESSAGE_TYPE = 27; static constexpr uint8_t ESTIMATED_SIZE = 20; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("text_sensor_state_response"); } @@ -1074,7 +1078,7 @@ class TextSensorStateResponse final : public StateResponseProtoMessage { #endif class SubscribeLogsRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 28; + static constexpr uint16_t MESSAGE_TYPE = 28; static constexpr uint8_t ESTIMATED_SIZE = 4; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("subscribe_logs_request"); } @@ -1090,7 +1094,7 @@ class SubscribeLogsRequest final : public ProtoDecodableMessage { }; class SubscribeLogsResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 29; + static constexpr uint16_t MESSAGE_TYPE = 29; static constexpr uint8_t ESTIMATED_SIZE = 21; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("subscribe_logs_response"); } @@ -1113,7 +1117,7 @@ class SubscribeLogsResponse final : public ProtoMessage { #ifdef USE_API_NOISE class NoiseEncryptionSetKeyRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 124; + static constexpr uint16_t MESSAGE_TYPE = 124; static constexpr uint8_t ESTIMATED_SIZE = 19; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("noise_encryption_set_key_request"); } @@ -1129,7 +1133,7 @@ class NoiseEncryptionSetKeyRequest final : public ProtoDecodableMessage { }; class NoiseEncryptionSetKeyResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 125; + static constexpr uint16_t MESSAGE_TYPE = 125; static constexpr uint8_t ESTIMATED_SIZE = 2; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("noise_encryption_set_key_response"); } @@ -1159,7 +1163,7 @@ class HomeassistantServiceMap final : public ProtoMessage { }; class HomeassistantActionRequest final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 35; + static constexpr uint16_t MESSAGE_TYPE = 35; static constexpr uint8_t ESTIMATED_SIZE = 128; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("homeassistant_action_request"); } @@ -1190,7 +1194,7 @@ class HomeassistantActionRequest final : public ProtoMessage { #ifdef USE_API_HOMEASSISTANT_ACTION_RESPONSES class HomeassistantActionResponse final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 130; + static constexpr uint16_t MESSAGE_TYPE = 130; static constexpr uint8_t ESTIMATED_SIZE = 34; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("homeassistant_action_response"); } @@ -1214,7 +1218,7 @@ class HomeassistantActionResponse final : public ProtoDecodableMessage { #ifdef USE_API_HOMEASSISTANT_STATES class SubscribeHomeAssistantStateResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 39; + static constexpr uint16_t MESSAGE_TYPE = 39; static constexpr uint8_t ESTIMATED_SIZE = 20; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("subscribe_home_assistant_state_response"); } @@ -1232,7 +1236,7 @@ class SubscribeHomeAssistantStateResponse final : public ProtoMessage { }; class HomeAssistantStateResponse final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 40; + static constexpr uint16_t MESSAGE_TYPE = 40; static constexpr uint8_t ESTIMATED_SIZE = 27; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("home_assistant_state_response"); } @@ -1250,7 +1254,7 @@ class HomeAssistantStateResponse final : public ProtoDecodableMessage { #endif class GetTimeRequest final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 36; + static constexpr uint16_t MESSAGE_TYPE = 36; static constexpr uint8_t ESTIMATED_SIZE = 0; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("get_time_request"); } @@ -1292,7 +1296,7 @@ class ParsedTimezone final : public ProtoDecodableMessage { }; class GetTimeResponse final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 37; + static constexpr uint16_t MESSAGE_TYPE = 37; static constexpr uint8_t ESTIMATED_SIZE = 22; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("get_time_response"); } @@ -1323,7 +1327,7 @@ class ListEntitiesServicesArgument final : public ProtoMessage { }; class ListEntitiesServicesResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 41; + static constexpr uint16_t MESSAGE_TYPE = 41; static constexpr uint8_t ESTIMATED_SIZE = 50; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_services_response"); } @@ -1363,7 +1367,7 @@ class ExecuteServiceArgument final : public ProtoDecodableMessage { }; class ExecuteServiceRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 42; + static constexpr uint16_t MESSAGE_TYPE = 42; static constexpr uint8_t ESTIMATED_SIZE = 45; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("execute_service_request"); } @@ -1390,7 +1394,7 @@ class ExecuteServiceRequest final : public ProtoDecodableMessage { #ifdef USE_API_USER_DEFINED_ACTION_RESPONSES class ExecuteServiceResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 131; + static constexpr uint16_t MESSAGE_TYPE = 131; static constexpr uint8_t ESTIMATED_SIZE = 34; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("execute_service_response"); } @@ -1414,7 +1418,7 @@ class ExecuteServiceResponse final : public ProtoMessage { #ifdef USE_CAMERA class ListEntitiesCameraResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 43; + static constexpr uint16_t MESSAGE_TYPE = 43; static constexpr uint8_t ESTIMATED_SIZE = 40; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_camera_response"); } @@ -1429,7 +1433,7 @@ class ListEntitiesCameraResponse final : public InfoResponseProtoMessage { }; class CameraImageResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 44; + static constexpr uint16_t MESSAGE_TYPE = 44; static constexpr uint8_t ESTIMATED_SIZE = 30; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("camera_image_response"); } @@ -1451,7 +1455,7 @@ class CameraImageResponse final : public StateResponseProtoMessage { }; class CameraImageRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 45; + static constexpr uint16_t MESSAGE_TYPE = 45; static constexpr uint8_t ESTIMATED_SIZE = 4; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("camera_image_request"); } @@ -1469,7 +1473,7 @@ class CameraImageRequest final : public ProtoDecodableMessage { #ifdef USE_CLIMATE class ListEntitiesClimateResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 46; + static constexpr uint16_t MESSAGE_TYPE = 46; static constexpr uint8_t ESTIMATED_SIZE = 153; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_climate_response"); } @@ -1503,7 +1507,7 @@ class ListEntitiesClimateResponse final : public InfoResponseProtoMessage { }; class ClimateStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 47; + static constexpr uint16_t MESSAGE_TYPE = 47; static constexpr uint8_t ESTIMATED_SIZE = 68; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("climate_state_response"); } @@ -1531,7 +1535,7 @@ class ClimateStateResponse final : public StateResponseProtoMessage { }; class ClimateCommandRequest final : public CommandProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 48; + static constexpr uint16_t MESSAGE_TYPE = 48; static constexpr uint8_t ESTIMATED_SIZE = 84; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("climate_command_request"); } @@ -1569,7 +1573,7 @@ class ClimateCommandRequest final : public CommandProtoMessage { #ifdef USE_WATER_HEATER class ListEntitiesWaterHeaterResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 132; + static constexpr uint16_t MESSAGE_TYPE = 132; static constexpr uint8_t ESTIMATED_SIZE = 65; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_water_heater_response"); } @@ -1590,7 +1594,7 @@ class ListEntitiesWaterHeaterResponse final : public InfoResponseProtoMessage { }; class WaterHeaterStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 133; + static constexpr uint16_t MESSAGE_TYPE = 133; static constexpr uint8_t ESTIMATED_SIZE = 35; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("water_heater_state_response"); } @@ -1611,7 +1615,7 @@ class WaterHeaterStateResponse final : public StateResponseProtoMessage { }; class WaterHeaterCommandRequest final : public CommandProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 134; + static constexpr uint16_t MESSAGE_TYPE = 134; static constexpr uint8_t ESTIMATED_SIZE = 34; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("water_heater_command_request"); } @@ -1634,7 +1638,7 @@ class WaterHeaterCommandRequest final : public CommandProtoMessage { #ifdef USE_NUMBER class ListEntitiesNumberResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 49; + static constexpr uint16_t MESSAGE_TYPE = 49; static constexpr uint8_t ESTIMATED_SIZE = 75; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_number_response"); } @@ -1655,7 +1659,7 @@ class ListEntitiesNumberResponse final : public InfoResponseProtoMessage { }; class NumberStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 50; + static constexpr uint16_t MESSAGE_TYPE = 50; static constexpr uint8_t ESTIMATED_SIZE = 16; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("number_state_response"); } @@ -1672,7 +1676,7 @@ class NumberStateResponse final : public StateResponseProtoMessage { }; class NumberCommandRequest final : public CommandProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 51; + static constexpr uint16_t MESSAGE_TYPE = 51; static constexpr uint8_t ESTIMATED_SIZE = 14; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("number_command_request"); } @@ -1690,7 +1694,7 @@ class NumberCommandRequest final : public CommandProtoMessage { #ifdef USE_SELECT class ListEntitiesSelectResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 52; + static constexpr uint16_t MESSAGE_TYPE = 52; static constexpr uint8_t ESTIMATED_SIZE = 58; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_select_response"); } @@ -1706,7 +1710,7 @@ class ListEntitiesSelectResponse final : public InfoResponseProtoMessage { }; class SelectStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 53; + static constexpr uint16_t MESSAGE_TYPE = 53; static constexpr uint8_t ESTIMATED_SIZE = 20; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("select_state_response"); } @@ -1723,7 +1727,7 @@ class SelectStateResponse final : public StateResponseProtoMessage { }; class SelectCommandRequest final : public CommandProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 54; + static constexpr uint16_t MESSAGE_TYPE = 54; static constexpr uint8_t ESTIMATED_SIZE = 18; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("select_command_request"); } @@ -1742,7 +1746,7 @@ class SelectCommandRequest final : public CommandProtoMessage { #ifdef USE_SIREN class ListEntitiesSirenResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 55; + static constexpr uint16_t MESSAGE_TYPE = 55; static constexpr uint8_t ESTIMATED_SIZE = 62; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_siren_response"); } @@ -1760,7 +1764,7 @@ class ListEntitiesSirenResponse final : public InfoResponseProtoMessage { }; class SirenStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 56; + static constexpr uint16_t MESSAGE_TYPE = 56; static constexpr uint8_t ESTIMATED_SIZE = 11; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("siren_state_response"); } @@ -1776,7 +1780,7 @@ class SirenStateResponse final : public StateResponseProtoMessage { }; class SirenCommandRequest final : public CommandProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 57; + static constexpr uint16_t MESSAGE_TYPE = 57; static constexpr uint8_t ESTIMATED_SIZE = 37; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("siren_command_request"); } @@ -1802,7 +1806,7 @@ class SirenCommandRequest final : public CommandProtoMessage { #ifdef USE_LOCK class ListEntitiesLockResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 58; + static constexpr uint16_t MESSAGE_TYPE = 58; static constexpr uint8_t ESTIMATED_SIZE = 55; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_lock_response"); } @@ -1821,7 +1825,7 @@ class ListEntitiesLockResponse final : public InfoResponseProtoMessage { }; class LockStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 59; + static constexpr uint16_t MESSAGE_TYPE = 59; static constexpr uint8_t ESTIMATED_SIZE = 11; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("lock_state_response"); } @@ -1837,7 +1841,7 @@ class LockStateResponse final : public StateResponseProtoMessage { }; class LockCommandRequest final : public CommandProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 60; + static constexpr uint16_t MESSAGE_TYPE = 60; static constexpr uint8_t ESTIMATED_SIZE = 22; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("lock_command_request"); } @@ -1858,7 +1862,7 @@ class LockCommandRequest final : public CommandProtoMessage { #ifdef USE_BUTTON class ListEntitiesButtonResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 61; + static constexpr uint16_t MESSAGE_TYPE = 61; static constexpr uint8_t ESTIMATED_SIZE = 49; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_button_response"); } @@ -1874,7 +1878,7 @@ class ListEntitiesButtonResponse final : public InfoResponseProtoMessage { }; class ButtonCommandRequest final : public CommandProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 62; + static constexpr uint16_t MESSAGE_TYPE = 62; static constexpr uint8_t ESTIMATED_SIZE = 9; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("button_command_request"); } @@ -1906,7 +1910,7 @@ class MediaPlayerSupportedFormat final : public ProtoMessage { }; class ListEntitiesMediaPlayerResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 63; + static constexpr uint16_t MESSAGE_TYPE = 63; static constexpr uint8_t ESTIMATED_SIZE = 80; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_media_player_response"); } @@ -1924,7 +1928,7 @@ class ListEntitiesMediaPlayerResponse final : public InfoResponseProtoMessage { }; class MediaPlayerStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 64; + static constexpr uint16_t MESSAGE_TYPE = 64; static constexpr uint8_t ESTIMATED_SIZE = 18; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("media_player_state_response"); } @@ -1942,7 +1946,7 @@ class MediaPlayerStateResponse final : public StateResponseProtoMessage { }; class MediaPlayerCommandRequest final : public CommandProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 65; + static constexpr uint16_t MESSAGE_TYPE = 65; static constexpr uint8_t ESTIMATED_SIZE = 35; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("media_player_command_request"); } @@ -1968,7 +1972,7 @@ class MediaPlayerCommandRequest final : public CommandProtoMessage { #ifdef USE_BLUETOOTH_PROXY class SubscribeBluetoothLEAdvertisementsRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 66; + static constexpr uint16_t MESSAGE_TYPE = 66; static constexpr uint8_t ESTIMATED_SIZE = 4; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("subscribe_bluetooth_le_advertisements_request"); } @@ -1996,7 +2000,7 @@ class BluetoothLERawAdvertisement final : public ProtoMessage { }; class BluetoothLERawAdvertisementsResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 93; + static constexpr uint16_t MESSAGE_TYPE = 93; static constexpr uint8_t ESTIMATED_SIZE = 136; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_le_raw_advertisements_response"); } @@ -2015,7 +2019,7 @@ class BluetoothLERawAdvertisementsResponse final : public ProtoMessage { #ifdef USE_BLUETOOTH_PROXY_CONNECTIONS class BluetoothDeviceRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 68; + static constexpr uint16_t MESSAGE_TYPE = 68; static constexpr uint8_t ESTIMATED_SIZE = 12; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_device_request"); } @@ -2033,7 +2037,7 @@ class BluetoothDeviceRequest final : public ProtoDecodableMessage { }; class BluetoothDeviceConnectionResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 69; + static constexpr uint16_t MESSAGE_TYPE = 69; static constexpr uint8_t ESTIMATED_SIZE = 14; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_device_connection_response"); } @@ -2052,7 +2056,7 @@ class BluetoothDeviceConnectionResponse final : public ProtoMessage { }; class BluetoothGATTGetServicesRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 70; + static constexpr uint16_t MESSAGE_TYPE = 70; static constexpr uint8_t ESTIMATED_SIZE = 4; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_gatt_get_services_request"); } @@ -2109,7 +2113,7 @@ class BluetoothGATTService final : public ProtoMessage { }; class BluetoothGATTGetServicesResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 71; + static constexpr uint16_t MESSAGE_TYPE = 71; static constexpr uint8_t ESTIMATED_SIZE = 38; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_gatt_get_services_response"); } @@ -2126,7 +2130,7 @@ class BluetoothGATTGetServicesResponse final : public ProtoMessage { }; class BluetoothGATTGetServicesDoneResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 72; + static constexpr uint16_t MESSAGE_TYPE = 72; static constexpr uint8_t ESTIMATED_SIZE = 4; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_gatt_get_services_done_response"); } @@ -2142,7 +2146,7 @@ class BluetoothGATTGetServicesDoneResponse final : public ProtoMessage { }; class BluetoothGATTReadRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 73; + static constexpr uint16_t MESSAGE_TYPE = 73; static constexpr uint8_t ESTIMATED_SIZE = 8; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_gatt_read_request"); } @@ -2158,7 +2162,7 @@ class BluetoothGATTReadRequest final : public ProtoDecodableMessage { }; class BluetoothGATTReadResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 74; + static constexpr uint16_t MESSAGE_TYPE = 74; static constexpr uint8_t ESTIMATED_SIZE = 27; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_gatt_read_response"); } @@ -2181,7 +2185,7 @@ class BluetoothGATTReadResponse final : public ProtoMessage { }; class BluetoothGATTWriteRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 75; + static constexpr uint16_t MESSAGE_TYPE = 75; static constexpr uint8_t ESTIMATED_SIZE = 29; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_gatt_write_request"); } @@ -2201,7 +2205,7 @@ class BluetoothGATTWriteRequest final : public ProtoDecodableMessage { }; class BluetoothGATTReadDescriptorRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 76; + static constexpr uint16_t MESSAGE_TYPE = 76; static constexpr uint8_t ESTIMATED_SIZE = 8; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_gatt_read_descriptor_request"); } @@ -2217,7 +2221,7 @@ class BluetoothGATTReadDescriptorRequest final : public ProtoDecodableMessage { }; class BluetoothGATTWriteDescriptorRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 77; + static constexpr uint16_t MESSAGE_TYPE = 77; static constexpr uint8_t ESTIMATED_SIZE = 27; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_gatt_write_descriptor_request"); } @@ -2236,7 +2240,7 @@ class BluetoothGATTWriteDescriptorRequest final : public ProtoDecodableMessage { }; class BluetoothGATTNotifyRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 78; + static constexpr uint16_t MESSAGE_TYPE = 78; static constexpr uint8_t ESTIMATED_SIZE = 10; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_gatt_notify_request"); } @@ -2253,7 +2257,7 @@ class BluetoothGATTNotifyRequest final : public ProtoDecodableMessage { }; class BluetoothGATTNotifyDataResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 79; + static constexpr uint16_t MESSAGE_TYPE = 79; static constexpr uint8_t ESTIMATED_SIZE = 27; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_gatt_notify_data_response"); } @@ -2276,7 +2280,7 @@ class BluetoothGATTNotifyDataResponse final : public ProtoMessage { }; class BluetoothConnectionsFreeResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 81; + static constexpr uint16_t MESSAGE_TYPE = 81; static constexpr uint8_t ESTIMATED_SIZE = 20; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_connections_free_response"); } @@ -2294,7 +2298,7 @@ class BluetoothConnectionsFreeResponse final : public ProtoMessage { }; class BluetoothGATTErrorResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 82; + static constexpr uint16_t MESSAGE_TYPE = 82; static constexpr uint8_t ESTIMATED_SIZE = 12; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_gatt_error_response"); } @@ -2312,7 +2316,7 @@ class BluetoothGATTErrorResponse final : public ProtoMessage { }; class BluetoothGATTWriteResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 83; + static constexpr uint16_t MESSAGE_TYPE = 83; static constexpr uint8_t ESTIMATED_SIZE = 8; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_gatt_write_response"); } @@ -2329,7 +2333,7 @@ class BluetoothGATTWriteResponse final : public ProtoMessage { }; class BluetoothGATTNotifyResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 84; + static constexpr uint16_t MESSAGE_TYPE = 84; static constexpr uint8_t ESTIMATED_SIZE = 8; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_gatt_notify_response"); } @@ -2346,7 +2350,7 @@ class BluetoothGATTNotifyResponse final : public ProtoMessage { }; class BluetoothDevicePairingResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 85; + static constexpr uint16_t MESSAGE_TYPE = 85; static constexpr uint8_t ESTIMATED_SIZE = 10; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_device_pairing_response"); } @@ -2364,7 +2368,7 @@ class BluetoothDevicePairingResponse final : public ProtoMessage { }; class BluetoothDeviceUnpairingResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 86; + static constexpr uint16_t MESSAGE_TYPE = 86; static constexpr uint8_t ESTIMATED_SIZE = 10; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_device_unpairing_response"); } @@ -2382,7 +2386,7 @@ class BluetoothDeviceUnpairingResponse final : public ProtoMessage { }; class BluetoothDeviceClearCacheResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 88; + static constexpr uint16_t MESSAGE_TYPE = 88; static constexpr uint8_t ESTIMATED_SIZE = 10; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_device_clear_cache_response"); } @@ -2402,7 +2406,7 @@ class BluetoothDeviceClearCacheResponse final : public ProtoMessage { #ifdef USE_BLUETOOTH_PROXY class BluetoothScannerStateResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 126; + static constexpr uint16_t MESSAGE_TYPE = 126; static constexpr uint8_t ESTIMATED_SIZE = 6; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_scanner_state_response"); } @@ -2420,7 +2424,7 @@ class BluetoothScannerStateResponse final : public ProtoMessage { }; class BluetoothScannerSetModeRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 127; + static constexpr uint16_t MESSAGE_TYPE = 127; static constexpr uint8_t ESTIMATED_SIZE = 2; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_scanner_set_mode_request"); } @@ -2437,7 +2441,7 @@ class BluetoothScannerSetModeRequest final : public ProtoDecodableMessage { #ifdef USE_VOICE_ASSISTANT class SubscribeVoiceAssistantRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 89; + static constexpr uint16_t MESSAGE_TYPE = 89; static constexpr uint8_t ESTIMATED_SIZE = 6; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("subscribe_voice_assistant_request"); } @@ -2466,7 +2470,7 @@ class VoiceAssistantAudioSettings final : public ProtoMessage { }; class VoiceAssistantRequest final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 90; + static constexpr uint16_t MESSAGE_TYPE = 90; static constexpr uint8_t ESTIMATED_SIZE = 41; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("voice_assistant_request"); } @@ -2486,7 +2490,7 @@ class VoiceAssistantRequest final : public ProtoMessage { }; class VoiceAssistantResponse final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 91; + static constexpr uint16_t MESSAGE_TYPE = 91; static constexpr uint8_t ESTIMATED_SIZE = 6; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("voice_assistant_response"); } @@ -2513,7 +2517,7 @@ class VoiceAssistantEventData final : public ProtoDecodableMessage { }; class VoiceAssistantEventResponse final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 92; + static constexpr uint16_t MESSAGE_TYPE = 92; static constexpr uint8_t ESTIMATED_SIZE = 36; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("voice_assistant_event_response"); } @@ -2530,7 +2534,7 @@ class VoiceAssistantEventResponse final : public ProtoDecodableMessage { }; class VoiceAssistantAudio final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 106; + static constexpr uint16_t MESSAGE_TYPE = 106; static constexpr uint8_t ESTIMATED_SIZE = 40; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("voice_assistant_audio"); } @@ -2552,7 +2556,7 @@ class VoiceAssistantAudio final : public ProtoDecodableMessage { }; class VoiceAssistantTimerEventResponse final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 115; + static constexpr uint16_t MESSAGE_TYPE = 115; static constexpr uint8_t ESTIMATED_SIZE = 30; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("voice_assistant_timer_event_response"); } @@ -2573,7 +2577,7 @@ class VoiceAssistantTimerEventResponse final : public ProtoDecodableMessage { }; class VoiceAssistantAnnounceRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 119; + static constexpr uint16_t MESSAGE_TYPE = 119; static constexpr uint8_t ESTIMATED_SIZE = 29; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("voice_assistant_announce_request"); } @@ -2592,7 +2596,7 @@ class VoiceAssistantAnnounceRequest final : public ProtoDecodableMessage { }; class VoiceAssistantAnnounceFinished final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 120; + static constexpr uint16_t MESSAGE_TYPE = 120; static constexpr uint8_t ESTIMATED_SIZE = 2; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("voice_assistant_announce_finished"); } @@ -2638,7 +2642,7 @@ class VoiceAssistantExternalWakeWord final : public ProtoDecodableMessage { }; class VoiceAssistantConfigurationRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 121; + static constexpr uint16_t MESSAGE_TYPE = 121; static constexpr uint8_t ESTIMATED_SIZE = 34; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("voice_assistant_configuration_request"); } @@ -2653,7 +2657,7 @@ class VoiceAssistantConfigurationRequest final : public ProtoDecodableMessage { }; class VoiceAssistantConfigurationResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 122; + static constexpr uint16_t MESSAGE_TYPE = 122; static constexpr uint8_t ESTIMATED_SIZE = 56; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("voice_assistant_configuration_response"); } @@ -2671,7 +2675,7 @@ class VoiceAssistantConfigurationResponse final : public ProtoMessage { }; class VoiceAssistantSetConfiguration final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 123; + static constexpr uint16_t MESSAGE_TYPE = 123; static constexpr uint8_t ESTIMATED_SIZE = 18; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("voice_assistant_set_configuration"); } @@ -2688,7 +2692,7 @@ class VoiceAssistantSetConfiguration final : public ProtoDecodableMessage { #ifdef USE_ALARM_CONTROL_PANEL class ListEntitiesAlarmControlPanelResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 94; + static constexpr uint16_t MESSAGE_TYPE = 94; static constexpr uint8_t ESTIMATED_SIZE = 48; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_alarm_control_panel_response"); } @@ -2706,7 +2710,7 @@ class ListEntitiesAlarmControlPanelResponse final : public InfoResponseProtoMess }; class AlarmControlPanelStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 95; + static constexpr uint16_t MESSAGE_TYPE = 95; static constexpr uint8_t ESTIMATED_SIZE = 11; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("alarm_control_panel_state_response"); } @@ -2722,7 +2726,7 @@ class AlarmControlPanelStateResponse final : public StateResponseProtoMessage { }; class AlarmControlPanelCommandRequest final : public CommandProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 96; + static constexpr uint16_t MESSAGE_TYPE = 96; static constexpr uint8_t ESTIMATED_SIZE = 20; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("alarm_control_panel_command_request"); } @@ -2742,7 +2746,7 @@ class AlarmControlPanelCommandRequest final : public CommandProtoMessage { #ifdef USE_TEXT class ListEntitiesTextResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 97; + static constexpr uint16_t MESSAGE_TYPE = 97; static constexpr uint8_t ESTIMATED_SIZE = 59; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_text_response"); } @@ -2761,7 +2765,7 @@ class ListEntitiesTextResponse final : public InfoResponseProtoMessage { }; class TextStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 98; + static constexpr uint16_t MESSAGE_TYPE = 98; static constexpr uint8_t ESTIMATED_SIZE = 20; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("text_state_response"); } @@ -2778,7 +2782,7 @@ class TextStateResponse final : public StateResponseProtoMessage { }; class TextCommandRequest final : public CommandProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 99; + static constexpr uint16_t MESSAGE_TYPE = 99; static constexpr uint8_t ESTIMATED_SIZE = 18; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("text_command_request"); } @@ -2797,7 +2801,7 @@ class TextCommandRequest final : public CommandProtoMessage { #ifdef USE_DATETIME_DATE class ListEntitiesDateResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 100; + static constexpr uint16_t MESSAGE_TYPE = 100; static constexpr uint8_t ESTIMATED_SIZE = 40; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_date_response"); } @@ -2812,7 +2816,7 @@ class ListEntitiesDateResponse final : public InfoResponseProtoMessage { }; class DateStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 101; + static constexpr uint16_t MESSAGE_TYPE = 101; static constexpr uint8_t ESTIMATED_SIZE = 23; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("date_state_response"); } @@ -2831,7 +2835,7 @@ class DateStateResponse final : public StateResponseProtoMessage { }; class DateCommandRequest final : public CommandProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 102; + static constexpr uint16_t MESSAGE_TYPE = 102; static constexpr uint8_t ESTIMATED_SIZE = 21; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("date_command_request"); } @@ -2851,7 +2855,7 @@ class DateCommandRequest final : public CommandProtoMessage { #ifdef USE_DATETIME_TIME class ListEntitiesTimeResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 103; + static constexpr uint16_t MESSAGE_TYPE = 103; static constexpr uint8_t ESTIMATED_SIZE = 40; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_time_response"); } @@ -2866,7 +2870,7 @@ class ListEntitiesTimeResponse final : public InfoResponseProtoMessage { }; class TimeStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 104; + static constexpr uint16_t MESSAGE_TYPE = 104; static constexpr uint8_t ESTIMATED_SIZE = 23; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("time_state_response"); } @@ -2885,7 +2889,7 @@ class TimeStateResponse final : public StateResponseProtoMessage { }; class TimeCommandRequest final : public CommandProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 105; + static constexpr uint16_t MESSAGE_TYPE = 105; static constexpr uint8_t ESTIMATED_SIZE = 21; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("time_command_request"); } @@ -2905,7 +2909,7 @@ class TimeCommandRequest final : public CommandProtoMessage { #ifdef USE_EVENT class ListEntitiesEventResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 107; + static constexpr uint16_t MESSAGE_TYPE = 107; static constexpr uint8_t ESTIMATED_SIZE = 67; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_event_response"); } @@ -2922,7 +2926,7 @@ class ListEntitiesEventResponse final : public InfoResponseProtoMessage { }; class EventResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 108; + static constexpr uint16_t MESSAGE_TYPE = 108; static constexpr uint8_t ESTIMATED_SIZE = 18; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("event_response"); } @@ -2940,7 +2944,7 @@ class EventResponse final : public StateResponseProtoMessage { #ifdef USE_VALVE class ListEntitiesValveResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 109; + static constexpr uint16_t MESSAGE_TYPE = 109; static constexpr uint8_t ESTIMATED_SIZE = 55; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_valve_response"); } @@ -2959,7 +2963,7 @@ class ListEntitiesValveResponse final : public InfoResponseProtoMessage { }; class ValveStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 110; + static constexpr uint16_t MESSAGE_TYPE = 110; static constexpr uint8_t ESTIMATED_SIZE = 16; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("valve_state_response"); } @@ -2976,7 +2980,7 @@ class ValveStateResponse final : public StateResponseProtoMessage { }; class ValveCommandRequest final : public CommandProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 111; + static constexpr uint16_t MESSAGE_TYPE = 111; static constexpr uint8_t ESTIMATED_SIZE = 18; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("valve_command_request"); } @@ -2996,7 +3000,7 @@ class ValveCommandRequest final : public CommandProtoMessage { #ifdef USE_DATETIME_DATETIME class ListEntitiesDateTimeResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 112; + static constexpr uint16_t MESSAGE_TYPE = 112; static constexpr uint8_t ESTIMATED_SIZE = 40; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_date_time_response"); } @@ -3011,7 +3015,7 @@ class ListEntitiesDateTimeResponse final : public InfoResponseProtoMessage { }; class DateTimeStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 113; + static constexpr uint16_t MESSAGE_TYPE = 113; static constexpr uint8_t ESTIMATED_SIZE = 16; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("date_time_state_response"); } @@ -3028,7 +3032,7 @@ class DateTimeStateResponse final : public StateResponseProtoMessage { }; class DateTimeCommandRequest final : public CommandProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 114; + static constexpr uint16_t MESSAGE_TYPE = 114; static constexpr uint8_t ESTIMATED_SIZE = 14; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("date_time_command_request"); } @@ -3046,7 +3050,7 @@ class DateTimeCommandRequest final : public CommandProtoMessage { #ifdef USE_UPDATE class ListEntitiesUpdateResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 116; + static constexpr uint16_t MESSAGE_TYPE = 116; static constexpr uint8_t ESTIMATED_SIZE = 49; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_update_response"); } @@ -3062,7 +3066,7 @@ class ListEntitiesUpdateResponse final : public InfoResponseProtoMessage { }; class UpdateStateResponse final : public StateResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 117; + static constexpr uint16_t MESSAGE_TYPE = 117; static constexpr uint8_t ESTIMATED_SIZE = 65; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("update_state_response"); } @@ -3086,7 +3090,7 @@ class UpdateStateResponse final : public StateResponseProtoMessage { }; class UpdateCommandRequest final : public CommandProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 118; + static constexpr uint16_t MESSAGE_TYPE = 118; static constexpr uint8_t ESTIMATED_SIZE = 11; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("update_command_request"); } @@ -3104,7 +3108,7 @@ class UpdateCommandRequest final : public CommandProtoMessage { #ifdef USE_ZWAVE_PROXY class ZWaveProxyFrame final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 128; + static constexpr uint16_t MESSAGE_TYPE = 128; static constexpr uint8_t ESTIMATED_SIZE = 19; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("z_wave_proxy_frame"); } @@ -3122,7 +3126,7 @@ class ZWaveProxyFrame final : public ProtoDecodableMessage { }; class ZWaveProxyRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 129; + static constexpr uint16_t MESSAGE_TYPE = 129; static constexpr uint8_t ESTIMATED_SIZE = 21; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("z_wave_proxy_request"); } @@ -3142,7 +3146,7 @@ class ZWaveProxyRequest final : public ProtoDecodableMessage { }; class ZWaveProxyRequestResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 151; + static constexpr uint16_t MESSAGE_TYPE = 151; static constexpr uint8_t ESTIMATED_SIZE = 4; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("z_wave_proxy_request_response"); } @@ -3161,7 +3165,7 @@ class ZWaveProxyRequestResponse final : public ProtoMessage { #ifdef USE_INFRARED class ListEntitiesInfraredResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 135; + static constexpr uint16_t MESSAGE_TYPE = 135; static constexpr uint8_t ESTIMATED_SIZE = 48; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_infrared_response"); } @@ -3180,7 +3184,7 @@ class ListEntitiesInfraredResponse final : public InfoResponseProtoMessage { #if defined(USE_IR_RF) || defined(USE_RADIO_FREQUENCY) class InfraredRFTransmitRawTimingsRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 136; + static constexpr uint16_t MESSAGE_TYPE = 136; static constexpr uint8_t ESTIMATED_SIZE = 224; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("infrared_rf_transmit_raw_timings_request"); } @@ -3206,7 +3210,7 @@ class InfraredRFTransmitRawTimingsRequest final : public ProtoDecodableMessage { }; class InfraredRFReceiveEvent final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 137; + static constexpr uint16_t MESSAGE_TYPE = 137; static constexpr uint8_t ESTIMATED_SIZE = 17; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("infrared_rf_receive_event"); } @@ -3228,7 +3232,7 @@ class InfraredRFReceiveEvent final : public ProtoMessage { #ifdef USE_RADIO_FREQUENCY class ListEntitiesRadioFrequencyResponse final : public InfoResponseProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 148; + static constexpr uint16_t MESSAGE_TYPE = 148; static constexpr uint8_t ESTIMATED_SIZE = 56; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("list_entities_radio_frequency_response"); } @@ -3249,7 +3253,7 @@ class ListEntitiesRadioFrequencyResponse final : public InfoResponseProtoMessage #ifdef USE_SERIAL_PROXY class SerialProxyConfigureRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 138; + static constexpr uint16_t MESSAGE_TYPE = 138; static constexpr uint8_t ESTIMATED_SIZE = 20; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("serial_proxy_configure_request"); } @@ -3269,7 +3273,7 @@ class SerialProxyConfigureRequest final : public ProtoDecodableMessage { }; class SerialProxyDataReceived final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 139; + static constexpr uint16_t MESSAGE_TYPE = 139; static constexpr uint8_t ESTIMATED_SIZE = 23; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("serial_proxy_data_received"); } @@ -3291,7 +3295,7 @@ class SerialProxyDataReceived final : public ProtoMessage { }; class SerialProxyWriteRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 140; + static constexpr uint16_t MESSAGE_TYPE = 140; static constexpr uint8_t ESTIMATED_SIZE = 23; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("serial_proxy_write_request"); } @@ -3309,7 +3313,7 @@ class SerialProxyWriteRequest final : public ProtoDecodableMessage { }; class SerialProxySetModemPinsRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 141; + static constexpr uint16_t MESSAGE_TYPE = 141; static constexpr uint8_t ESTIMATED_SIZE = 8; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("serial_proxy_set_modem_pins_request"); } @@ -3325,7 +3329,7 @@ class SerialProxySetModemPinsRequest final : public ProtoDecodableMessage { }; class SerialProxyGetModemPinsRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 142; + static constexpr uint16_t MESSAGE_TYPE = 142; static constexpr uint8_t ESTIMATED_SIZE = 4; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("serial_proxy_get_modem_pins_request"); } @@ -3340,7 +3344,7 @@ class SerialProxyGetModemPinsRequest final : public ProtoDecodableMessage { }; class SerialProxyGetModemPinsResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 143; + static constexpr uint16_t MESSAGE_TYPE = 143; static constexpr uint8_t ESTIMATED_SIZE = 10; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("serial_proxy_get_modem_pins_response"); } @@ -3358,7 +3362,7 @@ class SerialProxyGetModemPinsResponse final : public ProtoMessage { }; class SerialProxyRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 144; + static constexpr uint16_t MESSAGE_TYPE = 144; static constexpr uint8_t ESTIMATED_SIZE = 6; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("serial_proxy_request"); } @@ -3374,7 +3378,7 @@ class SerialProxyRequest final : public ProtoDecodableMessage { }; class SerialProxyRequestResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 147; + static constexpr uint16_t MESSAGE_TYPE = 147; static constexpr uint8_t ESTIMATED_SIZE = 17; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("serial_proxy_request_response"); } @@ -3395,7 +3399,7 @@ class SerialProxyRequestResponse final : public ProtoMessage { #ifdef USE_BLUETOOTH_PROXY_CONNECTIONS class BluetoothSetConnectionParamsRequest final : public ProtoDecodableMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 145; + static constexpr uint16_t MESSAGE_TYPE = 145; static constexpr uint8_t ESTIMATED_SIZE = 20; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_set_connection_params_request"); } @@ -3414,7 +3418,7 @@ class BluetoothSetConnectionParamsRequest final : public ProtoDecodableMessage { }; class BluetoothSetConnectionParamsResponse final : public ProtoMessage { public: - static constexpr uint8_t MESSAGE_TYPE = 146; + static constexpr uint16_t MESSAGE_TYPE = 146; static constexpr uint8_t ESTIMATED_SIZE = 8; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("bluetooth_set_connection_params_response"); } diff --git a/esphome/components/api/proto.h b/esphome/components/api/proto.h index f058f6af22..a226e080e8 100644 --- a/esphome/components/api/proto.h +++ b/esphome/components/api/proto.h @@ -684,11 +684,6 @@ class ProtoSize { return value < VARINT_THRESHOLD_1_BYTE ? 1 : (value < VARINT_THRESHOLD_2_BYTE ? 2 : 3); } - // Varint encoded length for an 8-bit value (1 or 2 bytes). - static constexpr inline uint8_t ESPHOME_ALWAYS_INLINE varint8(uint8_t value) { - return value < VARINT_THRESHOLD_1_BYTE ? 1 : 2; - } - /** * @brief Calculates the size in bytes needed to encode a uint32_t value as a varint * diff --git a/script/api_protobuf/api_protobuf.py b/script/api_protobuf/api_protobuf.py index dc3dd4b868..ca1c5736c8 100755 --- a/script/api_protobuf/api_protobuf.py +++ b/script/api_protobuf/api_protobuf.py @@ -475,6 +475,19 @@ TYPE_INFO: dict[int, TypeInfo] = {} # TYPE_DOUBLE = 1, TYPE_FIXED64 = 6, TYPE_SFIXED64 = 16, TYPE_SINT64 = 18 UNSUPPORTED_TYPES = {1: "double", 6: "fixed64", 16: "sfixed64", 18: "sint64"} +# The plaintext frame header budgets 2 varint bytes for the message type +# (APIPlaintextFrameHelper::HEADER_PADDING), which caps message IDs at 16383. +MAX_MESSAGE_ID = 16383 + + +def validate_message_id(message_id: int, message_name: str) -> None: + """Reject message IDs whose plaintext type varint would not fit in 2 bytes.""" + if message_id > MAX_MESSAGE_ID: + raise ValueError( + f"Message ID {message_id} for {message_name} exceeds the plaintext " + f"2-byte type varint maximum ({MAX_MESSAGE_ID})" + ) + def validate_field_type(field_type: int, field_name: str = "") -> None: """Validate that the field type is supported by ESPHome API. @@ -2549,14 +2562,10 @@ def build_message_type( # Add MESSAGE_TYPE method if this is a service message if message_id is not None: - # Validate that message_id fits in uint8_t - if message_id > 255: - raise ValueError( - f"Message ID {message_id} for {desc.name} exceeds uint8_t maximum (255)" - ) + validate_message_id(message_id, desc.name) # Add static constexpr for message type - public_content.append(f"static constexpr uint8_t MESSAGE_TYPE = {message_id};") + public_content.append(f"static constexpr uint16_t MESSAGE_TYPE = {message_id};") # Add estimated size constant estimated_size = calculate_message_estimated_size(desc) @@ -3212,8 +3221,12 @@ def main() -> None: #include "api_pb2_includes.h" """ - content += """ -namespace esphome::api { + content += f""" +namespace esphome::api {{ + +// Upper bound on message IDs, enforced by the code generator: the plaintext +// frame header budgets 2 varint bytes for the type (HEADER_PADDING). +static constexpr uint16_t MAX_MESSAGE_TYPE = {MAX_MESSAGE_ID}; """ diff --git a/tests/unit_tests/components/api/test_api_protobuf_generator.py b/tests/unit_tests/components/api/test_api_protobuf_generator.py index 2a07cbd49c..797125ba8f 100644 --- a/tests/unit_tests/components/api/test_api_protobuf_generator.py +++ b/tests/unit_tests/components/api/test_api_protobuf_generator.py @@ -15,7 +15,12 @@ import pytest sys.path.insert(0, str(Path(__file__).parents[4] / "script" / "api_protobuf")) -from api_protobuf import _make_ifdef_line, get_varint64_ifdef # noqa: E402 +from api_protobuf import ( # noqa: E402 + MAX_MESSAGE_ID, + _make_ifdef_line, + get_varint64_ifdef, + validate_message_id, +) from google.protobuf import descriptor_pb2 # noqa: E402 @@ -91,3 +96,14 @@ def test_make_ifdef_line_conjunction_and_negation() -> None: assert ( _make_ifdef_line("USE_X && !USE_Y") == "#if defined(USE_X) && !defined(USE_Y)" ) + + +def test_message_id_at_maximum_is_accepted() -> None: + # 16383 is the largest ID whose plaintext type varint fits the 2 bytes + # budgeted in HEADER_PADDING. + validate_message_id(MAX_MESSAGE_ID, "MaxMessage") + + +def test_message_id_above_maximum_is_rejected() -> None: + with pytest.raises(ValueError, match="exceeds the plaintext"): + validate_message_id(MAX_MESSAGE_ID + 1, "TooBigMessage") From 9caeb948f3c8569be38d75340b2a26a7ea22ef42 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 25 Aug 2026 13:20:30 -0500 Subject: [PATCH 3/3] Warn when forced-on ccache has no usable binary, skip freshly installed dests in the prefetch, derive the clean-all sandbox from the cache registry --- esphome/espidf/framework.py | 11 ++++++++--- esphome/platformio/registry.py | 5 +++++ tests/unit_tests/test_espidf_framework.py | 9 ++++++--- tests/unit_tests/test_platformio_registry.py | 16 ++++++++++++++++ tests/unit_tests/test_writer.py | 16 +++++++++------- 5 files changed, 44 insertions(+), 13 deletions(-) diff --git a/esphome/espidf/framework.py b/esphome/espidf/framework.py index 25fbc1aa52..4b7653616a 100644 --- a/esphome/espidf/framework.py +++ b/esphome/espidf/framework.py @@ -1209,9 +1209,14 @@ def _ccache_env() -> dict[str, str]: # export the canonical off spelling instead return {"IDF_CCACHE_ENABLE": "0"} if idf_knob is True: - # Forced on skips the runnability verdict, but still resolve for - # the "no ccache binary on PATH" warning - resolve_ccache_path() + # Forced on ignores the runnability verdict, but a missing or + # unusable binary is worth saying out loud: idf.py silently + # compiles without ccache in that case + if resolve_ccache_path() is None: + _LOGGER.warning( + "IDF_CCACHE_ENABLE=1 but no usable ccache binary was " + "found; idf.py will compile without ccache" + ) elif resolve_ccache_path() is None: # ESP-IDF silently skips ccache without the binary; export the # canonical off spelling so an unparsable inherited value (or a diff --git a/esphome/platformio/registry.py b/esphome/platformio/registry.py index ca012ccbbe..a04caa8487 100644 --- a/esphome/platformio/registry.py +++ b/esphome/platformio/registry.py @@ -218,6 +218,11 @@ def prefetch_packages( def _fetch(entry: _PendingArchive, tracker: Callable[[int], None]) -> None: entry.dest.parent.mkdir(parents=True, exist_ok=True) with FileLock(f"{entry.dest}.lock", fallback_to_soft=False): + if (entry.dest / ".esphome_extracted").is_file(): + # A concurrent build installed (and deleted the archive of) + # this package while we waited; re-downloading would orphan + # a fresh copy in downloads_dir + return download_with_resume( entry.url, downloads_dir / f"{entry.name}-{entry.version}", diff --git a/tests/unit_tests/test_espidf_framework.py b/tests/unit_tests/test_espidf_framework.py index 42a00ef0d7..ecf54349be 100644 --- a/tests/unit_tests/test_espidf_framework.py +++ b/tests/unit_tests/test_espidf_framework.py @@ -1602,15 +1602,18 @@ def test_ccache_env_opt_out_via_env(tmp_path: Path) -> None: assert _ccache_env() == {"IDF_CCACHE_ENABLE": "0"} -def test_ccache_env_opt_in_without_binary(tmp_path: Path) -> None: - # Explicit IDF_CCACHE_ENABLE=1 forces it on; the probe verdict is - # ignored but the resolver still runs for its no-binary warning. +def test_ccache_env_opt_in_without_binary( + tmp_path: Path, caplog: pytest.LogCaptureFixture +) -> None: + # Explicit IDF_CCACHE_ENABLE=1 forces it on; without a usable binary + # idf.py silently skips ccache, so this branch must say so out loud. p1, p2, p3 = _ccache_patches(tmp_path, None, tmp_path / "build") with patch.dict("os.environ", {"IDF_CCACHE_ENABLE": "1"}, clear=True), p1, p2, p3: env = _ccache_env() assert env["IDF_CCACHE_ENABLE"] == "1" assert env["CCACHE_DIR"] == str(tmp_path / "tools" / "ccache") assert env["CCACHE_DEPEND"] == "1" + assert "no usable ccache binary" in caplog.text def test_ccache_env_honors_shared_esphome_opt_out(tmp_path: Path) -> None: diff --git a/tests/unit_tests/test_platformio_registry.py b/tests/unit_tests/test_platformio_registry.py index 70e49d1f5b..56bfe4fe74 100644 --- a/tests/unit_tests/test_platformio_registry.py +++ b/tests/unit_tests/test_platformio_registry.py @@ -534,6 +534,22 @@ def test_prefetch_packages_downloads_pending_in_parallel(tmp_path: Path) -> None assert callable(call[1]["progress"]) +def test_prefetch_packages_skips_freshly_installed_dest(tmp_path: Path) -> None: + """A dest whose marker appeared while the worker waited on the lock is + already installed; re-downloading would orphan an archive copy.""" + dest = tmp_path / "a" + dest.mkdir() + (dest / ".esphome_extracted").touch() + with ( + patch.object(registry, "download_with_resume") as mock_download, + patch.object( + registry, "registry_download", side_effect=_resolve_for({"a": 10}) + ), + ): + registry.prefetch_packages([("a", "1.0", dest, [])], tmp_path / "dl") + mock_download.assert_not_called() + + def test_prefetch_packages_dedupes_duplicate_entries(tmp_path: Path) -> None: """Duplicate (name, version) entries would race each other between two workers; only one survives (and one is too few to parallelize).""" diff --git a/tests/unit_tests/test_writer.py b/tests/unit_tests/test_writer.py index 0a53dba9c2..9c20ee10d2 100644 --- a/tests/unit_tests/test_writer.py +++ b/tests/unit_tests/test_writer.py @@ -14,6 +14,7 @@ from unittest.mock import MagicMock, patch import pytest +from esphome.build_helpers.tools_cache import TOOLS_CACHE_SPECS from esphome.const import ( PLATFORM_BK72XX, PLATFORM_ESP32, @@ -68,15 +69,12 @@ def _isolate_platformio_paths(tmp_path_factory: pytest.TempPathFactory) -> Any: test_clean_all_partial_exists) install their own inner patch which stacks on top of this one and wins for the duration of their block. - Also pin ``ESPHOME_ESP_IDF_PREFIX`` and ``ESPHOME_SDK_NRF_PREFIX`` to - nonexistent tmp dirs, and patch ``platformdirs.user_cache_dir``, for the - same reason: ``clean_all`` removes the machine-global toolchain installs + Also pin every ``TOOLS_CACHE_SPECS`` env override to a nonexistent tmp + dir, and patch ``platformdirs.user_cache_dir``, for the same reason: ``clean_all`` removes the machine-global toolchain installs and their default cache root, which otherwise resolve to the real ``~/.cache/esphome``. """ pio_root = tmp_path_factory.mktemp("isolated_pio") / "nonexistent" - idf_root = tmp_path_factory.mktemp("isolated_idf") / "nonexistent" - sdk_nrf_root = tmp_path_factory.mktemp("isolated_sdk_nrf") / "nonexistent" cache_root = tmp_path_factory.mktemp("isolated_cache") / "nonexistent" mock_cfg = MagicMock() mock_cfg.get.side_effect = lambda section, option: ( @@ -90,8 +88,12 @@ def _isolate_platformio_paths(tmp_path_factory: pytest.TempPathFactory) -> Any: patch.dict( "os.environ", { - "ESPHOME_ESP_IDF_PREFIX": str(idf_root), - "ESPHOME_SDK_NRF_PREFIX": str(sdk_nrf_root), + # Derived from the registry so a new backend's cache can + # never drift out of the sandbox and hit a real toolchain + env_var: str( + tmp_path_factory.mktemp(f"isolated_{subdir}") / "nonexistent" + ) + for env_var, subdir in TOOLS_CACHE_SPECS }, ), patch("platformdirs.user_cache_dir", return_value=str(cache_root)),