From d2deba6b697a9a63ce3b8268393127b202eadd73 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Wed, 16 Jul 2025 01:56:19 +0000 Subject: [PATCH 1/9] [pre-commit.ci lite] apply automatic fixes --- tests/integration/test_host_mode_api_password.py | 2 +- tests/integration/test_runtime_stats.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integration/test_host_mode_api_password.py b/tests/integration/test_host_mode_api_password.py index 098fc38142..825c2c55f2 100644 --- a/tests/integration/test_host_mode_api_password.py +++ b/tests/integration/test_host_mode_api_password.py @@ -41,7 +41,7 @@ async def test_host_mode_api_password( # Wait for at least one state with timeout try: await asyncio.wait_for(state_future, timeout=5.0) - except asyncio.TimeoutError: + except TimeoutError: pytest.fail("No states received within timeout") # Should have received at least one state (the test sensor) diff --git a/tests/integration/test_runtime_stats.py b/tests/integration/test_runtime_stats.py index cd8546facc..9e93035d83 100644 --- a/tests/integration/test_runtime_stats.py +++ b/tests/integration/test_runtime_stats.py @@ -65,13 +65,13 @@ async def test_runtime_stats( # Wait for first "Total stats" log (should happen at 1s) try: await asyncio.wait_for(first_stats_future, timeout=5.0) - except asyncio.TimeoutError: + except TimeoutError: pytest.fail("First 'Total stats' log not seen within 5 seconds") # Wait for second "Total stats" log (should happen at 2s) try: await asyncio.wait_for(second_stats_future, timeout=5.0) - except asyncio.TimeoutError: + except TimeoutError: pytest.fail(f"Second 'Total stats' log not seen. Total seen: {stats_count}") # Verify we got at least 2 stats logs From 1ce5a994d870dff9cd96996e85f04e140348ebd3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 15 Jul 2025 19:56:40 -1000 Subject: [PATCH 2/9] fix a few more that are missing --- esphome/components/api/api.proto | 24 +++++++-------- esphome/components/api/api_pb2.cpp | 40 +++++++++++++++++++++++++ esphome/components/api/api_pb2_dump.cpp | 36 ++++++++++++++++++++++ 3 files changed, 88 insertions(+), 12 deletions(-) diff --git a/esphome/components/api/api.proto b/esphome/components/api/api.proto index 10c0796faa..e3175436ce 100644 --- a/esphome/components/api/api.proto +++ b/esphome/components/api/api.proto @@ -311,7 +311,7 @@ message BinarySensorStateResponse { // If the binary sensor does not have a valid state yet. // Equivalent to `!obj->has_state()` - inverse logic to make state packets smaller bool missing_state = 3; - uint32 device_id = 4; + uint32 device_id = 4 [(field_ifdef) = "USE_DEVICES"]; } // ==================== COVER ==================== @@ -361,7 +361,7 @@ message CoverStateResponse { float position = 3; float tilt = 4; CoverOperation current_operation = 5; - uint32 device_id = 6; + uint32 device_id = 6 [(field_ifdef) = "USE_DEVICES"]; } enum LegacyCoverCommand { @@ -458,7 +458,7 @@ message FanCommandRequest { int32 speed_level = 11; bool has_preset_mode = 12; string preset_mode = 13; - uint32 device_id = 14; + uint32 device_id = 14 [(field_ifdef) = "USE_DEVICES"]; } // ==================== LIGHT ==================== @@ -520,7 +520,7 @@ message LightStateResponse { float cold_white = 12; float warm_white = 13; string effect = 9; - uint32 device_id = 14; + uint32 device_id = 14 [(field_ifdef) = "USE_DEVICES"]; } message LightCommandRequest { option (id) = 32; @@ -556,7 +556,7 @@ message LightCommandRequest { uint32 flash_length = 17; bool has_effect = 18; string effect = 19; - uint32 device_id = 28; + uint32 device_id = 28 [(field_ifdef) = "USE_DEVICES"]; } // ==================== SENSOR ==================== @@ -594,7 +594,7 @@ message ListEntitiesSensorResponse { SensorLastResetType legacy_last_reset_type = 11; bool disabled_by_default = 12; EntityCategory entity_category = 13; - uint32 device_id = 14; + uint32 device_id = 14 [(field_ifdef) = "USE_DEVICES"]; } message SensorStateResponse { option (id) = 25; @@ -608,7 +608,7 @@ message SensorStateResponse { // If the sensor does not have a valid state yet. // Equivalent to `!obj->has_state()` - inverse logic to make state packets smaller bool missing_state = 3; - uint32 device_id = 4; + uint32 device_id = 4 [(field_ifdef) = "USE_DEVICES"]; } // ==================== SWITCH ==================== @@ -639,7 +639,7 @@ message SwitchStateResponse { fixed32 key = 1; bool state = 2; - uint32 device_id = 3; + uint32 device_id = 3 [(field_ifdef) = "USE_DEVICES"]; } message SwitchCommandRequest { option (id) = 33; @@ -650,7 +650,7 @@ message SwitchCommandRequest { fixed32 key = 1; bool state = 2; - uint32 device_id = 3; + uint32 device_id = 3 [(field_ifdef) = "USE_DEVICES"]; } // ==================== TEXT SENSOR ==================== @@ -683,7 +683,7 @@ message TextSensorStateResponse { // If the text sensor does not have a valid state yet. // Equivalent to `!obj->has_state()` - inverse logic to make state packets smaller bool missing_state = 3; - uint32 device_id = 4; + uint32 device_id = 4 [(field_ifdef) = "USE_DEVICES"]; } // ==================== SUBSCRIBE LOGS ==================== @@ -869,7 +869,7 @@ message CameraImageResponse { fixed32 key = 1; bytes data = 2; bool done = 3; - uint32 device_id = 4; + uint32 device_id = 4 [(field_ifdef) = "USE_DEVICES"]; } message CameraImageRequest { option (id) = 45; @@ -1020,7 +1020,7 @@ message ClimateCommandRequest { string custom_preset = 21; bool has_target_humidity = 22; float target_humidity = 23; - uint32 device_id = 24; + uint32 device_id = 24 [(field_ifdef) = "USE_DEVICES"]; } // ==================== NUMBER ==================== diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index 68fbbcc52f..7c44454511 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -260,13 +260,17 @@ void BinarySensorStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_bool(2, this->state); buffer.encode_bool(3, this->missing_state); +#ifdef USE_DEVICES buffer.encode_uint32(4, this->device_id); +#endif } void BinarySensorStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_bool_field(total_size, 1, this->state); ProtoSize::add_bool_field(total_size, 1, this->missing_state); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } #endif #ifdef USE_COVER @@ -312,7 +316,9 @@ void CoverStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_float(3, this->position); buffer.encode_float(4, this->tilt); buffer.encode_uint32(5, static_cast(this->current_operation)); +#ifdef USE_DEVICES buffer.encode_uint32(6, this->device_id); +#endif } void CoverStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); @@ -320,7 +326,9 @@ void CoverStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_float_field(total_size, 1, this->position); ProtoSize::add_float_field(total_size, 1, this->tilt); ProtoSize::add_enum_field(total_size, 1, static_cast(this->current_operation)); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } bool CoverCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { @@ -468,9 +476,11 @@ bool FanCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { case 12: this->has_preset_mode = value.as_bool(); break; +#ifdef USE_DEVICES case 14: this->device_id = value.as_uint32(); break; +#endif default: return false; } @@ -566,7 +576,9 @@ void LightStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_float(12, this->cold_white); buffer.encode_float(13, this->warm_white); buffer.encode_string(9, this->effect); +#ifdef USE_DEVICES buffer.encode_uint32(14, this->device_id); +#endif } void LightStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); @@ -582,7 +594,9 @@ void LightStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_float_field(total_size, 1, this->cold_white); ProtoSize::add_float_field(total_size, 1, this->warm_white); ProtoSize::add_string_field(total_size, 1, this->effect); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } bool LightCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { @@ -634,9 +648,11 @@ bool LightCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { case 18: this->has_effect = value.as_bool(); break; +#ifdef USE_DEVICES case 28: this->device_id = value.as_uint32(); break; +#endif default: return false; } @@ -706,7 +722,9 @@ void ListEntitiesSensorResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(11, static_cast(this->legacy_last_reset_type)); buffer.encode_bool(12, this->disabled_by_default); buffer.encode_uint32(13, static_cast(this->entity_category)); +#ifdef USE_DEVICES buffer.encode_uint32(14, this->device_id); +#endif } void ListEntitiesSensorResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); @@ -723,19 +741,25 @@ void ListEntitiesSensorResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_enum_field(total_size, 1, static_cast(this->legacy_last_reset_type)); ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default); ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category)); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } void SensorStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_float(2, this->state); buffer.encode_bool(3, this->missing_state); +#ifdef USE_DEVICES buffer.encode_uint32(4, this->device_id); +#endif } void SensorStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_float_field(total_size, 1, this->state); ProtoSize::add_bool_field(total_size, 1, this->missing_state); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } #endif #ifdef USE_SWITCH @@ -772,21 +796,27 @@ void ListEntitiesSwitchResponse::calculate_size(uint32_t &total_size) const { void SwitchStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_bool(2, this->state); +#ifdef USE_DEVICES buffer.encode_uint32(3, this->device_id); +#endif } void SwitchStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_bool_field(total_size, 1, this->state); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } bool SwitchCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { case 2: this->state = value.as_bool(); break; +#ifdef USE_DEVICES case 3: this->device_id = value.as_uint32(); break; +#endif default: return false; } @@ -836,13 +866,17 @@ void TextSensorStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_string(2, this->state); buffer.encode_bool(3, this->missing_state); +#ifdef USE_DEVICES buffer.encode_uint32(4, this->device_id); +#endif } void TextSensorStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->state); ProtoSize::add_bool_field(total_size, 1, this->missing_state); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } #endif bool SubscribeLogsRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { @@ -1151,13 +1185,17 @@ void CameraImageResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_bytes(2, reinterpret_cast(this->data.data()), this->data.size()); buffer.encode_bool(3, this->done); +#ifdef USE_DEVICES buffer.encode_uint32(4, this->device_id); +#endif } void CameraImageResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->data); ProtoSize::add_bool_field(total_size, 1, this->done); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } bool CameraImageRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { @@ -1362,9 +1400,11 @@ bool ClimateCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) case 22: this->has_target_humidity = value.as_bool(); break; +#ifdef USE_DEVICES case 24: this->device_id = value.as_uint32(); break; +#endif default: return false; } diff --git a/esphome/components/api/api_pb2_dump.cpp b/esphome/components/api/api_pb2_dump.cpp index c8fca01e9a..342fafc1c0 100644 --- a/esphome/components/api/api_pb2_dump.cpp +++ b/esphome/components/api/api_pb2_dump.cpp @@ -883,10 +883,13 @@ void BinarySensorStateResponse::dump_to(std::string &out) const { out.append(YESNO(this->missing_state)); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } #endif @@ -976,10 +979,13 @@ void CoverStateResponse::dump_to(std::string &out) const { out.append(proto_enum_to_string(this->current_operation)); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } void CoverCommandRequest::dump_to(std::string &out) const { @@ -1192,10 +1198,13 @@ void FanCommandRequest::dump_to(std::string &out) const { out.append("'").append(this->preset_mode).append("'"); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } #endif @@ -1342,10 +1351,13 @@ void LightStateResponse::dump_to(std::string &out) const { out.append("'").append(this->effect).append("'"); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } void LightCommandRequest::dump_to(std::string &out) const { @@ -1471,10 +1483,13 @@ void LightCommandRequest::dump_to(std::string &out) const { out.append("'").append(this->effect).append("'"); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } #endif @@ -1534,10 +1549,13 @@ void ListEntitiesSensorResponse::dump_to(std::string &out) const { out.append(proto_enum_to_string(this->entity_category)); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } void SensorStateResponse::dump_to(std::string &out) const { @@ -1557,10 +1575,13 @@ void SensorStateResponse::dump_to(std::string &out) const { out.append(YESNO(this->missing_state)); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } #endif @@ -1624,10 +1645,13 @@ void SwitchStateResponse::dump_to(std::string &out) const { out.append(YESNO(this->state)); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } void SwitchCommandRequest::dump_to(std::string &out) const { @@ -1642,10 +1666,13 @@ void SwitchCommandRequest::dump_to(std::string &out) const { out.append(YESNO(this->state)); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } #endif @@ -1709,10 +1736,13 @@ void TextSensorStateResponse::dump_to(std::string &out) const { out.append(YESNO(this->missing_state)); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } #endif @@ -2009,10 +2039,13 @@ void CameraImageResponse::dump_to(std::string &out) const { out.append(YESNO(this->done)); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } void CameraImageRequest::dump_to(std::string &out) const { @@ -2337,10 +2370,13 @@ void ClimateCommandRequest::dump_to(std::string &out) const { out.append(buffer); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } #endif From 628caf63fc374f43f907884e8fceba8aa5749f5f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 15 Jul 2025 19:57:10 -1000 Subject: [PATCH 3/9] fix a few more that are missing --- esphome/components/api/api.proto | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/esphome/components/api/api.proto b/esphome/components/api/api.proto index e3175436ce..0ba2dbaed4 100644 --- a/esphome/components/api/api.proto +++ b/esphome/components/api/api.proto @@ -1049,7 +1049,7 @@ message ListEntitiesNumberResponse { string unit_of_measurement = 11; NumberMode mode = 12; string device_class = 13; - uint32 device_id = 14; + uint32 device_id = 14 [(field_ifdef) = "USE_DEVICES"]; } message NumberStateResponse { option (id) = 50; @@ -1063,7 +1063,7 @@ message NumberStateResponse { // If the number does not have a valid state yet. // Equivalent to `!obj->has_state()` - inverse logic to make state packets smaller bool missing_state = 3; - uint32 device_id = 4; + uint32 device_id = 4 [(field_ifdef) = "USE_DEVICES"]; } message NumberCommandRequest { option (id) = 51; @@ -1074,7 +1074,7 @@ message NumberCommandRequest { fixed32 key = 1; float state = 2; - uint32 device_id = 3; + uint32 device_id = 3 [(field_ifdef) = "USE_DEVICES"]; } // ==================== SELECT ==================== @@ -1107,7 +1107,7 @@ message SelectStateResponse { // If the select does not have a valid state yet. // Equivalent to `!obj->has_state()` - inverse logic to make state packets smaller bool missing_state = 3; - uint32 device_id = 4; + uint32 device_id = 4 [(field_ifdef) = "USE_DEVICES"]; } message SelectCommandRequest { option (id) = 54; @@ -1118,7 +1118,7 @@ message SelectCommandRequest { fixed32 key = 1; string state = 2; - uint32 device_id = 3; + uint32 device_id = 3 [(field_ifdef) = "USE_DEVICES"]; } // ==================== SIREN ==================== @@ -1150,7 +1150,7 @@ message SirenStateResponse { fixed32 key = 1; bool state = 2; - uint32 device_id = 3; + uint32 device_id = 3 [(field_ifdef) = "USE_DEVICES"]; } message SirenCommandRequest { option (id) = 57; From 86ceccbb1c536727893898cc336367948ef0c473 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 15 Jul 2025 19:57:15 -1000 Subject: [PATCH 4/9] fix a few more that are missing --- esphome/components/api/api.proto | 6 +++--- esphome/components/api/api_pb2.cpp | 28 +++++++++++++++++++++++++ esphome/components/api/api_pb2_dump.cpp | 27 ++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/esphome/components/api/api.proto b/esphome/components/api/api.proto index 0ba2dbaed4..856ae4b047 100644 --- a/esphome/components/api/api.proto +++ b/esphome/components/api/api.proto @@ -1216,7 +1216,7 @@ message LockStateResponse { option (no_delay) = true; fixed32 key = 1; LockState state = 2; - uint32 device_id = 3; + uint32 device_id = 3 [(field_ifdef) = "USE_DEVICES"]; } message LockCommandRequest { option (id) = 60; @@ -1230,7 +1230,7 @@ message LockCommandRequest { // Not yet implemented: bool has_code = 3; string code = 4; - uint32 device_id = 5; + uint32 device_id = 5 [(field_ifdef) = "USE_DEVICES"]; } // ==================== BUTTON ==================== @@ -1259,7 +1259,7 @@ message ButtonCommandRequest { option (base_class) = "CommandProtoMessage"; fixed32 key = 1; - uint32 device_id = 2; + uint32 device_id = 2 [(field_ifdef) = "USE_DEVICES"]; } // ==================== MEDIA PLAYER ==================== diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index 7c44454511..21cffebac2 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -1462,7 +1462,9 @@ void ListEntitiesNumberResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(11, this->unit_of_measurement); buffer.encode_uint32(12, static_cast(this->mode)); buffer.encode_string(13, this->device_class); +#ifdef USE_DEVICES buffer.encode_uint32(14, this->device_id); +#endif } void ListEntitiesNumberResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); @@ -1479,25 +1481,33 @@ void ListEntitiesNumberResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->unit_of_measurement); ProtoSize::add_enum_field(total_size, 1, static_cast(this->mode)); ProtoSize::add_string_field(total_size, 1, this->device_class); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } void NumberStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_float(2, this->state); buffer.encode_bool(3, this->missing_state); +#ifdef USE_DEVICES buffer.encode_uint32(4, this->device_id); +#endif } void NumberStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_float_field(total_size, 1, this->state); ProtoSize::add_bool_field(total_size, 1, this->missing_state); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } bool NumberCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { +#ifdef USE_DEVICES case 3: this->device_id = value.as_uint32(); break; +#endif default: return false; } @@ -1556,19 +1566,25 @@ void SelectStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_string(2, this->state); buffer.encode_bool(3, this->missing_state); +#ifdef USE_DEVICES buffer.encode_uint32(4, this->device_id); +#endif } void SelectStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->state); ProtoSize::add_bool_field(total_size, 1, this->missing_state); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } bool SelectCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { +#ifdef USE_DEVICES case 3: this->device_id = value.as_uint32(); break; +#endif default: return false; } @@ -1637,12 +1653,16 @@ void ListEntitiesSirenResponse::calculate_size(uint32_t &total_size) const { void SirenStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_bool(2, this->state); +#ifdef USE_DEVICES buffer.encode_uint32(3, this->device_id); +#endif } void SirenStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_bool_field(total_size, 1, this->state); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } bool SirenCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { @@ -1736,12 +1756,16 @@ void ListEntitiesLockResponse::calculate_size(uint32_t &total_size) const { void LockStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_uint32(2, static_cast(this->state)); +#ifdef USE_DEVICES buffer.encode_uint32(3, this->device_id); +#endif } void LockStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_enum_field(total_size, 1, static_cast(this->state)); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } bool LockCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { @@ -1751,9 +1775,11 @@ bool LockCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { case 3: this->has_code = value.as_bool(); break; +#ifdef USE_DEVICES case 5: this->device_id = value.as_uint32(); break; +#endif default: return false; } @@ -1811,9 +1837,11 @@ void ListEntitiesButtonResponse::calculate_size(uint32_t &total_size) const { } bool ButtonCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { +#ifdef USE_DEVICES case 2: this->device_id = value.as_uint32(); break; +#endif default: return false; } diff --git a/esphome/components/api/api_pb2_dump.cpp b/esphome/components/api/api_pb2_dump.cpp index 342fafc1c0..29cd2fa336 100644 --- a/esphome/components/api/api_pb2_dump.cpp +++ b/esphome/components/api/api_pb2_dump.cpp @@ -2438,10 +2438,13 @@ void ListEntitiesNumberResponse::dump_to(std::string &out) const { out.append("'").append(this->device_class).append("'"); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } void NumberStateResponse::dump_to(std::string &out) const { @@ -2461,10 +2464,13 @@ void NumberStateResponse::dump_to(std::string &out) const { out.append(YESNO(this->missing_state)); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } void NumberCommandRequest::dump_to(std::string &out) const { @@ -2480,10 +2486,13 @@ void NumberCommandRequest::dump_to(std::string &out) const { out.append(buffer); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } #endif @@ -2549,10 +2558,13 @@ void SelectStateResponse::dump_to(std::string &out) const { out.append(YESNO(this->missing_state)); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } void SelectCommandRequest::dump_to(std::string &out) const { @@ -2567,10 +2579,13 @@ void SelectCommandRequest::dump_to(std::string &out) const { out.append("'").append(this->state).append("'"); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } #endif @@ -2640,10 +2655,13 @@ void SirenStateResponse::dump_to(std::string &out) const { out.append(YESNO(this->state)); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } void SirenCommandRequest::dump_to(std::string &out) const { @@ -2766,10 +2784,13 @@ void LockStateResponse::dump_to(std::string &out) const { out.append(proto_enum_to_string(this->state)); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } void LockCommandRequest::dump_to(std::string &out) const { @@ -2792,10 +2813,13 @@ void LockCommandRequest::dump_to(std::string &out) const { out.append("'").append(this->code).append("'"); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } #endif @@ -2851,10 +2875,13 @@ void ButtonCommandRequest::dump_to(std::string &out) const { out.append(buffer); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } #endif From c80481baabda40f3f467a4133c0260ae04bbf15c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 15 Jul 2025 19:57:34 -1000 Subject: [PATCH 5/9] fix a few more that are missing --- esphome/components/api/api.proto | 6 +++--- esphome/components/api/api_pb2.cpp | 10 ++++++++++ esphome/components/api/api_pb2_dump.cpp | 9 +++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/esphome/components/api/api.proto b/esphome/components/api/api.proto index 856ae4b047..3d11037f2d 100644 --- a/esphome/components/api/api.proto +++ b/esphome/components/api/api.proto @@ -1320,7 +1320,7 @@ message MediaPlayerStateResponse { MediaPlayerState state = 2; float volume = 3; bool muted = 4; - uint32 device_id = 5; + uint32 device_id = 5 [(field_ifdef) = "USE_DEVICES"]; } message MediaPlayerCommandRequest { option (id) = 65; @@ -1863,7 +1863,7 @@ message AlarmControlPanelStateResponse { option (no_delay) = true; fixed32 key = 1; AlarmControlPanelState state = 2; - uint32 device_id = 3; + uint32 device_id = 3 [(field_ifdef) = "USE_DEVICES"]; } message AlarmControlPanelCommandRequest { @@ -1875,7 +1875,7 @@ message AlarmControlPanelCommandRequest { fixed32 key = 1; AlarmControlPanelStateCommand command = 2; string code = 3; - uint32 device_id = 4; + uint32 device_id = 4 [(field_ifdef) = "USE_DEVICES"]; } // ===================== TEXT ===================== diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index 21cffebac2..56fb8b442f 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -1939,14 +1939,18 @@ void MediaPlayerStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(2, static_cast(this->state)); buffer.encode_float(3, this->volume); buffer.encode_bool(4, this->muted); +#ifdef USE_DEVICES buffer.encode_uint32(5, this->device_id); +#endif } void MediaPlayerStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_enum_field(total_size, 1, static_cast(this->state)); ProtoSize::add_float_field(total_size, 1, this->volume); ProtoSize::add_bool_field(total_size, 1, this->muted); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } bool MediaPlayerCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { @@ -2804,21 +2808,27 @@ void ListEntitiesAlarmControlPanelResponse::calculate_size(uint32_t &total_size) void AlarmControlPanelStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_uint32(2, static_cast(this->state)); +#ifdef USE_DEVICES buffer.encode_uint32(3, this->device_id); +#endif } void AlarmControlPanelStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_enum_field(total_size, 1, static_cast(this->state)); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } bool AlarmControlPanelCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { case 2: this->command = static_cast(value.as_uint32()); break; +#ifdef USE_DEVICES case 4: this->device_id = value.as_uint32(); break; +#endif default: return false; } diff --git a/esphome/components/api/api_pb2_dump.cpp b/esphome/components/api/api_pb2_dump.cpp index 29cd2fa336..1d85bc31d5 100644 --- a/esphome/components/api/api_pb2_dump.cpp +++ b/esphome/components/api/api_pb2_dump.cpp @@ -2983,10 +2983,13 @@ void MediaPlayerStateResponse::dump_to(std::string &out) const { out.append(YESNO(this->muted)); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } void MediaPlayerCommandRequest::dump_to(std::string &out) const { @@ -3842,10 +3845,13 @@ void AlarmControlPanelStateResponse::dump_to(std::string &out) const { out.append(proto_enum_to_string(this->state)); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } void AlarmControlPanelCommandRequest::dump_to(std::string &out) const { @@ -3864,10 +3870,13 @@ void AlarmControlPanelCommandRequest::dump_to(std::string &out) const { out.append("'").append(this->code).append("'"); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } #endif From f6c12229e515ce81918c12bbc1c4ed497fee1782 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 15 Jul 2025 19:57:43 -1000 Subject: [PATCH 6/9] fix a few more that are missing --- esphome/components/api/api.proto | 4 ++-- esphome/components/api/api_pb2.cpp | 6 ++++++ esphome/components/api/api_pb2_dump.cpp | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/esphome/components/api/api.proto b/esphome/components/api/api.proto index 3d11037f2d..87da838e87 100644 --- a/esphome/components/api/api.proto +++ b/esphome/components/api/api.proto @@ -1915,7 +1915,7 @@ message TextStateResponse { // If the Text does not have a valid state yet. // Equivalent to `!obj->has_state()` - inverse logic to make state packets smaller bool missing_state = 3; - uint32 device_id = 4; + uint32 device_id = 4 [(field_ifdef) = "USE_DEVICES"]; } message TextCommandRequest { option (id) = 99; @@ -1926,7 +1926,7 @@ message TextCommandRequest { fixed32 key = 1; string state = 2; - uint32 device_id = 3; + uint32 device_id = 3 [(field_ifdef) = "USE_DEVICES"]; } diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index 56fb8b442f..f67cda5bdd 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -2894,19 +2894,25 @@ void TextStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_string(2, this->state); buffer.encode_bool(3, this->missing_state); +#ifdef USE_DEVICES buffer.encode_uint32(4, this->device_id); +#endif } void TextStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->state); ProtoSize::add_bool_field(total_size, 1, this->missing_state); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } bool TextCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { +#ifdef USE_DEVICES case 3: this->device_id = value.as_uint32(); break; +#endif default: return false; } diff --git a/esphome/components/api/api_pb2_dump.cpp b/esphome/components/api/api_pb2_dump.cpp index 1d85bc31d5..f83112d240 100644 --- a/esphome/components/api/api_pb2_dump.cpp +++ b/esphome/components/api/api_pb2_dump.cpp @@ -3954,10 +3954,13 @@ void TextStateResponse::dump_to(std::string &out) const { out.append(YESNO(this->missing_state)); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } void TextCommandRequest::dump_to(std::string &out) const { @@ -3972,10 +3975,13 @@ void TextCommandRequest::dump_to(std::string &out) const { out.append("'").append(this->state).append("'"); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } #endif From dfdec8ec0ad76b6b8d4ea7e41cac1f6bd053fc70 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 15 Jul 2025 19:58:08 -1000 Subject: [PATCH 7/9] fix a few more that are missing --- esphome/components/api/api.proto | 8 ++++---- esphome/components/api/api_pb2.cpp | 12 ++++++++++++ esphome/components/api/api_pb2_dump.cpp | 12 ++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/esphome/components/api/api.proto b/esphome/components/api/api.proto index 87da838e87..4aba9af7f2 100644 --- a/esphome/components/api/api.proto +++ b/esphome/components/api/api.proto @@ -1961,7 +1961,7 @@ message DateStateResponse { uint32 year = 3; uint32 month = 4; uint32 day = 5; - uint32 device_id = 6; + uint32 device_id = 6 [(field_ifdef) = "USE_DEVICES"]; } message DateCommandRequest { option (id) = 102; @@ -1974,7 +1974,7 @@ message DateCommandRequest { uint32 year = 2; uint32 month = 3; uint32 day = 4; - uint32 device_id = 5; + uint32 device_id = 5 [(field_ifdef) = "USE_DEVICES"]; } // ==================== DATETIME TIME ==================== @@ -2008,7 +2008,7 @@ message TimeStateResponse { uint32 hour = 3; uint32 minute = 4; uint32 second = 5; - uint32 device_id = 6; + uint32 device_id = 6 [(field_ifdef) = "USE_DEVICES"]; } message TimeCommandRequest { option (id) = 105; @@ -2021,7 +2021,7 @@ message TimeCommandRequest { uint32 hour = 2; uint32 minute = 3; uint32 second = 4; - uint32 device_id = 5; + uint32 device_id = 5 [(field_ifdef) = "USE_DEVICES"]; } // ==================== EVENT ==================== diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index f67cda5bdd..b02d05bb38 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -2972,7 +2972,9 @@ void DateStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(3, this->year); buffer.encode_uint32(4, this->month); buffer.encode_uint32(5, this->day); +#ifdef USE_DEVICES buffer.encode_uint32(6, this->device_id); +#endif } void DateStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); @@ -2980,7 +2982,9 @@ void DateStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_uint32_field(total_size, 1, this->year); ProtoSize::add_uint32_field(total_size, 1, this->month); ProtoSize::add_uint32_field(total_size, 1, this->day); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } bool DateCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { @@ -2993,9 +2997,11 @@ bool DateCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { case 4: this->day = value.as_uint32(); break; +#ifdef USE_DEVICES case 5: this->device_id = value.as_uint32(); break; +#endif default: return false; } @@ -3045,7 +3051,9 @@ void TimeStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(3, this->hour); buffer.encode_uint32(4, this->minute); buffer.encode_uint32(5, this->second); +#ifdef USE_DEVICES buffer.encode_uint32(6, this->device_id); +#endif } void TimeStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); @@ -3053,7 +3061,9 @@ void TimeStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_uint32_field(total_size, 1, this->hour); ProtoSize::add_uint32_field(total_size, 1, this->minute); ProtoSize::add_uint32_field(total_size, 1, this->second); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } bool TimeCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { @@ -3066,9 +3076,11 @@ bool TimeCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { case 4: this->second = value.as_uint32(); break; +#ifdef USE_DEVICES case 5: this->device_id = value.as_uint32(); break; +#endif default: return false; } diff --git a/esphome/components/api/api_pb2_dump.cpp b/esphome/components/api/api_pb2_dump.cpp index f83112d240..51484cf6c4 100644 --- a/esphome/components/api/api_pb2_dump.cpp +++ b/esphome/components/api/api_pb2_dump.cpp @@ -4052,10 +4052,13 @@ void DateStateResponse::dump_to(std::string &out) const { out.append(buffer); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } void DateCommandRequest::dump_to(std::string &out) const { @@ -4081,10 +4084,13 @@ void DateCommandRequest::dump_to(std::string &out) const { out.append(buffer); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } #endif @@ -4155,10 +4161,13 @@ void TimeStateResponse::dump_to(std::string &out) const { out.append(buffer); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } void TimeCommandRequest::dump_to(std::string &out) const { @@ -4184,10 +4193,13 @@ void TimeCommandRequest::dump_to(std::string &out) const { out.append(buffer); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } #endif From 5adfb71fe12c1fe627e02b1a3e667b483dc802c5 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 15 Jul 2025 19:58:13 -1000 Subject: [PATCH 8/9] fix a few more that are missing --- esphome/components/api/api.proto | 6 +++--- esphome/components/api/api_pb2.cpp | 10 ++++++++++ esphome/components/api/api_pb2_dump.cpp | 9 +++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/esphome/components/api/api.proto b/esphome/components/api/api.proto index 4aba9af7f2..06c78bbad3 100644 --- a/esphome/components/api/api.proto +++ b/esphome/components/api/api.proto @@ -2052,7 +2052,7 @@ message EventResponse { fixed32 key = 1; string event_type = 2; - uint32 device_id = 3; + uint32 device_id = 3 [(field_ifdef) = "USE_DEVICES"]; } // ==================== VALVE ==================== @@ -2093,7 +2093,7 @@ message ValveStateResponse { fixed32 key = 1; float position = 2; ValveOperation current_operation = 3; - uint32 device_id = 4; + uint32 device_id = 4 [(field_ifdef) = "USE_DEVICES"]; } message ValveCommandRequest { @@ -2107,7 +2107,7 @@ message ValveCommandRequest { bool has_position = 2; float position = 3; bool stop = 4; - uint32 device_id = 5; + uint32 device_id = 5 [(field_ifdef) = "USE_DEVICES"]; } // ==================== DATETIME DATETIME ==================== diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index b02d05bb38..8ab38f897d 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -3137,12 +3137,16 @@ void ListEntitiesEventResponse::calculate_size(uint32_t &total_size) const { void EventResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_string(2, this->event_type); +#ifdef USE_DEVICES buffer.encode_uint32(3, this->device_id); +#endif } void EventResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->event_type); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } #endif #ifdef USE_VALVE @@ -3184,13 +3188,17 @@ void ValveStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_float(2, this->position); buffer.encode_uint32(3, static_cast(this->current_operation)); +#ifdef USE_DEVICES buffer.encode_uint32(4, this->device_id); +#endif } void ValveStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_float_field(total_size, 1, this->position); ProtoSize::add_enum_field(total_size, 1, static_cast(this->current_operation)); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } bool ValveCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { @@ -3200,9 +3208,11 @@ bool ValveCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { case 4: this->stop = value.as_bool(); break; +#ifdef USE_DEVICES case 5: this->device_id = value.as_uint32(); break; +#endif default: return false; } diff --git a/esphome/components/api/api_pb2_dump.cpp b/esphome/components/api/api_pb2_dump.cpp index 51484cf6c4..3f64134e1e 100644 --- a/esphome/components/api/api_pb2_dump.cpp +++ b/esphome/components/api/api_pb2_dump.cpp @@ -4265,10 +4265,13 @@ void EventResponse::dump_to(std::string &out) const { out.append("'").append(this->event_type).append("'"); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } #endif @@ -4345,10 +4348,13 @@ void ValveStateResponse::dump_to(std::string &out) const { out.append(proto_enum_to_string(this->current_operation)); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } void ValveCommandRequest::dump_to(std::string &out) const { @@ -4372,10 +4378,13 @@ void ValveCommandRequest::dump_to(std::string &out) const { out.append(YESNO(this->stop)); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } #endif From 561ed32b2abafb8ff0d092f9f742ac38d8e11944 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 15 Jul 2025 19:58:28 -1000 Subject: [PATCH 9/9] fix a few more that are missing --- esphome/components/api/api.proto | 6 +++--- esphome/components/api/api_pb2.cpp | 8 ++++++++ esphome/components/api/api_pb2_dump.cpp | 9 +++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/esphome/components/api/api.proto b/esphome/components/api/api.proto index 06c78bbad3..c8b046c1e2 100644 --- a/esphome/components/api/api.proto +++ b/esphome/components/api/api.proto @@ -2139,7 +2139,7 @@ message DateTimeStateResponse { // Equivalent to `!obj->has_state()` - inverse logic to make state packets smaller bool missing_state = 2; fixed32 epoch_seconds = 3; - uint32 device_id = 4; + uint32 device_id = 4 [(field_ifdef) = "USE_DEVICES"]; } message DateTimeCommandRequest { option (id) = 114; @@ -2150,7 +2150,7 @@ message DateTimeCommandRequest { fixed32 key = 1; fixed32 epoch_seconds = 2; - uint32 device_id = 3; + uint32 device_id = 3 [(field_ifdef) = "USE_DEVICES"]; } // ==================== UPDATE ==================== @@ -2204,5 +2204,5 @@ message UpdateCommandRequest { fixed32 key = 1; UpdateCommand command = 2; - uint32 device_id = 3; + uint32 device_id = 3 [(field_ifdef) = "USE_DEVICES"]; } diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index 8ab38f897d..010e483534 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -3263,19 +3263,25 @@ void DateTimeStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_bool(2, this->missing_state); buffer.encode_fixed32(3, this->epoch_seconds); +#ifdef USE_DEVICES buffer.encode_uint32(4, this->device_id); +#endif } void DateTimeStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_bool_field(total_size, 1, this->missing_state); ProtoSize::add_fixed32_field(total_size, 1, this->epoch_seconds); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } bool DateTimeCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { +#ifdef USE_DEVICES case 3: this->device_id = value.as_uint32(); break; +#endif default: return false; } @@ -3359,9 +3365,11 @@ bool UpdateCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { case 2: this->command = static_cast(value.as_uint32()); break; +#ifdef USE_DEVICES case 3: this->device_id = value.as_uint32(); break; +#endif default: return false; } diff --git a/esphome/components/api/api_pb2_dump.cpp b/esphome/components/api/api_pb2_dump.cpp index 3f64134e1e..7d4150a857 100644 --- a/esphome/components/api/api_pb2_dump.cpp +++ b/esphome/components/api/api_pb2_dump.cpp @@ -4445,10 +4445,13 @@ void DateTimeStateResponse::dump_to(std::string &out) const { out.append(buffer); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } void DateTimeCommandRequest::dump_to(std::string &out) const { @@ -4464,10 +4467,13 @@ void DateTimeCommandRequest::dump_to(std::string &out) const { out.append(buffer); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } #endif @@ -4581,10 +4587,13 @@ void UpdateCommandRequest::dump_to(std::string &out) const { out.append(proto_enum_to_string(this->command)); out.append("\n"); +#ifdef USE_DEVICES out.append(" device_id: "); snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id); out.append(buffer); out.append("\n"); + +#endif out.append("}"); } #endif