From a477249266b9dfc5b7e4a04429339c7ed653076c 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:35:26 +0000 Subject: [PATCH 01/13] [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 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 02/13] [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 9cac1c824e69e5ce7a8fa7074a29fbb6962e3a55 Mon Sep 17 00:00:00 2001 From: Thomas Rupprecht Date: Wed, 16 Jul 2025 05:22:33 +0200 Subject: [PATCH 03/13] [ssd1306_base] fix typo `brighrness` (#9491) --- esphome/components/ssd1306_base/ssd1306_base.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/ssd1306_base/ssd1306_base.cpp b/esphome/components/ssd1306_base/ssd1306_base.cpp index 1f039cff78..00425b853f 100644 --- a/esphome/components/ssd1306_base/ssd1306_base.cpp +++ b/esphome/components/ssd1306_base/ssd1306_base.cpp @@ -176,7 +176,7 @@ void SSD1306::setup() { // Disable scrolling mode (0x2E) this->command(SSD1306_COMMAND_DEACTIVATE_SCROLL); - // Contrast and brighrness + // Contrast and brightness // SSD1306 does not have brightness setting set_contrast(this->contrast_); if (this->is_ssd1305_()) From 231bcb1f7d0ee7d64bd6b6dc0c0de11f9180758b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 15 Jul 2025 17:24:20 -1000 Subject: [PATCH 04/13] Fix CI failures from merge collisions (#9535) --- 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 f3c0c0c00ce7a4848923959c7c6e8401243376af Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 15 Jul 2025 18:56:49 -1000 Subject: [PATCH 05/13] Remove legacy unique_id field from entities (#9022) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- esphome/components/adc/adc_sensor.h | 4 - esphome/components/adc/adc_sensor_esp8266.cpp | 2 - esphome/components/api/api.proto | 46 +++++----- esphome/components/api/api_connection.cpp | 30 ------ esphome/components/api/api_pb2.cpp | 46 ---------- esphome/components/api/api_pb2.h | 47 +++++----- esphome/components/api/api_pb2_dump.cpp | 92 ------------------- .../ethernet_info/ethernet_info_text_sensor.h | 3 - esphome/components/mqtt/mqtt_component.cpp | 22 ++--- esphome/components/mqtt/mqtt_component.h | 7 -- esphome/components/mqtt/mqtt_sensor.cpp | 1 - esphome/components/mqtt/mqtt_sensor.h | 1 - esphome/components/mqtt/mqtt_text_sensor.cpp | 1 - esphome/components/mqtt/mqtt_text_sensor.h | 1 - esphome/components/one_wire/one_wire.cpp | 2 - esphome/components/one_wire/one_wire.h | 2 - esphome/components/sensor/sensor.cpp | 1 - esphome/components/sensor/sensor.h | 9 -- .../components/text_sensor/text_sensor.cpp | 2 - esphome/components/text_sensor/text_sensor.h | 8 -- .../uptime/sensor/uptime_seconds_sensor.cpp | 1 - .../uptime/sensor/uptime_seconds_sensor.h | 2 - .../version/version_text_sensor.cpp | 1 - .../components/version/version_text_sensor.h | 1 - .../wifi_info/wifi_info_text_sensor.h | 6 -- .../wifi_signal/wifi_signal_sensor.h | 1 - 26 files changed, 54 insertions(+), 285 deletions(-) diff --git a/esphome/components/adc/adc_sensor.h b/esphome/components/adc/adc_sensor.h index 7b1f69e454..19648e7269 100644 --- a/esphome/components/adc/adc_sensor.h +++ b/esphome/components/adc/adc_sensor.h @@ -118,10 +118,6 @@ class ADCSensor : public sensor::Sensor, public PollingComponent, public voltage void set_autorange(bool autorange) { this->autorange_ = autorange; } #endif // USE_ESP32 -#ifdef USE_ESP8266 - std::string unique_id() override; -#endif // USE_ESP8266 - #ifdef USE_RP2040 void set_is_temperature() { this->is_temperature_ = true; } #endif // USE_RP2040 diff --git a/esphome/components/adc/adc_sensor_esp8266.cpp b/esphome/components/adc/adc_sensor_esp8266.cpp index 67128fb1f3..1123d83830 100644 --- a/esphome/components/adc/adc_sensor_esp8266.cpp +++ b/esphome/components/adc/adc_sensor_esp8266.cpp @@ -56,8 +56,6 @@ float ADCSensor::sample() { return aggr.aggregate() / 1024.0f; } -std::string ADCSensor::unique_id() { return get_mac_address() + "-adc"; } - } // namespace adc } // namespace esphome diff --git a/esphome/components/api/api.proto b/esphome/components/api/api.proto index 861b3471d7..8c5d6d2018 100644 --- a/esphome/components/api/api.proto +++ b/esphome/components/api/api.proto @@ -290,7 +290,7 @@ message ListEntitiesBinarySensorResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id string device_class = 5; bool is_status_binary_sensor = 6; @@ -324,7 +324,7 @@ message ListEntitiesCoverResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id bool assumed_state = 5; bool supports_position = 6; @@ -401,7 +401,7 @@ message ListEntitiesFanResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id bool supports_oscillation = 5; bool supports_speed = 6; @@ -484,7 +484,7 @@ message ListEntitiesLightResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id repeated ColorMode supported_color_modes = 12; // next four supports_* are for legacy clients, newer clients should use color modes @@ -582,7 +582,7 @@ message ListEntitiesSensorResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id string icon = 5; string unit_of_measurement = 6; @@ -621,7 +621,7 @@ message ListEntitiesSwitchResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id string icon = 5; bool assumed_state = 6; @@ -663,7 +663,7 @@ message ListEntitiesTextSensorResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id string icon = 5; bool disabled_by_default = 6; @@ -853,7 +853,7 @@ message ListEntitiesCameraResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id bool disabled_by_default = 5; string icon = 6; EntityCategory entity_category = 7; @@ -937,7 +937,7 @@ message ListEntitiesClimateResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id bool supports_current_temperature = 5; bool supports_two_point_target_temperature = 6; @@ -1038,7 +1038,7 @@ message ListEntitiesNumberResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id string icon = 5; float min_value = 6; @@ -1087,7 +1087,7 @@ message ListEntitiesSelectResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id string icon = 5; repeated string options = 6; @@ -1131,7 +1131,7 @@ message ListEntitiesSirenResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id string icon = 5; bool disabled_by_default = 6; @@ -1194,7 +1194,7 @@ message ListEntitiesLockResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id string icon = 5; bool disabled_by_default = 6; @@ -1243,7 +1243,7 @@ message ListEntitiesButtonResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id string icon = 5; bool disabled_by_default = 6; @@ -1298,7 +1298,7 @@ message ListEntitiesMediaPlayerResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id string icon = 5; bool disabled_by_default = 6; @@ -1845,7 +1845,7 @@ message ListEntitiesAlarmControlPanelResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id string icon = 5; bool disabled_by_default = 6; EntityCategory entity_category = 7; @@ -1892,7 +1892,7 @@ message ListEntitiesTextResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id string icon = 5; bool disabled_by_default = 6; EntityCategory entity_category = 7; @@ -1940,7 +1940,7 @@ message ListEntitiesDateResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id string icon = 5; bool disabled_by_default = 6; @@ -1987,7 +1987,7 @@ message ListEntitiesTimeResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id string icon = 5; bool disabled_by_default = 6; @@ -2034,7 +2034,7 @@ message ListEntitiesEventResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id string icon = 5; bool disabled_by_default = 6; @@ -2065,7 +2065,7 @@ message ListEntitiesValveResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id string icon = 5; bool disabled_by_default = 6; @@ -2120,7 +2120,7 @@ message ListEntitiesDateTimeResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id string icon = 5; bool disabled_by_default = 6; @@ -2163,7 +2163,7 @@ message ListEntitiesUpdateResponse { string object_id = 1; fixed32 key = 2; string name = 3; - string unique_id = 4; + reserved 4; // Deprecated: was string unique_id string icon = 5; bool disabled_by_default = 6; diff --git a/esphome/components/api/api_connection.cpp b/esphome/components/api/api_connection.cpp index dbe3c3fa98..a079c1fff1 100644 --- a/esphome/components/api/api_connection.cpp +++ b/esphome/components/api/api_connection.cpp @@ -241,10 +241,6 @@ void APIConnection::loop() { } } -std::string get_default_unique_id(const std::string &component_type, EntityBase *entity) { - return App.get_name() + component_type + entity->get_object_id(); -} - DisconnectResponse APIConnection::disconnect(const DisconnectRequest &msg) { // remote initiated disconnect_client // don't close yet, we still need to send the disconnect response @@ -331,7 +327,6 @@ uint16_t APIConnection::try_send_binary_sensor_info(EntityBase *entity, APIConne ListEntitiesBinarySensorResponse msg; msg.device_class = binary_sensor->get_device_class(); msg.is_status_binary_sensor = binary_sensor->is_status_binary_sensor(); - msg.unique_id = get_default_unique_id("binary_sensor", binary_sensor); fill_entity_info_base(binary_sensor, msg); return encode_message_to_buffer(msg, ListEntitiesBinarySensorResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -366,7 +361,6 @@ uint16_t APIConnection::try_send_cover_info(EntityBase *entity, APIConnection *c msg.supports_tilt = traits.get_supports_tilt(); msg.supports_stop = traits.get_supports_stop(); msg.device_class = cover->get_device_class(); - msg.unique_id = get_default_unique_id("cover", cover); fill_entity_info_base(cover, msg); return encode_message_to_buffer(msg, ListEntitiesCoverResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -429,7 +423,6 @@ uint16_t APIConnection::try_send_fan_info(EntityBase *entity, APIConnection *con msg.supported_speed_count = traits.supported_speed_count(); for (auto const &preset : traits.supported_preset_modes()) msg.supported_preset_modes.push_back(preset); - msg.unique_id = get_default_unique_id("fan", fan); fill_entity_info_base(fan, msg); return encode_message_to_buffer(msg, ListEntitiesFanResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -503,7 +496,6 @@ uint16_t APIConnection::try_send_light_info(EntityBase *entity, APIConnection *c msg.effects.push_back(effect->get_name()); } } - msg.unique_id = get_default_unique_id("light", light); fill_entity_info_base(light, msg); return encode_message_to_buffer(msg, ListEntitiesLightResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -565,9 +557,6 @@ uint16_t APIConnection::try_send_sensor_info(EntityBase *entity, APIConnection * msg.force_update = sensor->get_force_update(); msg.device_class = sensor->get_device_class(); msg.state_class = static_cast(sensor->get_state_class()); - msg.unique_id = sensor->unique_id(); - if (msg.unique_id.empty()) - msg.unique_id = get_default_unique_id("sensor", sensor); fill_entity_info_base(sensor, msg); return encode_message_to_buffer(msg, ListEntitiesSensorResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -594,7 +583,6 @@ uint16_t APIConnection::try_send_switch_info(EntityBase *entity, APIConnection * ListEntitiesSwitchResponse msg; msg.assumed_state = a_switch->assumed_state(); msg.device_class = a_switch->get_device_class(); - msg.unique_id = get_default_unique_id("switch", a_switch); fill_entity_info_base(a_switch, msg); return encode_message_to_buffer(msg, ListEntitiesSwitchResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -629,9 +617,6 @@ uint16_t APIConnection::try_send_text_sensor_info(EntityBase *entity, APIConnect auto *text_sensor = static_cast(entity); ListEntitiesTextSensorResponse msg; msg.device_class = text_sensor->get_device_class(); - msg.unique_id = text_sensor->unique_id(); - if (msg.unique_id.empty()) - msg.unique_id = get_default_unique_id("text_sensor", text_sensor); fill_entity_info_base(text_sensor, msg); return encode_message_to_buffer(msg, ListEntitiesTextSensorResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -704,7 +689,6 @@ uint16_t APIConnection::try_send_climate_info(EntityBase *entity, APIConnection msg.supported_custom_presets.push_back(custom_preset); for (auto swing_mode : traits.get_supported_swing_modes()) msg.supported_swing_modes.push_back(static_cast(swing_mode)); - msg.unique_id = get_default_unique_id("climate", climate); fill_entity_info_base(climate, msg); return encode_message_to_buffer(msg, ListEntitiesClimateResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -760,7 +744,6 @@ uint16_t APIConnection::try_send_number_info(EntityBase *entity, APIConnection * msg.min_value = number->traits.get_min_value(); msg.max_value = number->traits.get_max_value(); msg.step = number->traits.get_step(); - msg.unique_id = get_default_unique_id("number", number); fill_entity_info_base(number, msg); return encode_message_to_buffer(msg, ListEntitiesNumberResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -791,7 +774,6 @@ uint16_t APIConnection::try_send_date_info(EntityBase *entity, APIConnection *co bool is_single) { auto *date = static_cast(entity); ListEntitiesDateResponse msg; - msg.unique_id = get_default_unique_id("date", date); fill_entity_info_base(date, msg); return encode_message_to_buffer(msg, ListEntitiesDateResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -822,7 +804,6 @@ uint16_t APIConnection::try_send_time_info(EntityBase *entity, APIConnection *co bool is_single) { auto *time = static_cast(entity); ListEntitiesTimeResponse msg; - msg.unique_id = get_default_unique_id("time", time); fill_entity_info_base(time, msg); return encode_message_to_buffer(msg, ListEntitiesTimeResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -854,7 +835,6 @@ uint16_t APIConnection::try_send_datetime_info(EntityBase *entity, APIConnection bool is_single) { auto *datetime = static_cast(entity); ListEntitiesDateTimeResponse msg; - msg.unique_id = get_default_unique_id("datetime", datetime); fill_entity_info_base(datetime, msg); return encode_message_to_buffer(msg, ListEntitiesDateTimeResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -889,7 +869,6 @@ uint16_t APIConnection::try_send_text_info(EntityBase *entity, APIConnection *co msg.min_length = text->traits.get_min_length(); msg.max_length = text->traits.get_max_length(); msg.pattern = text->traits.get_pattern(); - msg.unique_id = get_default_unique_id("text", text); fill_entity_info_base(text, msg); return encode_message_to_buffer(msg, ListEntitiesTextResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -922,7 +901,6 @@ uint16_t APIConnection::try_send_select_info(EntityBase *entity, APIConnection * ListEntitiesSelectResponse msg; for (const auto &option : select->traits.get_options()) msg.options.push_back(option); - msg.unique_id = get_default_unique_id("select", select); fill_entity_info_base(select, msg); return encode_message_to_buffer(msg, ListEntitiesSelectResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -939,7 +917,6 @@ uint16_t APIConnection::try_send_button_info(EntityBase *entity, APIConnection * auto *button = static_cast(entity); ListEntitiesButtonResponse msg; msg.device_class = button->get_device_class(); - msg.unique_id = get_default_unique_id("button", button); fill_entity_info_base(button, msg); return encode_message_to_buffer(msg, ListEntitiesButtonResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -971,7 +948,6 @@ uint16_t APIConnection::try_send_lock_info(EntityBase *entity, APIConnection *co msg.assumed_state = a_lock->traits.get_assumed_state(); msg.supports_open = a_lock->traits.get_supports_open(); msg.requires_code = a_lock->traits.get_requires_code(); - msg.unique_id = get_default_unique_id("lock", a_lock); fill_entity_info_base(a_lock, msg); return encode_message_to_buffer(msg, ListEntitiesLockResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -1015,7 +991,6 @@ uint16_t APIConnection::try_send_valve_info(EntityBase *entity, APIConnection *c msg.assumed_state = traits.get_is_assumed_state(); msg.supports_position = traits.get_supports_position(); msg.supports_stop = traits.get_supports_stop(); - msg.unique_id = get_default_unique_id("valve", valve); fill_entity_info_base(valve, msg); return encode_message_to_buffer(msg, ListEntitiesValveResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -1062,7 +1037,6 @@ uint16_t APIConnection::try_send_media_player_info(EntityBase *entity, APIConnec media_format.sample_bytes = supported_format.sample_bytes; msg.supported_formats.push_back(media_format); } - msg.unique_id = get_default_unique_id("media_player", media_player); fill_entity_info_base(media_player, msg); return encode_message_to_buffer(msg, ListEntitiesMediaPlayerResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -1099,7 +1073,6 @@ uint16_t APIConnection::try_send_camera_info(EntityBase *entity, APIConnection * bool is_single) { auto *camera = static_cast(entity); ListEntitiesCameraResponse msg; - msg.unique_id = get_default_unique_id("camera", camera); fill_entity_info_base(camera, msg); return encode_message_to_buffer(msg, ListEntitiesCameraResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -1289,7 +1262,6 @@ uint16_t APIConnection::try_send_alarm_control_panel_info(EntityBase *entity, AP msg.supported_features = a_alarm_control_panel->get_supported_features(); msg.requires_code = a_alarm_control_panel->get_requires_code(); msg.requires_code_to_arm = a_alarm_control_panel->get_requires_code_to_arm(); - msg.unique_id = get_default_unique_id("alarm_control_panel", a_alarm_control_panel); fill_entity_info_base(a_alarm_control_panel, msg); return encode_message_to_buffer(msg, ListEntitiesAlarmControlPanelResponse::MESSAGE_TYPE, conn, remaining_size, is_single); @@ -1344,7 +1316,6 @@ uint16_t APIConnection::try_send_event_info(EntityBase *entity, APIConnection *c msg.device_class = event->get_device_class(); for (const auto &event_type : event->get_event_types()) msg.event_types.push_back(event_type); - msg.unique_id = get_default_unique_id("event", event); fill_entity_info_base(event, msg); return encode_message_to_buffer(msg, ListEntitiesEventResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -1380,7 +1351,6 @@ uint16_t APIConnection::try_send_update_info(EntityBase *entity, APIConnection * auto *update = static_cast(entity); ListEntitiesUpdateResponse msg; msg.device_class = update->get_device_class(); - msg.unique_id = get_default_unique_id("update", update); fill_entity_info_base(update, msg); return encode_message_to_buffer(msg, ListEntitiesUpdateResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index b6212d915e..5e0f0a4fb6 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -174,7 +174,6 @@ void ListEntitiesBinarySensorResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_string(5, this->device_class); buffer.encode_bool(6, this->is_status_binary_sensor); buffer.encode_bool(7, this->disabled_by_default); @@ -186,7 +185,6 @@ void ListEntitiesBinarySensorResponse::calculate_size(uint32_t &total_size) cons ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->device_class); ProtoSize::add_bool_field(total_size, 1, this->is_status_binary_sensor); ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default); @@ -212,7 +210,6 @@ void ListEntitiesCoverResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_bool(5, this->assumed_state); buffer.encode_bool(6, this->supports_position); buffer.encode_bool(7, this->supports_tilt); @@ -227,7 +224,6 @@ void ListEntitiesCoverResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_bool_field(total_size, 1, this->assumed_state); ProtoSize::add_bool_field(total_size, 1, this->supports_position); ProtoSize::add_bool_field(total_size, 1, this->supports_tilt); @@ -301,7 +297,6 @@ void ListEntitiesFanResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_bool(5, this->supports_oscillation); buffer.encode_bool(6, this->supports_speed); buffer.encode_bool(7, this->supports_direction); @@ -318,7 +313,6 @@ void ListEntitiesFanResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_bool_field(total_size, 1, this->supports_oscillation); ProtoSize::add_bool_field(total_size, 1, this->supports_speed); ProtoSize::add_bool_field(total_size, 1, this->supports_direction); @@ -422,7 +416,6 @@ void ListEntitiesLightResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); for (auto &it : this->supported_color_modes) { buffer.encode_uint32(12, static_cast(it), true); } @@ -444,7 +437,6 @@ void ListEntitiesLightResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); if (!this->supported_color_modes.empty()) { for (const auto &it : this->supported_color_modes) { ProtoSize::add_enum_field_repeated(total_size, 1, static_cast(it)); @@ -609,7 +601,6 @@ void ListEntitiesSensorResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_string(5, this->icon); buffer.encode_string(6, this->unit_of_measurement); buffer.encode_int32(7, this->accuracy_decimals); @@ -625,7 +616,6 @@ void ListEntitiesSensorResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_string_field(total_size, 1, this->unit_of_measurement); ProtoSize::add_int32_field(total_size, 1, this->accuracy_decimals); @@ -655,7 +645,6 @@ void ListEntitiesSwitchResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_string(5, this->icon); buffer.encode_bool(6, this->assumed_state); buffer.encode_bool(7, this->disabled_by_default); @@ -667,7 +656,6 @@ void ListEntitiesSwitchResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_bool_field(total_size, 1, this->assumed_state); ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default); @@ -714,7 +702,6 @@ void ListEntitiesTextSensorResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_string(5, this->icon); buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); @@ -725,7 +712,6 @@ void ListEntitiesTextSensorResponse::calculate_size(uint32_t &total_size) const ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default); ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category)); @@ -1025,7 +1011,6 @@ void ListEntitiesCameraResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_bool(5, this->disabled_by_default); buffer.encode_string(6, this->icon); buffer.encode_uint32(7, static_cast(this->entity_category)); @@ -1035,7 +1020,6 @@ void ListEntitiesCameraResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default); ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category)); @@ -1072,7 +1056,6 @@ void ListEntitiesClimateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_bool(5, this->supports_current_temperature); buffer.encode_bool(6, this->supports_two_point_target_temperature); for (auto &it : this->supported_modes) { @@ -1112,7 +1095,6 @@ void ListEntitiesClimateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_bool_field(total_size, 1, this->supports_current_temperature); ProtoSize::add_bool_field(total_size, 1, this->supports_two_point_target_temperature); if (!this->supported_modes.empty()) { @@ -1295,7 +1277,6 @@ void ListEntitiesNumberResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_string(5, this->icon); buffer.encode_float(6, this->min_value); buffer.encode_float(7, this->max_value); @@ -1311,7 +1292,6 @@ void ListEntitiesNumberResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_float_field(total_size, 1, this->min_value); ProtoSize::add_float_field(total_size, 1, this->max_value); @@ -1364,7 +1344,6 @@ void ListEntitiesSelectResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_string(5, this->icon); for (auto &it : this->options) { buffer.encode_string(6, it, true); @@ -1377,7 +1356,6 @@ void ListEntitiesSelectResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->icon); if (!this->options.empty()) { for (const auto &it : this->options) { @@ -1436,7 +1414,6 @@ void ListEntitiesSirenResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_string(5, this->icon); buffer.encode_bool(6, this->disabled_by_default); for (auto &it : this->tones) { @@ -1451,7 +1428,6 @@ void ListEntitiesSirenResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default); if (!this->tones.empty()) { @@ -1531,7 +1507,6 @@ void ListEntitiesLockResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_string(5, this->icon); buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); @@ -1545,7 +1520,6 @@ void ListEntitiesLockResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default); ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category)); @@ -1607,7 +1581,6 @@ void ListEntitiesButtonResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_string(5, this->icon); buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); @@ -1618,7 +1591,6 @@ void ListEntitiesButtonResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default); ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category)); @@ -1694,7 +1666,6 @@ void ListEntitiesMediaPlayerResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_string(5, this->icon); buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); @@ -1708,7 +1679,6 @@ void ListEntitiesMediaPlayerResponse::calculate_size(uint32_t &total_size) const ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default); ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category)); @@ -2553,7 +2523,6 @@ void ListEntitiesAlarmControlPanelResponse::encode(ProtoWriteBuffer buffer) cons buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_string(5, this->icon); buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); @@ -2566,7 +2535,6 @@ void ListEntitiesAlarmControlPanelResponse::calculate_size(uint32_t &total_size) ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default); ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category)); @@ -2624,7 +2592,6 @@ void ListEntitiesTextResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_string(5, this->icon); buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); @@ -2638,7 +2605,6 @@ void ListEntitiesTextResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default); ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category)); @@ -2696,7 +2662,6 @@ void ListEntitiesDateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_string(5, this->icon); buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); @@ -2706,7 +2671,6 @@ void ListEntitiesDateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default); ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category)); @@ -2763,7 +2727,6 @@ void ListEntitiesTimeResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_string(5, this->icon); buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); @@ -2773,7 +2736,6 @@ void ListEntitiesTimeResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default); ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category)); @@ -2830,7 +2792,6 @@ void ListEntitiesEventResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_string(5, this->icon); buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); @@ -2844,7 +2805,6 @@ void ListEntitiesEventResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default); ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category)); @@ -2872,7 +2832,6 @@ void ListEntitiesValveResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_string(5, this->icon); buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); @@ -2886,7 +2845,6 @@ void ListEntitiesValveResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default); ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category)); @@ -2943,7 +2901,6 @@ void ListEntitiesDateTimeResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_string(5, this->icon); buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); @@ -2953,7 +2910,6 @@ void ListEntitiesDateTimeResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default); ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category)); @@ -3000,7 +2956,6 @@ void ListEntitiesUpdateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); buffer.encode_string(3, this->name); - buffer.encode_string(4, this->unique_id); buffer.encode_string(5, this->icon); buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); @@ -3011,7 +2966,6 @@ void ListEntitiesUpdateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default); ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category)); diff --git a/esphome/components/api/api_pb2.h b/esphome/components/api/api_pb2.h index 3f2d4afad3..e84e814f44 100644 --- a/esphome/components/api/api_pb2.h +++ b/esphome/components/api/api_pb2.h @@ -291,7 +291,6 @@ class InfoResponseProtoMessage : public ProtoMessage { std::string object_id{}; uint32_t key{0}; std::string name{}; - std::string unique_id{}; bool disabled_by_default{false}; std::string icon{}; enums::EntityCategory entity_category{}; @@ -559,7 +558,7 @@ class SubscribeStatesRequest : public ProtoMessage { class ListEntitiesBinarySensorResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 12; - static constexpr uint8_t ESTIMATED_SIZE = 60; + static constexpr uint8_t ESTIMATED_SIZE = 51; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_binary_sensor_response"; } #endif @@ -595,7 +594,7 @@ class BinarySensorStateResponse : public StateResponseProtoMessage { class ListEntitiesCoverResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 13; - static constexpr uint8_t ESTIMATED_SIZE = 66; + static constexpr uint8_t ESTIMATED_SIZE = 57; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_cover_response"; } #endif @@ -658,7 +657,7 @@ class CoverCommandRequest : public CommandProtoMessage { class ListEntitiesFanResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 14; - static constexpr uint8_t ESTIMATED_SIZE = 77; + static constexpr uint8_t ESTIMATED_SIZE = 68; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_fan_response"; } #endif @@ -729,7 +728,7 @@ class FanCommandRequest : public CommandProtoMessage { class ListEntitiesLightResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 15; - static constexpr uint8_t ESTIMATED_SIZE = 90; + static constexpr uint8_t ESTIMATED_SIZE = 81; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_light_response"; } #endif @@ -823,7 +822,7 @@ class LightCommandRequest : public CommandProtoMessage { class ListEntitiesSensorResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 16; - static constexpr uint8_t ESTIMATED_SIZE = 77; + static constexpr uint8_t ESTIMATED_SIZE = 68; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_sensor_response"; } #endif @@ -863,7 +862,7 @@ class SensorStateResponse : public StateResponseProtoMessage { class ListEntitiesSwitchResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 17; - static constexpr uint8_t ESTIMATED_SIZE = 60; + static constexpr uint8_t ESTIMATED_SIZE = 51; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_switch_response"; } #endif @@ -914,7 +913,7 @@ class SwitchCommandRequest : public CommandProtoMessage { class ListEntitiesTextSensorResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 18; - static constexpr uint8_t ESTIMATED_SIZE = 58; + static constexpr uint8_t ESTIMATED_SIZE = 49; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_text_sensor_response"; } #endif @@ -1213,7 +1212,7 @@ class ExecuteServiceRequest : public ProtoMessage { class ListEntitiesCameraResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 43; - static constexpr uint8_t ESTIMATED_SIZE = 49; + static constexpr uint8_t ESTIMATED_SIZE = 40; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_camera_response"; } #endif @@ -1263,7 +1262,7 @@ class CameraImageRequest : public ProtoMessage { class ListEntitiesClimateResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 46; - static constexpr uint8_t ESTIMATED_SIZE = 156; + static constexpr uint8_t ESTIMATED_SIZE = 147; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_climate_response"; } #endif @@ -1365,7 +1364,7 @@ class ClimateCommandRequest : public CommandProtoMessage { class ListEntitiesNumberResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 49; - static constexpr uint8_t ESTIMATED_SIZE = 84; + static constexpr uint8_t ESTIMATED_SIZE = 75; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_number_response"; } #endif @@ -1421,7 +1420,7 @@ class NumberCommandRequest : public CommandProtoMessage { class ListEntitiesSelectResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 52; - static constexpr uint8_t ESTIMATED_SIZE = 67; + static constexpr uint8_t ESTIMATED_SIZE = 58; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_select_response"; } #endif @@ -1473,7 +1472,7 @@ class SelectCommandRequest : public CommandProtoMessage { class ListEntitiesSirenResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 55; - static constexpr uint8_t ESTIMATED_SIZE = 71; + static constexpr uint8_t ESTIMATED_SIZE = 62; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_siren_response"; } #endif @@ -1533,7 +1532,7 @@ class SirenCommandRequest : public CommandProtoMessage { class ListEntitiesLockResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 58; - static constexpr uint8_t ESTIMATED_SIZE = 64; + static constexpr uint8_t ESTIMATED_SIZE = 55; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_lock_response"; } #endif @@ -1589,7 +1588,7 @@ class LockCommandRequest : public CommandProtoMessage { class ListEntitiesButtonResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 61; - static constexpr uint8_t ESTIMATED_SIZE = 58; + static constexpr uint8_t ESTIMATED_SIZE = 49; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_button_response"; } #endif @@ -1639,7 +1638,7 @@ class MediaPlayerSupportedFormat : public ProtoMessage { class ListEntitiesMediaPlayerResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 63; - static constexpr uint8_t ESTIMATED_SIZE = 85; + static constexpr uint8_t ESTIMATED_SIZE = 76; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_media_player_response"; } #endif @@ -2453,7 +2452,7 @@ class VoiceAssistantSetConfiguration : public ProtoMessage { class ListEntitiesAlarmControlPanelResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 94; - static constexpr uint8_t ESTIMATED_SIZE = 57; + static constexpr uint8_t ESTIMATED_SIZE = 48; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_alarm_control_panel_response"; } #endif @@ -2507,7 +2506,7 @@ class AlarmControlPanelCommandRequest : public CommandProtoMessage { class ListEntitiesTextResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 97; - static constexpr uint8_t ESTIMATED_SIZE = 68; + static constexpr uint8_t ESTIMATED_SIZE = 59; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_text_response"; } #endif @@ -2562,7 +2561,7 @@ class TextCommandRequest : public CommandProtoMessage { class ListEntitiesDateResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 100; - static constexpr uint8_t ESTIMATED_SIZE = 49; + static constexpr uint8_t ESTIMATED_SIZE = 40; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_date_response"; } #endif @@ -2616,7 +2615,7 @@ class DateCommandRequest : public CommandProtoMessage { class ListEntitiesTimeResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 103; - static constexpr uint8_t ESTIMATED_SIZE = 49; + static constexpr uint8_t ESTIMATED_SIZE = 40; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_time_response"; } #endif @@ -2670,7 +2669,7 @@ class TimeCommandRequest : public CommandProtoMessage { class ListEntitiesEventResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 107; - static constexpr uint8_t ESTIMATED_SIZE = 76; + static constexpr uint8_t ESTIMATED_SIZE = 67; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_event_response"; } #endif @@ -2705,7 +2704,7 @@ class EventResponse : public StateResponseProtoMessage { class ListEntitiesValveResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 109; - static constexpr uint8_t ESTIMATED_SIZE = 64; + static constexpr uint8_t ESTIMATED_SIZE = 55; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_valve_response"; } #endif @@ -2761,7 +2760,7 @@ class ValveCommandRequest : public CommandProtoMessage { class ListEntitiesDateTimeResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 112; - static constexpr uint8_t ESTIMATED_SIZE = 49; + static constexpr uint8_t ESTIMATED_SIZE = 40; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_date_time_response"; } #endif @@ -2811,7 +2810,7 @@ class DateTimeCommandRequest : public CommandProtoMessage { class ListEntitiesUpdateResponse : public InfoResponseProtoMessage { public: static constexpr uint8_t MESSAGE_TYPE = 116; - static constexpr uint8_t ESTIMATED_SIZE = 58; + static constexpr uint8_t ESTIMATED_SIZE = 49; #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_update_response"; } #endif diff --git a/esphome/components/api/api_pb2_dump.cpp b/esphome/components/api/api_pb2_dump.cpp index f6509f47cc..647ef3881a 100644 --- a/esphome/components/api/api_pb2_dump.cpp +++ b/esphome/components/api/api_pb2_dump.cpp @@ -807,10 +807,6 @@ void ListEntitiesBinarySensorResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" device_class: "); out.append("'").append(this->device_class).append("'"); out.append("\n"); @@ -877,10 +873,6 @@ void ListEntitiesCoverResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" assumed_state: "); out.append(YESNO(this->assumed_state)); out.append("\n"); @@ -1013,10 +1005,6 @@ void ListEntitiesFanResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" supports_oscillation: "); out.append(YESNO(this->supports_oscillation)); out.append("\n"); @@ -1178,10 +1166,6 @@ void ListEntitiesLightResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - for (const auto &it : this->supported_color_modes) { out.append(" supported_color_modes: "); out.append(proto_enum_to_string(it)); @@ -1456,10 +1440,6 @@ void ListEntitiesSensorResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" icon: "); out.append("'").append(this->icon).append("'"); out.append("\n"); @@ -1544,10 +1524,6 @@ void ListEntitiesSwitchResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" icon: "); out.append("'").append(this->icon).append("'"); out.append("\n"); @@ -1628,10 +1604,6 @@ void ListEntitiesTextSensorResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" icon: "); out.append("'").append(this->icon).append("'"); out.append("\n"); @@ -1931,10 +1903,6 @@ void ListEntitiesCameraResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" disabled_by_default: "); out.append(YESNO(this->disabled_by_default)); out.append("\n"); @@ -2005,10 +1973,6 @@ void ListEntitiesClimateResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" supports_current_temperature: "); out.append(YESNO(this->supports_current_temperature)); out.append("\n"); @@ -2317,10 +2281,6 @@ void ListEntitiesNumberResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" icon: "); out.append("'").append(this->icon).append("'"); out.append("\n"); @@ -2426,10 +2386,6 @@ void ListEntitiesSelectResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" icon: "); out.append("'").append(this->icon).append("'"); out.append("\n"); @@ -2512,10 +2468,6 @@ void ListEntitiesSirenResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" icon: "); out.append("'").append(this->icon).append("'"); out.append("\n"); @@ -2632,10 +2584,6 @@ void ListEntitiesLockResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" icon: "); out.append("'").append(this->icon).append("'"); out.append("\n"); @@ -2732,10 +2680,6 @@ void ListEntitiesButtonResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" icon: "); out.append("'").append(this->icon).append("'"); out.append("\n"); @@ -2817,10 +2761,6 @@ void ListEntitiesMediaPlayerResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" icon: "); out.append("'").append(this->icon).append("'"); out.append("\n"); @@ -3678,10 +3618,6 @@ void ListEntitiesAlarmControlPanelResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" icon: "); out.append("'").append(this->icon).append("'"); out.append("\n"); @@ -3771,10 +3707,6 @@ void ListEntitiesTextResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" icon: "); out.append("'").append(this->icon).append("'"); out.append("\n"); @@ -3869,10 +3801,6 @@ void ListEntitiesDateResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" icon: "); out.append("'").append(this->icon).append("'"); out.append("\n"); @@ -3971,10 +3899,6 @@ void ListEntitiesTimeResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" icon: "); out.append("'").append(this->icon).append("'"); out.append("\n"); @@ -4073,10 +3997,6 @@ void ListEntitiesEventResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" icon: "); out.append("'").append(this->icon).append("'"); out.append("\n"); @@ -4141,10 +4061,6 @@ void ListEntitiesValveResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" icon: "); out.append("'").append(this->icon).append("'"); out.append("\n"); @@ -4247,10 +4163,6 @@ void ListEntitiesDateTimeResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" icon: "); out.append("'").append(this->icon).append("'"); out.append("\n"); @@ -4329,10 +4241,6 @@ void ListEntitiesUpdateResponse::dump_to(std::string &out) const { out.append("'").append(this->name).append("'"); out.append("\n"); - out.append(" unique_id: "); - out.append("'").append(this->unique_id).append("'"); - out.append("\n"); - out.append(" icon: "); out.append("'").append(this->icon).append("'"); out.append("\n"); diff --git a/esphome/components/ethernet_info/ethernet_info_text_sensor.h b/esphome/components/ethernet_info/ethernet_info_text_sensor.h index 2e67694bbd..2adc08e31e 100644 --- a/esphome/components/ethernet_info/ethernet_info_text_sensor.h +++ b/esphome/components/ethernet_info/ethernet_info_text_sensor.h @@ -29,7 +29,6 @@ class IPAddressEthernetInfo : public PollingComponent, public text_sensor::TextS } float get_setup_priority() const override { return setup_priority::ETHERNET; } - std::string unique_id() override { return get_mac_address() + "-ethernetinfo"; } void dump_config() override; void add_ip_sensors(uint8_t index, text_sensor::TextSensor *s) { this->ip_sensors_[index] = s; } @@ -52,7 +51,6 @@ class DNSAddressEthernetInfo : public PollingComponent, public text_sensor::Text } } float get_setup_priority() const override { return setup_priority::ETHERNET; } - std::string unique_id() override { return get_mac_address() + "-ethernetinfo-dns"; } void dump_config() override; protected: @@ -63,7 +61,6 @@ class MACAddressEthernetInfo : public Component, public text_sensor::TextSensor public: void setup() override { this->publish_state(ethernet::global_eth_component->get_eth_mac_address_pretty()); } float get_setup_priority() const override { return setup_priority::ETHERNET; } - std::string unique_id() override { return get_mac_address() + "-ethernetinfo-mac"; } void dump_config() override; }; diff --git a/esphome/components/mqtt/mqtt_component.cpp b/esphome/components/mqtt/mqtt_component.cpp index b51f4d903e..6ceaf219ff 100644 --- a/esphome/components/mqtt/mqtt_component.cpp +++ b/esphome/components/mqtt/mqtt_component.cpp @@ -129,21 +129,16 @@ bool MQTTComponent::send_discovery_() { root[MQTT_PAYLOAD_NOT_AVAILABLE] = this->availability_->payload_not_available; } - std::string unique_id = this->unique_id(); const MQTTDiscoveryInfo &discovery_info = global_mqtt_client->get_discovery_info(); - if (!unique_id.empty()) { - root[MQTT_UNIQUE_ID] = unique_id; + if (discovery_info.unique_id_generator == MQTT_MAC_ADDRESS_UNIQUE_ID_GENERATOR) { + char friendly_name_hash[9]; + sprintf(friendly_name_hash, "%08" PRIx32, fnv1_hash(this->friendly_name())); + friendly_name_hash[8] = 0; // ensure the hash-string ends with null + root[MQTT_UNIQUE_ID] = get_mac_address() + "-" + this->component_type() + "-" + friendly_name_hash; } else { - if (discovery_info.unique_id_generator == MQTT_MAC_ADDRESS_UNIQUE_ID_GENERATOR) { - char friendly_name_hash[9]; - sprintf(friendly_name_hash, "%08" PRIx32, fnv1_hash(this->friendly_name())); - friendly_name_hash[8] = 0; // ensure the hash-string ends with null - root[MQTT_UNIQUE_ID] = get_mac_address() + "-" + this->component_type() + "-" + friendly_name_hash; - } else { - // default to almost-unique ID. It's a hack but the only way to get that - // gorgeous device registry view. - root[MQTT_UNIQUE_ID] = "ESP" + this->component_type() + this->get_default_object_id_(); - } + // default to almost-unique ID. It's a hack but the only way to get that + // gorgeous device registry view. + root[MQTT_UNIQUE_ID] = "ESP" + this->component_type() + this->get_default_object_id_(); } const std::string &node_name = App.get_name(); @@ -286,7 +281,6 @@ void MQTTComponent::call_dump_config() { this->dump_config(); } void MQTTComponent::schedule_resend_state() { this->resend_state_ = true; } -std::string MQTTComponent::unique_id() { return ""; } bool MQTTComponent::is_connected_() const { return global_mqtt_client->is_connected(); } // Pull these properties from EntityBase if not overridden diff --git a/esphome/components/mqtt/mqtt_component.h b/esphome/components/mqtt/mqtt_component.h index 01ba98ad40..851fdd842c 100644 --- a/esphome/components/mqtt/mqtt_component.h +++ b/esphome/components/mqtt/mqtt_component.h @@ -164,13 +164,6 @@ class MQTTComponent : public Component { */ virtual const EntityBase *get_entity() const = 0; - /** A unique ID for this MQTT component, empty for no unique id. See unique ID requirements: - * https://developers.home-assistant.io/docs/en/entity_registry_index.html#unique-id-requirements - * - * @return The unique id as a string. - */ - virtual std::string unique_id(); - /// Get the friendly name of this MQTT component. virtual std::string friendly_name() const; diff --git a/esphome/components/mqtt/mqtt_sensor.cpp b/esphome/components/mqtt/mqtt_sensor.cpp index 9324ea9bb1..2e1db1908f 100644 --- a/esphome/components/mqtt/mqtt_sensor.cpp +++ b/esphome/components/mqtt/mqtt_sensor.cpp @@ -76,7 +76,6 @@ bool MQTTSensorComponent::publish_state(float value) { int8_t accuracy = this->sensor_->get_accuracy_decimals(); return this->publish(this->get_state_topic_(), value_accuracy_to_string(value, accuracy)); } -std::string MQTTSensorComponent::unique_id() { return this->sensor_->unique_id(); } } // namespace mqtt } // namespace esphome diff --git a/esphome/components/mqtt/mqtt_sensor.h b/esphome/components/mqtt/mqtt_sensor.h index adc201736a..15ea703ad4 100644 --- a/esphome/components/mqtt/mqtt_sensor.h +++ b/esphome/components/mqtt/mqtt_sensor.h @@ -46,7 +46,6 @@ class MQTTSensorComponent : public mqtt::MQTTComponent { /// Override for MQTTComponent, returns "sensor". std::string component_type() const override; const EntityBase *get_entity() const override; - std::string unique_id() override; sensor::Sensor *sensor_; optional expire_after_; // Override the expire after advertised to Home Assistant diff --git a/esphome/components/mqtt/mqtt_text_sensor.cpp b/esphome/components/mqtt/mqtt_text_sensor.cpp index 0cc5de07a3..42260ed2a8 100644 --- a/esphome/components/mqtt/mqtt_text_sensor.cpp +++ b/esphome/components/mqtt/mqtt_text_sensor.cpp @@ -40,7 +40,6 @@ bool MQTTTextSensor::send_initial_state() { } std::string MQTTTextSensor::component_type() const { return "sensor"; } const EntityBase *MQTTTextSensor::get_entity() const { return this->sensor_; } -std::string MQTTTextSensor::unique_id() { return this->sensor_->unique_id(); } } // namespace mqtt } // namespace esphome diff --git a/esphome/components/mqtt/mqtt_text_sensor.h b/esphome/components/mqtt/mqtt_text_sensor.h index fe53a6fefd..9a14efdd16 100644 --- a/esphome/components/mqtt/mqtt_text_sensor.h +++ b/esphome/components/mqtt/mqtt_text_sensor.h @@ -28,7 +28,6 @@ class MQTTTextSensor : public mqtt::MQTTComponent { protected: std::string component_type() const override; const EntityBase *get_entity() const override; - std::string unique_id() override; text_sensor::TextSensor *sensor_; }; diff --git a/esphome/components/one_wire/one_wire.cpp b/esphome/components/one_wire/one_wire.cpp index 131bc4fbfe..96e6145f63 100644 --- a/esphome/components/one_wire/one_wire.cpp +++ b/esphome/components/one_wire/one_wire.cpp @@ -11,8 +11,6 @@ const std::string &OneWireDevice::get_address_name() { return this->address_name_; } -std::string OneWireDevice::unique_id() { return "dallas-" + str_lower_case(format_hex(this->address_)); } - bool OneWireDevice::send_command_(uint8_t cmd) { if (!this->bus_->select(this->address_)) return false; diff --git a/esphome/components/one_wire/one_wire.h b/esphome/components/one_wire/one_wire.h index bf10e4f82e..e83c6e81e8 100644 --- a/esphome/components/one_wire/one_wire.h +++ b/esphome/components/one_wire/one_wire.h @@ -24,8 +24,6 @@ class OneWireDevice { /// Helper to create (and cache) the name for this sensor. For example "0xfe0000031f1eaf29". const std::string &get_address_name(); - std::string unique_id(); - protected: uint64_t address_{0}; OneWireBus *bus_{nullptr}; ///< pointer to OneWireBus instance diff --git a/esphome/components/sensor/sensor.cpp b/esphome/components/sensor/sensor.cpp index 7dab63b026..0a82677bc9 100644 --- a/esphome/components/sensor/sensor.cpp +++ b/esphome/components/sensor/sensor.cpp @@ -96,7 +96,6 @@ void Sensor::clear_filters() { } float Sensor::get_state() const { return this->state; } float Sensor::get_raw_state() const { return this->raw_state; } -std::string Sensor::unique_id() { return ""; } void Sensor::internal_send_state_to_frontend(float state) { this->set_has_state(true); diff --git a/esphome/components/sensor/sensor.h b/esphome/components/sensor/sensor.h index 3fb6e5522b..c2ded0f2c3 100644 --- a/esphome/components/sensor/sensor.h +++ b/esphome/components/sensor/sensor.h @@ -28,9 +28,6 @@ namespace sensor { if (!(obj)->get_icon().empty()) { \ ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, (obj)->get_icon().c_str()); \ } \ - if (!(obj)->unique_id().empty()) { \ - ESP_LOGV(TAG, "%s Unique ID: '%s'", prefix, (obj)->unique_id().c_str()); \ - } \ if ((obj)->get_force_update()) { \ ESP_LOGV(TAG, "%s Force Update: YES", prefix); \ } \ @@ -141,12 +138,6 @@ class Sensor : public EntityBase, public EntityBase_DeviceClass, public EntityBa */ float raw_state; - /** Override this method to set the unique ID of this sensor. - * - * @deprecated Do not use for new sensors, a suitable unique ID is automatically generated (2023.4). - */ - virtual std::string unique_id(); - void internal_send_state_to_frontend(float state); protected: diff --git a/esphome/components/text_sensor/text_sensor.cpp b/esphome/components/text_sensor/text_sensor.cpp index c57e0ffefb..72b540b84c 100644 --- a/esphome/components/text_sensor/text_sensor.cpp +++ b/esphome/components/text_sensor/text_sensor.cpp @@ -70,7 +70,5 @@ void TextSensor::internal_send_state_to_frontend(const std::string &state) { this->callback_.call(state); } -std::string TextSensor::unique_id() { return ""; } - } // namespace text_sensor } // namespace esphome diff --git a/esphome/components/text_sensor/text_sensor.h b/esphome/components/text_sensor/text_sensor.h index b27145aa18..b54f75155b 100644 --- a/esphome/components/text_sensor/text_sensor.h +++ b/esphome/components/text_sensor/text_sensor.h @@ -20,9 +20,6 @@ namespace text_sensor { if (!(obj)->get_icon().empty()) { \ ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, (obj)->get_icon().c_str()); \ } \ - if (!(obj)->unique_id().empty()) { \ - ESP_LOGV(TAG, "%s Unique ID: '%s'", prefix, (obj)->unique_id().c_str()); \ - } \ } #define SUB_TEXT_SENSOR(name) \ @@ -64,11 +61,6 @@ class TextSensor : public EntityBase, public EntityBase_DeviceClass { // ========== INTERNAL METHODS ========== // (In most use cases you won't need these) - /** Override this method to set the unique ID of this sensor. - * - * @deprecated Do not use for new sensors, a suitable unique ID is automatically generated (2023.4). - */ - virtual std::string unique_id(); void internal_send_state_to_frontend(const std::string &state); diff --git a/esphome/components/uptime/sensor/uptime_seconds_sensor.cpp b/esphome/components/uptime/sensor/uptime_seconds_sensor.cpp index fa6b9d621d..54260d7e80 100644 --- a/esphome/components/uptime/sensor/uptime_seconds_sensor.cpp +++ b/esphome/components/uptime/sensor/uptime_seconds_sensor.cpp @@ -27,7 +27,6 @@ void UptimeSecondsSensor::update() { const float seconds = float(seconds_int) + (this->uptime_ % 1000ULL) / 1000.0f; this->publish_state(seconds); } -std::string UptimeSecondsSensor::unique_id() { return get_mac_address() + "-uptime"; } float UptimeSecondsSensor::get_setup_priority() const { return setup_priority::HARDWARE; } void UptimeSecondsSensor::dump_config() { LOG_SENSOR("", "Uptime Sensor", this); diff --git a/esphome/components/uptime/sensor/uptime_seconds_sensor.h b/esphome/components/uptime/sensor/uptime_seconds_sensor.h index 41b3647822..210195052f 100644 --- a/esphome/components/uptime/sensor/uptime_seconds_sensor.h +++ b/esphome/components/uptime/sensor/uptime_seconds_sensor.h @@ -13,8 +13,6 @@ class UptimeSecondsSensor : public sensor::Sensor, public PollingComponent { float get_setup_priority() const override; - std::string unique_id() override; - protected: uint64_t uptime_{0}; }; diff --git a/esphome/components/version/version_text_sensor.cpp b/esphome/components/version/version_text_sensor.cpp index 5b2437ab62..ed093595cc 100644 --- a/esphome/components/version/version_text_sensor.cpp +++ b/esphome/components/version/version_text_sensor.cpp @@ -17,7 +17,6 @@ void VersionTextSensor::setup() { } float VersionTextSensor::get_setup_priority() const { return setup_priority::DATA; } void VersionTextSensor::set_hide_timestamp(bool hide_timestamp) { this->hide_timestamp_ = hide_timestamp; } -std::string VersionTextSensor::unique_id() { return get_mac_address() + "-version"; } void VersionTextSensor::dump_config() { LOG_TEXT_SENSOR("", "Version Text Sensor", this); } } // namespace version diff --git a/esphome/components/version/version_text_sensor.h b/esphome/components/version/version_text_sensor.h index 9355e78442..6813da7830 100644 --- a/esphome/components/version/version_text_sensor.h +++ b/esphome/components/version/version_text_sensor.h @@ -12,7 +12,6 @@ class VersionTextSensor : public text_sensor::TextSensor, public Component { void setup() override; void dump_config() override; float get_setup_priority() const override; - std::string unique_id() override; protected: bool hide_timestamp_{false}; diff --git a/esphome/components/wifi_info/wifi_info_text_sensor.h b/esphome/components/wifi_info/wifi_info_text_sensor.h index 0aa44a0894..68b5f438e4 100644 --- a/esphome/components/wifi_info/wifi_info_text_sensor.h +++ b/esphome/components/wifi_info/wifi_info_text_sensor.h @@ -28,7 +28,6 @@ class IPAddressWiFiInfo : public PollingComponent, public text_sensor::TextSenso } } float get_setup_priority() const override { return setup_priority::AFTER_WIFI; } - std::string unique_id() override { return get_mac_address() + "-wifiinfo-ip"; } void dump_config() override; void add_ip_sensors(uint8_t index, text_sensor::TextSensor *s) { this->ip_sensors_[index] = s; } @@ -51,7 +50,6 @@ class DNSAddressWifiInfo : public PollingComponent, public text_sensor::TextSens } } float get_setup_priority() const override { return setup_priority::AFTER_WIFI; } - std::string unique_id() override { return get_mac_address() + "-wifiinfo-dns"; } void dump_config() override; protected: @@ -80,7 +78,6 @@ class ScanResultsWiFiInfo : public PollingComponent, public text_sensor::TextSen } } float get_setup_priority() const override { return setup_priority::AFTER_WIFI; } - std::string unique_id() override { return get_mac_address() + "-wifiinfo-scanresults"; } void dump_config() override; protected: @@ -97,7 +94,6 @@ class SSIDWiFiInfo : public PollingComponent, public text_sensor::TextSensor { } } float get_setup_priority() const override { return setup_priority::AFTER_WIFI; } - std::string unique_id() override { return get_mac_address() + "-wifiinfo-ssid"; } void dump_config() override; protected: @@ -116,7 +112,6 @@ class BSSIDWiFiInfo : public PollingComponent, public text_sensor::TextSensor { } } float get_setup_priority() const override { return setup_priority::AFTER_WIFI; } - std::string unique_id() override { return get_mac_address() + "-wifiinfo-bssid"; } void dump_config() override; protected: @@ -126,7 +121,6 @@ class BSSIDWiFiInfo : public PollingComponent, public text_sensor::TextSensor { class MacAddressWifiInfo : public Component, public text_sensor::TextSensor { public: void setup() override { this->publish_state(get_mac_address_pretty()); } - std::string unique_id() override { return get_mac_address() + "-wifiinfo-macadr"; } void dump_config() override; }; diff --git a/esphome/components/wifi_signal/wifi_signal_sensor.h b/esphome/components/wifi_signal/wifi_signal_sensor.h index fbe03a6404..5cfd19b523 100644 --- a/esphome/components/wifi_signal/wifi_signal_sensor.h +++ b/esphome/components/wifi_signal/wifi_signal_sensor.h @@ -13,7 +13,6 @@ class WiFiSignalSensor : public sensor::Sensor, public PollingComponent { void update() override { this->publish_state(wifi::global_wifi_component->wifi_rssi()); } void dump_config() override; - std::string unique_id() override { return get_mac_address() + "-wifisignal"; } float get_setup_priority() const override { return setup_priority::AFTER_WIFI; } }; From 1ce5a994d870dff9cd96996e85f04e140348ebd3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 15 Jul 2025 19:56:40 -1000 Subject: [PATCH 06/13] 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 07/13] 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 08/13] 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 09/13] 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 10/13] 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 11/13] 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 12/13] 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 13/13] 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