From 546cdbde0dfccbcd70730049c683215a5481f42e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 7 Jan 2026 08:23:28 -1000 Subject: [PATCH] [api] Simplify string handling by removing bifurcated client/server storage (#12822) --- esphome/components/api/api_connection.cpp | 108 ++-- esphome/components/api/api_connection.h | 6 +- esphome/components/api/api_pb2.cpp | 504 +++++++++--------- esphome/components/api/api_pb2.h | 171 ++---- esphome/components/api/api_pb2_dump.cpp | 383 ++++++------- esphome/components/api/custom_api_device.h | 16 +- .../components/api/homeassistant_service.h | 4 +- esphome/components/api/proto.h | 8 +- esphome/components/api/user_services.h | 8 +- .../number/homeassistant_number.cpp | 6 +- .../switch/homeassistant_switch.cpp | 6 +- .../voice_assistant/voice_assistant.cpp | 4 +- script/api_protobuf/api_protobuf.py | 36 +- 13 files changed, 577 insertions(+), 683 deletions(-) diff --git a/esphome/components/api/api_connection.cpp b/esphome/components/api/api_connection.cpp index 30f7b5710c..649ed31283 100644 --- a/esphome/components/api/api_connection.cpp +++ b/esphome/components/api/api_connection.cpp @@ -376,7 +376,7 @@ uint16_t APIConnection::try_send_binary_sensor_info(EntityBase *entity, APIConne bool is_single) { auto *binary_sensor = static_cast(entity); ListEntitiesBinarySensorResponse msg; - msg.set_device_class(binary_sensor->get_device_class_ref()); + msg.device_class = binary_sensor->get_device_class_ref(); msg.is_status_binary_sensor = binary_sensor->is_status_binary_sensor(); return fill_and_encode_entity_info(binary_sensor, msg, ListEntitiesBinarySensorResponse::MESSAGE_TYPE, conn, remaining_size, is_single); @@ -408,7 +408,7 @@ uint16_t APIConnection::try_send_cover_info(EntityBase *entity, APIConnection *c msg.supports_position = traits.get_supports_position(); msg.supports_tilt = traits.get_supports_tilt(); msg.supports_stop = traits.get_supports_stop(); - msg.set_device_class(cover->get_device_class_ref()); + msg.device_class = cover->get_device_class_ref(); return fill_and_encode_entity_info(cover, msg, ListEntitiesCoverResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -443,7 +443,7 @@ uint16_t APIConnection::try_send_fan_state(EntityBase *entity, APIConnection *co if (traits.supports_direction()) msg.direction = static_cast(fan->direction); if (traits.supports_preset_modes() && fan->has_preset_mode()) - msg.set_preset_mode(StringRef(fan->get_preset_mode())); + msg.preset_mode = StringRef(fan->get_preset_mode()); return fill_and_encode_entity_state(fan, msg, FanStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } uint16_t APIConnection::try_send_fan_info(EntityBase *entity, APIConnection *conn, uint32_t remaining_size, @@ -499,7 +499,7 @@ uint16_t APIConnection::try_send_light_state(EntityBase *entity, APIConnection * resp.cold_white = values.get_cold_white(); resp.warm_white = values.get_warm_white(); if (light->supports_effects()) { - resp.set_effect(light->get_effect_name_ref()); + resp.effect = light->get_effect_name_ref(); } return fill_and_encode_entity_state(light, resp, LightStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -581,10 +581,10 @@ uint16_t APIConnection::try_send_sensor_info(EntityBase *entity, APIConnection * bool is_single) { auto *sensor = static_cast(entity); ListEntitiesSensorResponse msg; - msg.set_unit_of_measurement(sensor->get_unit_of_measurement_ref()); + msg.unit_of_measurement = sensor->get_unit_of_measurement_ref(); msg.accuracy_decimals = sensor->get_accuracy_decimals(); msg.force_update = sensor->get_force_update(); - msg.set_device_class(sensor->get_device_class_ref()); + msg.device_class = sensor->get_device_class_ref(); msg.state_class = static_cast(sensor->get_state_class()); return fill_and_encode_entity_info(sensor, msg, ListEntitiesSensorResponse::MESSAGE_TYPE, conn, remaining_size, is_single); @@ -611,7 +611,7 @@ uint16_t APIConnection::try_send_switch_info(EntityBase *entity, APIConnection * auto *a_switch = static_cast(entity); ListEntitiesSwitchResponse msg; msg.assumed_state = a_switch->assumed_state(); - msg.set_device_class(a_switch->get_device_class_ref()); + msg.device_class = a_switch->get_device_class_ref(); return fill_and_encode_entity_info(a_switch, msg, ListEntitiesSwitchResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -636,7 +636,7 @@ uint16_t APIConnection::try_send_text_sensor_state(EntityBase *entity, APIConnec bool is_single) { auto *text_sensor = static_cast(entity); TextSensorStateResponse resp; - resp.set_state(StringRef(text_sensor->state)); + resp.state = StringRef(text_sensor->state); resp.missing_state = !text_sensor->has_state(); return fill_and_encode_entity_state(text_sensor, resp, TextSensorStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single); @@ -645,7 +645,7 @@ uint16_t APIConnection::try_send_text_sensor_info(EntityBase *entity, APIConnect bool is_single) { auto *text_sensor = static_cast(entity); ListEntitiesTextSensorResponse msg; - msg.set_device_class(text_sensor->get_device_class_ref()); + msg.device_class = text_sensor->get_device_class_ref(); return fill_and_encode_entity_info(text_sensor, msg, ListEntitiesTextSensorResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -675,13 +675,13 @@ uint16_t APIConnection::try_send_climate_state(EntityBase *entity, APIConnection if (traits.get_supports_fan_modes() && climate->fan_mode.has_value()) resp.fan_mode = static_cast(climate->fan_mode.value()); if (!traits.get_supported_custom_fan_modes().empty() && climate->has_custom_fan_mode()) { - resp.set_custom_fan_mode(StringRef(climate->get_custom_fan_mode())); + resp.custom_fan_mode = StringRef(climate->get_custom_fan_mode()); } if (traits.get_supports_presets() && climate->preset.has_value()) { resp.preset = static_cast(climate->preset.value()); } if (!traits.get_supported_custom_presets().empty() && climate->has_custom_preset()) { - resp.set_custom_preset(StringRef(climate->get_custom_preset())); + resp.custom_preset = StringRef(climate->get_custom_preset()); } if (traits.get_supports_swing_modes()) resp.swing_mode = static_cast(climate->swing_mode); @@ -766,9 +766,9 @@ uint16_t APIConnection::try_send_number_info(EntityBase *entity, APIConnection * bool is_single) { auto *number = static_cast(entity); ListEntitiesNumberResponse msg; - msg.set_unit_of_measurement(number->traits.get_unit_of_measurement_ref()); + msg.unit_of_measurement = number->traits.get_unit_of_measurement_ref(); msg.mode = static_cast(number->traits.get_mode()); - msg.set_device_class(number->traits.get_device_class_ref()); + msg.device_class = number->traits.get_device_class_ref(); msg.min_value = number->traits.get_min_value(); msg.max_value = number->traits.get_max_value(); msg.step = number->traits.get_step(); @@ -881,7 +881,7 @@ uint16_t APIConnection::try_send_text_state(EntityBase *entity, APIConnection *c bool is_single) { auto *text = static_cast(entity); TextStateResponse resp; - resp.set_state(StringRef(text->state)); + resp.state = StringRef(text->state); resp.missing_state = !text->has_state(); return fill_and_encode_entity_state(text, resp, TextStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -893,7 +893,7 @@ uint16_t APIConnection::try_send_text_info(EntityBase *entity, APIConnection *co msg.mode = static_cast(text->traits.get_mode()); msg.min_length = text->traits.get_min_length(); msg.max_length = text->traits.get_max_length(); - msg.set_pattern(text->traits.get_pattern_ref()); + msg.pattern = text->traits.get_pattern_ref(); return fill_and_encode_entity_info(text, msg, ListEntitiesTextResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -914,7 +914,7 @@ uint16_t APIConnection::try_send_select_state(EntityBase *entity, APIConnection bool is_single) { auto *select = static_cast(entity); SelectStateResponse resp; - resp.set_state(StringRef(select->current_option())); + resp.state = StringRef(select->current_option()); resp.missing_state = !select->has_state(); return fill_and_encode_entity_state(select, resp, SelectStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -939,7 +939,7 @@ uint16_t APIConnection::try_send_button_info(EntityBase *entity, APIConnection * bool is_single) { auto *button = static_cast(entity); ListEntitiesButtonResponse msg; - msg.set_device_class(button->get_device_class_ref()); + msg.device_class = button->get_device_class_ref(); return fill_and_encode_entity_info(button, msg, ListEntitiesButtonResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -1008,7 +1008,7 @@ uint16_t APIConnection::try_send_valve_info(EntityBase *entity, APIConnection *c auto *valve = static_cast(entity); ListEntitiesValveResponse msg; auto traits = valve->get_traits(); - msg.set_device_class(valve->get_device_class_ref()); + msg.device_class = valve->get_device_class_ref(); msg.assumed_state = traits.get_is_assumed_state(); msg.supports_position = traits.get_supports_position(); msg.supports_stop = traits.get_supports_stop(); @@ -1053,7 +1053,7 @@ uint16_t APIConnection::try_send_media_player_info(EntityBase *entity, APIConnec for (auto &supported_format : traits.get_supported_formats()) { msg.supported_formats.emplace_back(); auto &media_format = msg.supported_formats.back(); - media_format.set_format(StringRef(supported_format.format)); + media_format.format = StringRef(supported_format.format); media_format.sample_rate = supported_format.sample_rate; media_format.num_channels = supported_format.num_channels; media_format.purpose = static_cast(supported_format.purpose); @@ -1263,8 +1263,8 @@ bool APIConnection::send_voice_assistant_get_configuration_response(const VoiceA for (auto &wake_word : config.available_wake_words) { resp.available_wake_words.emplace_back(); auto &resp_wake_word = resp.available_wake_words.back(); - resp_wake_word.set_id(StringRef(wake_word.id)); - resp_wake_word.set_wake_word(StringRef(wake_word.wake_word)); + resp_wake_word.id = StringRef(wake_word.id); + resp_wake_word.wake_word = StringRef(wake_word.wake_word); for (const auto &lang : wake_word.trained_languages) { resp_wake_word.trained_languages.push_back(lang); } @@ -1279,8 +1279,8 @@ bool APIConnection::send_voice_assistant_get_configuration_response(const VoiceA resp.available_wake_words.emplace_back(); auto &resp_wake_word = resp.available_wake_words.back(); - resp_wake_word.set_id(StringRef(wake_word.id)); - resp_wake_word.set_wake_word(StringRef(wake_word.wake_word)); + resp_wake_word.id = StringRef(wake_word.id); + resp_wake_word.wake_word = StringRef(wake_word.wake_word); for (const auto &lang : wake_word.trained_languages) { resp_wake_word.trained_languages.push_back(lang); } @@ -1421,7 +1421,7 @@ void APIConnection::send_event(event::Event *event, const char *event_type) { uint16_t APIConnection::try_send_event_response(event::Event *event, const char *event_type, APIConnection *conn, uint32_t remaining_size, bool is_single) { EventResponse resp; - resp.set_event_type(StringRef(event_type)); + resp.event_type = StringRef(event_type); return fill_and_encode_entity_state(event, resp, EventResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -1429,7 +1429,7 @@ uint16_t APIConnection::try_send_event_info(EntityBase *entity, APIConnection *c bool is_single) { auto *event = static_cast(entity); ListEntitiesEventResponse msg; - msg.set_device_class(event->get_device_class_ref()); + msg.device_class = event->get_device_class_ref(); msg.event_types = &event->get_event_types(); return fill_and_encode_entity_info(event, msg, ListEntitiesEventResponse::MESSAGE_TYPE, conn, remaining_size, is_single); @@ -1452,11 +1452,11 @@ uint16_t APIConnection::try_send_update_state(EntityBase *entity, APIConnection resp.has_progress = true; resp.progress = update->update_info.progress; } - resp.set_current_version(StringRef(update->update_info.current_version)); - resp.set_latest_version(StringRef(update->update_info.latest_version)); - resp.set_title(StringRef(update->update_info.title)); - resp.set_release_summary(StringRef(update->update_info.summary)); - resp.set_release_url(StringRef(update->update_info.release_url)); + resp.current_version = StringRef(update->update_info.current_version); + resp.latest_version = StringRef(update->update_info.latest_version); + resp.title = StringRef(update->update_info.title); + resp.release_summary = StringRef(update->update_info.summary); + resp.release_url = StringRef(update->update_info.release_url); } return fill_and_encode_entity_state(update, resp, UpdateStateResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -1464,7 +1464,7 @@ uint16_t APIConnection::try_send_update_info(EntityBase *entity, APIConnection * bool is_single) { auto *update = static_cast(entity); ListEntitiesUpdateResponse msg; - msg.set_device_class(update->get_device_class_ref()); + msg.device_class = update->get_device_class_ref(); return fill_and_encode_entity_info(update, msg, ListEntitiesUpdateResponse::MESSAGE_TYPE, conn, remaining_size, is_single); } @@ -1531,8 +1531,8 @@ bool APIConnection::send_hello_response(const HelloRequest &msg) { resp.api_version_major = 1; resp.api_version_minor = 14; // Send only the version string - the client only logs this for debugging and doesn't use it otherwise - resp.set_server_info(ESPHOME_VERSION_REF); - resp.set_name(StringRef(App.get_name())); + resp.server_info = ESPHOME_VERSION_REF; + resp.name = StringRef(App.get_name()); // Auto-authenticate - password auth was removed in ESPHome 2026.1.0 this->complete_authentication_(); @@ -1547,24 +1547,24 @@ bool APIConnection::send_ping_response(const PingRequest &msg) { bool APIConnection::send_device_info_response(const DeviceInfoRequest &msg) { DeviceInfoResponse resp{}; - resp.set_name(StringRef(App.get_name())); - resp.set_friendly_name(StringRef(App.get_friendly_name())); + resp.name = StringRef(App.get_name()); + resp.friendly_name = StringRef(App.get_friendly_name()); #ifdef USE_AREAS - resp.set_suggested_area(StringRef(App.get_area())); + resp.suggested_area = StringRef(App.get_area()); #endif // Stack buffer for MAC address (XX:XX:XX:XX:XX:XX\0 = 18 bytes) char mac_address[18]; uint8_t mac[6]; get_mac_address_raw(mac); format_mac_addr_upper(mac, mac_address); - resp.set_mac_address(StringRef(mac_address)); + resp.mac_address = StringRef(mac_address); - resp.set_esphome_version(ESPHOME_VERSION_REF); + resp.esphome_version = ESPHOME_VERSION_REF; // Stack buffer for build time string char build_time_str[Application::BUILD_TIME_STR_SIZE]; App.get_build_time_string(build_time_str); - resp.set_compilation_time(StringRef(build_time_str)); + resp.compilation_time = StringRef(build_time_str); // Manufacturer string - define once, handle ESP8266 PROGMEM separately #if defined(USE_ESP8266) || defined(USE_ESP32) @@ -1588,10 +1588,10 @@ bool APIConnection::send_device_info_response(const DeviceInfoRequest &msg) { static const char MANUFACTURER_PROGMEM[] PROGMEM = ESPHOME_MANUFACTURER; char manufacturer_buf[sizeof(MANUFACTURER_PROGMEM)]; memcpy_P(manufacturer_buf, MANUFACTURER_PROGMEM, sizeof(MANUFACTURER_PROGMEM)); - resp.set_manufacturer(StringRef(manufacturer_buf, sizeof(MANUFACTURER_PROGMEM) - 1)); + resp.manufacturer = StringRef(manufacturer_buf, sizeof(MANUFACTURER_PROGMEM) - 1); #else static constexpr auto MANUFACTURER = StringRef::from_lit(ESPHOME_MANUFACTURER); - resp.set_manufacturer(MANUFACTURER); + resp.manufacturer = MANUFACTURER; #endif #undef ESPHOME_MANUFACTURER @@ -1599,10 +1599,10 @@ bool APIConnection::send_device_info_response(const DeviceInfoRequest &msg) { static const char MODEL_PROGMEM[] PROGMEM = ESPHOME_BOARD; char model_buf[sizeof(MODEL_PROGMEM)]; memcpy_P(model_buf, MODEL_PROGMEM, sizeof(MODEL_PROGMEM)); - resp.set_model(StringRef(model_buf, sizeof(MODEL_PROGMEM) - 1)); + resp.model = StringRef(model_buf, sizeof(MODEL_PROGMEM) - 1); #else static constexpr auto MODEL = StringRef::from_lit(ESPHOME_BOARD); - resp.set_model(MODEL); + resp.model = MODEL; #endif #ifdef USE_DEEP_SLEEP resp.has_deep_sleep = deep_sleep::global_has_deep_sleep; @@ -1615,13 +1615,13 @@ bool APIConnection::send_device_info_response(const DeviceInfoRequest &msg) { char project_version_buf[sizeof(PROJECT_VERSION_PROGMEM)]; memcpy_P(project_name_buf, PROJECT_NAME_PROGMEM, sizeof(PROJECT_NAME_PROGMEM)); memcpy_P(project_version_buf, PROJECT_VERSION_PROGMEM, sizeof(PROJECT_VERSION_PROGMEM)); - resp.set_project_name(StringRef(project_name_buf, sizeof(PROJECT_NAME_PROGMEM) - 1)); - resp.set_project_version(StringRef(project_version_buf, sizeof(PROJECT_VERSION_PROGMEM) - 1)); + resp.project_name = StringRef(project_name_buf, sizeof(PROJECT_NAME_PROGMEM) - 1); + resp.project_version = StringRef(project_version_buf, sizeof(PROJECT_VERSION_PROGMEM) - 1); #else static constexpr auto PROJECT_NAME = StringRef::from_lit(ESPHOME_PROJECT_NAME); static constexpr auto PROJECT_VERSION = StringRef::from_lit(ESPHOME_PROJECT_VERSION); - resp.set_project_name(PROJECT_NAME); - resp.set_project_version(PROJECT_VERSION); + resp.project_name = PROJECT_NAME; + resp.project_version = PROJECT_VERSION; #endif #endif #ifdef USE_WEBSERVER @@ -1632,7 +1632,7 @@ bool APIConnection::send_device_info_response(const DeviceInfoRequest &msg) { // Stack buffer for Bluetooth MAC address (XX:XX:XX:XX:XX:XX\0 = 18 bytes) char bluetooth_mac[18]; bluetooth_proxy::global_bluetooth_proxy->get_bluetooth_mac_address_pretty(bluetooth_mac); - resp.set_bluetooth_mac_address(StringRef(bluetooth_mac)); + resp.bluetooth_mac_address = StringRef(bluetooth_mac); #endif #ifdef USE_VOICE_ASSISTANT resp.voice_assistant_feature_flags = voice_assistant::global_voice_assistant->get_feature_flags(); @@ -1651,7 +1651,7 @@ bool APIConnection::send_device_info_response(const DeviceInfoRequest &msg) { break; auto &device_info = resp.devices[device_index++]; device_info.device_id = device->get_device_id(); - device_info.set_name(StringRef(device->get_name())); + device_info.name = StringRef(device->get_name()); device_info.area_id = device->get_area_id(); } #endif @@ -1662,7 +1662,7 @@ bool APIConnection::send_device_info_response(const DeviceInfoRequest &msg) { break; auto &area_info = resp.areas[area_index++]; area_info.area_id = area->get_area_id(); - area_info.set_name(StringRef(area->get_name())); + area_info.name = StringRef(area->get_name()); } #endif @@ -1741,7 +1741,7 @@ void APIConnection::send_execute_service_response(uint32_t call_id, bool success ExecuteServiceResponse resp; resp.call_id = call_id; resp.success = success; - resp.set_error_message(error_message); + resp.error_message = error_message; this->send_message(resp, ExecuteServiceResponse::MESSAGE_TYPE); } #ifdef USE_API_USER_DEFINED_ACTION_RESPONSES_JSON @@ -1750,7 +1750,7 @@ void APIConnection::send_execute_service_response(uint32_t call_id, bool success ExecuteServiceResponse resp; resp.call_id = call_id; resp.success = success; - resp.set_error_message(error_message); + resp.error_message = error_message; resp.response_data = response_data; resp.response_data_len = response_data_len; this->send_message(resp, ExecuteServiceResponse::MESSAGE_TYPE); @@ -2071,10 +2071,10 @@ void APIConnection::process_state_subscriptions_() { const auto &it = subs[this->state_subs_at_]; SubscribeHomeAssistantStateResponse resp; - resp.set_entity_id(StringRef(it.entity_id)); + resp.entity_id = StringRef(it.entity_id); // Avoid string copy by using the const char* pointer if it exists - resp.set_attribute(it.attribute != nullptr ? StringRef(it.attribute) : StringRef("")); + resp.attribute = it.attribute != nullptr ? StringRef(it.attribute) : StringRef(""); resp.once = it.once; if (this->send_message(resp, SubscribeHomeAssistantStateResponse::MESSAGE_TYPE)) { diff --git a/esphome/components/api/api_connection.h b/esphome/components/api/api_connection.h index 802681f32f..15d79a25ec 100644 --- a/esphome/components/api/api_connection.h +++ b/esphome/components/api/api_connection.h @@ -317,16 +317,16 @@ class APIConnection final : public APIServerConnection { // Buffer must remain in scope until encode_message_to_buffer is called char object_id_buf[OBJECT_ID_MAX_LEN]; if (!conn->client_supports_api_version(1, 14)) { - msg.set_object_id(entity->get_object_id_to(object_id_buf)); + msg.object_id = entity->get_object_id_to(object_id_buf); } if (entity->has_own_name()) { - msg.set_name(entity->get_name()); + msg.name = entity->get_name(); } // Set common EntityBase properties #ifdef USE_ENTITY_ICON - msg.set_icon(entity->get_icon_ref()); + msg.icon = entity->get_icon_ref(); #endif msg.disabled_by_default = entity->is_disabled_by_default(); msg.entity_category = static_cast(entity->get_entity_category()); diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index d26b309552..03a6639b5e 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -34,51 +34,51 @@ bool HelloRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) void HelloResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(1, this->api_version_major); buffer.encode_uint32(2, this->api_version_minor); - buffer.encode_string(3, this->server_info_ref_); - buffer.encode_string(4, this->name_ref_); + buffer.encode_string(3, this->server_info); + buffer.encode_string(4, this->name); } void HelloResponse::calculate_size(ProtoSize &size) const { size.add_uint32(1, this->api_version_major); size.add_uint32(1, this->api_version_minor); - size.add_length(1, this->server_info_ref_.size()); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->server_info.size()); + size.add_length(1, this->name.size()); } #ifdef USE_AREAS void AreaInfo::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(1, this->area_id); - buffer.encode_string(2, this->name_ref_); + buffer.encode_string(2, this->name); } void AreaInfo::calculate_size(ProtoSize &size) const { size.add_uint32(1, this->area_id); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); } #endif #ifdef USE_DEVICES void DeviceInfo::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(1, this->device_id); - buffer.encode_string(2, this->name_ref_); + buffer.encode_string(2, this->name); buffer.encode_uint32(3, this->area_id); } void DeviceInfo::calculate_size(ProtoSize &size) const { size.add_uint32(1, this->device_id); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); size.add_uint32(1, this->area_id); } #endif void DeviceInfoResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(2, this->name_ref_); - buffer.encode_string(3, this->mac_address_ref_); - buffer.encode_string(4, this->esphome_version_ref_); - buffer.encode_string(5, this->compilation_time_ref_); - buffer.encode_string(6, this->model_ref_); + buffer.encode_string(2, this->name); + buffer.encode_string(3, this->mac_address); + buffer.encode_string(4, this->esphome_version); + buffer.encode_string(5, this->compilation_time); + buffer.encode_string(6, this->model); #ifdef USE_DEEP_SLEEP buffer.encode_bool(7, this->has_deep_sleep); #endif #ifdef ESPHOME_PROJECT_NAME - buffer.encode_string(8, this->project_name_ref_); + buffer.encode_string(8, this->project_name); #endif #ifdef ESPHOME_PROJECT_NAME - buffer.encode_string(9, this->project_version_ref_); + buffer.encode_string(9, this->project_version); #endif #ifdef USE_WEBSERVER buffer.encode_uint32(10, this->webserver_port); @@ -86,16 +86,16 @@ void DeviceInfoResponse::encode(ProtoWriteBuffer buffer) const { #ifdef USE_BLUETOOTH_PROXY buffer.encode_uint32(15, this->bluetooth_proxy_feature_flags); #endif - buffer.encode_string(12, this->manufacturer_ref_); - buffer.encode_string(13, this->friendly_name_ref_); + buffer.encode_string(12, this->manufacturer); + buffer.encode_string(13, this->friendly_name); #ifdef USE_VOICE_ASSISTANT buffer.encode_uint32(17, this->voice_assistant_feature_flags); #endif #ifdef USE_AREAS - buffer.encode_string(16, this->suggested_area_ref_); + buffer.encode_string(16, this->suggested_area); #endif #ifdef USE_BLUETOOTH_PROXY - buffer.encode_string(18, this->bluetooth_mac_address_ref_); + buffer.encode_string(18, this->bluetooth_mac_address); #endif #ifdef USE_API_NOISE buffer.encode_bool(19, this->api_encryption_supported); @@ -121,19 +121,19 @@ void DeviceInfoResponse::encode(ProtoWriteBuffer buffer) const { #endif } void DeviceInfoResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->name_ref_.size()); - size.add_length(1, this->mac_address_ref_.size()); - size.add_length(1, this->esphome_version_ref_.size()); - size.add_length(1, this->compilation_time_ref_.size()); - size.add_length(1, this->model_ref_.size()); + size.add_length(1, this->name.size()); + size.add_length(1, this->mac_address.size()); + size.add_length(1, this->esphome_version.size()); + size.add_length(1, this->compilation_time.size()); + size.add_length(1, this->model.size()); #ifdef USE_DEEP_SLEEP size.add_bool(1, this->has_deep_sleep); #endif #ifdef ESPHOME_PROJECT_NAME - size.add_length(1, this->project_name_ref_.size()); + size.add_length(1, this->project_name.size()); #endif #ifdef ESPHOME_PROJECT_NAME - size.add_length(1, this->project_version_ref_.size()); + size.add_length(1, this->project_version.size()); #endif #ifdef USE_WEBSERVER size.add_uint32(1, this->webserver_port); @@ -141,16 +141,16 @@ void DeviceInfoResponse::calculate_size(ProtoSize &size) const { #ifdef USE_BLUETOOTH_PROXY size.add_uint32(1, this->bluetooth_proxy_feature_flags); #endif - size.add_length(1, this->manufacturer_ref_.size()); - size.add_length(1, this->friendly_name_ref_.size()); + size.add_length(1, this->manufacturer.size()); + size.add_length(1, this->friendly_name.size()); #ifdef USE_VOICE_ASSISTANT size.add_uint32(2, this->voice_assistant_feature_flags); #endif #ifdef USE_AREAS - size.add_length(2, this->suggested_area_ref_.size()); + size.add_length(2, this->suggested_area.size()); #endif #ifdef USE_BLUETOOTH_PROXY - size.add_length(2, this->bluetooth_mac_address_ref_.size()); + size.add_length(2, this->bluetooth_mac_address.size()); #endif #ifdef USE_API_NOISE size.add_bool(2, this->api_encryption_supported); @@ -177,14 +177,14 @@ void DeviceInfoResponse::calculate_size(ProtoSize &size) const { } #ifdef USE_BINARY_SENSOR void ListEntitiesBinarySensorResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); - buffer.encode_string(5, this->device_class_ref_); + buffer.encode_string(3, this->name); + buffer.encode_string(5, this->device_class); buffer.encode_bool(6, this->is_status_binary_sensor); buffer.encode_bool(7, this->disabled_by_default); #ifdef USE_ENTITY_ICON - buffer.encode_string(8, this->icon_ref_); + buffer.encode_string(8, this->icon); #endif buffer.encode_uint32(9, static_cast(this->entity_category)); #ifdef USE_DEVICES @@ -192,14 +192,14 @@ void ListEntitiesBinarySensorResponse::encode(ProtoWriteBuffer buffer) const { #endif } void ListEntitiesBinarySensorResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); - size.add_length(1, this->device_class_ref_.size()); + size.add_length(1, this->name.size()); + size.add_length(1, this->device_class.size()); size.add_bool(1, this->is_status_binary_sensor); size.add_bool(1, this->disabled_by_default); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_uint32(1, static_cast(this->entity_category)); #ifdef USE_DEVICES @@ -225,16 +225,16 @@ void BinarySensorStateResponse::calculate_size(ProtoSize &size) const { #endif #ifdef USE_COVER void ListEntitiesCoverResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); buffer.encode_bool(5, this->assumed_state); buffer.encode_bool(6, this->supports_position); buffer.encode_bool(7, this->supports_tilt); - buffer.encode_string(8, this->device_class_ref_); + buffer.encode_string(8, this->device_class); buffer.encode_bool(9, this->disabled_by_default); #ifdef USE_ENTITY_ICON - buffer.encode_string(10, this->icon_ref_); + buffer.encode_string(10, this->icon); #endif buffer.encode_uint32(11, static_cast(this->entity_category)); buffer.encode_bool(12, this->supports_stop); @@ -243,16 +243,16 @@ void ListEntitiesCoverResponse::encode(ProtoWriteBuffer buffer) const { #endif } void ListEntitiesCoverResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); size.add_bool(1, this->assumed_state); size.add_bool(1, this->supports_position); size.add_bool(1, this->supports_tilt); - size.add_length(1, this->device_class_ref_.size()); + size.add_length(1, this->device_class.size()); size.add_bool(1, this->disabled_by_default); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_uint32(1, static_cast(this->entity_category)); size.add_bool(1, this->supports_stop); @@ -318,16 +318,16 @@ bool CoverCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { #endif #ifdef USE_FAN void ListEntitiesFanResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); buffer.encode_bool(5, this->supports_oscillation); buffer.encode_bool(6, this->supports_speed); buffer.encode_bool(7, this->supports_direction); buffer.encode_int32(8, this->supported_speed_count); buffer.encode_bool(9, this->disabled_by_default); #ifdef USE_ENTITY_ICON - buffer.encode_string(10, this->icon_ref_); + buffer.encode_string(10, this->icon); #endif buffer.encode_uint32(11, static_cast(this->entity_category)); for (const char *it : *this->supported_preset_modes) { @@ -338,16 +338,16 @@ void ListEntitiesFanResponse::encode(ProtoWriteBuffer buffer) const { #endif } void ListEntitiesFanResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); size.add_bool(1, this->supports_oscillation); size.add_bool(1, this->supports_speed); size.add_bool(1, this->supports_direction); size.add_int32(1, this->supported_speed_count); size.add_bool(1, this->disabled_by_default); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_uint32(1, static_cast(this->entity_category)); if (!this->supported_preset_modes->empty()) { @@ -365,7 +365,7 @@ void FanStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(3, this->oscillating); buffer.encode_uint32(5, static_cast(this->direction)); buffer.encode_int32(6, this->speed_level); - buffer.encode_string(7, this->preset_mode_ref_); + buffer.encode_string(7, this->preset_mode); #ifdef USE_DEVICES buffer.encode_uint32(8, this->device_id); #endif @@ -376,7 +376,7 @@ void FanStateResponse::calculate_size(ProtoSize &size) const { size.add_bool(1, this->oscillating); size.add_uint32(1, static_cast(this->direction)); size.add_int32(1, this->speed_level); - size.add_length(1, this->preset_mode_ref_.size()); + size.add_length(1, this->preset_mode.size()); #ifdef USE_DEVICES size.add_uint32(1, this->device_id); #endif @@ -444,9 +444,9 @@ bool FanCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { #endif #ifdef USE_LIGHT void ListEntitiesLightResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); for (const auto &it : *this->supported_color_modes) { buffer.encode_uint32(12, static_cast(it), true); } @@ -457,7 +457,7 @@ void ListEntitiesLightResponse::encode(ProtoWriteBuffer buffer) const { } buffer.encode_bool(13, this->disabled_by_default); #ifdef USE_ENTITY_ICON - buffer.encode_string(14, this->icon_ref_); + buffer.encode_string(14, this->icon); #endif buffer.encode_uint32(15, static_cast(this->entity_category)); #ifdef USE_DEVICES @@ -465,9 +465,9 @@ void ListEntitiesLightResponse::encode(ProtoWriteBuffer buffer) const { #endif } void ListEntitiesLightResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); if (!this->supported_color_modes->empty()) { for (const auto &it : *this->supported_color_modes) { size.add_uint32_force(1, static_cast(it)); @@ -482,7 +482,7 @@ void ListEntitiesLightResponse::calculate_size(ProtoSize &size) const { } size.add_bool(1, this->disabled_by_default); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_uint32(1, static_cast(this->entity_category)); #ifdef USE_DEVICES @@ -502,7 +502,7 @@ void LightStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_float(8, this->color_temperature); buffer.encode_float(12, this->cold_white); buffer.encode_float(13, this->warm_white); - buffer.encode_string(9, this->effect_ref_); + buffer.encode_string(9, this->effect); #ifdef USE_DEVICES buffer.encode_uint32(14, this->device_id); #endif @@ -520,7 +520,7 @@ void LightStateResponse::calculate_size(ProtoSize &size) const { size.add_float(1, this->color_temperature); size.add_float(1, this->cold_white); size.add_float(1, this->warm_white); - size.add_length(1, this->effect_ref_.size()); + size.add_length(1, this->effect.size()); #ifdef USE_DEVICES size.add_uint32(1, this->device_id); #endif @@ -636,16 +636,16 @@ bool LightCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { #endif #ifdef USE_SENSOR void ListEntitiesSensorResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); #ifdef USE_ENTITY_ICON - buffer.encode_string(5, this->icon_ref_); + buffer.encode_string(5, this->icon); #endif - buffer.encode_string(6, this->unit_of_measurement_ref_); + buffer.encode_string(6, this->unit_of_measurement); buffer.encode_int32(7, this->accuracy_decimals); buffer.encode_bool(8, this->force_update); - buffer.encode_string(9, this->device_class_ref_); + buffer.encode_string(9, this->device_class); buffer.encode_uint32(10, static_cast(this->state_class)); buffer.encode_bool(12, this->disabled_by_default); buffer.encode_uint32(13, static_cast(this->entity_category)); @@ -654,16 +654,16 @@ void ListEntitiesSensorResponse::encode(ProtoWriteBuffer buffer) const { #endif } void ListEntitiesSensorResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif - size.add_length(1, this->unit_of_measurement_ref_.size()); + size.add_length(1, this->unit_of_measurement.size()); size.add_int32(1, this->accuracy_decimals); size.add_bool(1, this->force_update); - size.add_length(1, this->device_class_ref_.size()); + size.add_length(1, this->device_class.size()); size.add_uint32(1, static_cast(this->state_class)); size.add_bool(1, this->disabled_by_default); size.add_uint32(1, static_cast(this->entity_category)); @@ -690,31 +690,31 @@ void SensorStateResponse::calculate_size(ProtoSize &size) const { #endif #ifdef USE_SWITCH void ListEntitiesSwitchResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); #ifdef USE_ENTITY_ICON - buffer.encode_string(5, this->icon_ref_); + buffer.encode_string(5, this->icon); #endif buffer.encode_bool(6, this->assumed_state); buffer.encode_bool(7, this->disabled_by_default); buffer.encode_uint32(8, static_cast(this->entity_category)); - buffer.encode_string(9, this->device_class_ref_); + buffer.encode_string(9, this->device_class); #ifdef USE_DEVICES buffer.encode_uint32(10, this->device_id); #endif } void ListEntitiesSwitchResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_bool(1, this->assumed_state); size.add_bool(1, this->disabled_by_default); size.add_uint32(1, static_cast(this->entity_category)); - size.add_length(1, this->device_class_ref_.size()); + size.add_length(1, this->device_class.size()); #ifdef USE_DEVICES size.add_uint32(1, this->device_id); #endif @@ -761,36 +761,36 @@ bool SwitchCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { #endif #ifdef USE_TEXT_SENSOR void ListEntitiesTextSensorResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); #ifdef USE_ENTITY_ICON - buffer.encode_string(5, this->icon_ref_); + buffer.encode_string(5, this->icon); #endif buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); - buffer.encode_string(8, this->device_class_ref_); + buffer.encode_string(8, this->device_class); #ifdef USE_DEVICES buffer.encode_uint32(9, this->device_id); #endif } void ListEntitiesTextSensorResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_bool(1, this->disabled_by_default); size.add_uint32(1, static_cast(this->entity_category)); - size.add_length(1, this->device_class_ref_.size()); + size.add_length(1, this->device_class.size()); #ifdef USE_DEVICES size.add_uint32(1, this->device_id); #endif } void TextSensorStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); - buffer.encode_string(2, this->state_ref_); + buffer.encode_string(2, this->state); buffer.encode_bool(3, this->missing_state); #ifdef USE_DEVICES buffer.encode_uint32(4, this->device_id); @@ -798,7 +798,7 @@ void TextSensorStateResponse::encode(ProtoWriteBuffer buffer) const { } void TextSensorStateResponse::calculate_size(ProtoSize &size) const { size.add_fixed32(1, this->key); - size.add_length(1, this->state_ref_.size()); + size.add_length(1, this->state.size()); size.add_bool(1, this->missing_state); #ifdef USE_DEVICES size.add_uint32(1, this->device_id); @@ -844,15 +844,15 @@ void NoiseEncryptionSetKeyResponse::calculate_size(ProtoSize &size) const { size #endif #ifdef USE_API_HOMEASSISTANT_SERVICES void HomeassistantServiceMap::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->key_ref_); + buffer.encode_string(1, this->key); buffer.encode_string(2, this->value); } void HomeassistantServiceMap::calculate_size(ProtoSize &size) const { - size.add_length(1, this->key_ref_.size()); + size.add_length(1, this->key.size()); size.add_length(1, this->value.size()); } void HomeassistantActionRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->service_ref_); + buffer.encode_string(1, this->service); for (auto &it : this->data) { buffer.encode_message(2, it); } @@ -874,7 +874,7 @@ void HomeassistantActionRequest::encode(ProtoWriteBuffer buffer) const { #endif } void HomeassistantActionRequest::calculate_size(ProtoSize &size) const { - size.add_length(1, this->service_ref_.size()); + size.add_length(1, this->service.size()); size.add_repeated_message(1, this->data); size.add_repeated_message(1, this->data_template); size.add_repeated_message(1, this->variables); @@ -925,13 +925,13 @@ bool HomeassistantActionResponse::decode_length(uint32_t field_id, ProtoLengthDe #endif #ifdef USE_API_HOMEASSISTANT_STATES void SubscribeHomeAssistantStateResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->entity_id_ref_); - buffer.encode_string(2, this->attribute_ref_); + buffer.encode_string(1, this->entity_id); + buffer.encode_string(2, this->attribute); buffer.encode_bool(3, this->once); } void SubscribeHomeAssistantStateResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->entity_id_ref_.size()); - size.add_length(1, this->attribute_ref_.size()); + size.add_length(1, this->entity_id.size()); + size.add_length(1, this->attribute.size()); size.add_bool(1, this->once); } bool HomeAssistantStateResponse::decode_length(uint32_t field_id, ProtoLengthDelimited value) { @@ -977,15 +977,15 @@ bool GetTimeResponse::decode_32bit(uint32_t field_id, Proto32Bit value) { } #ifdef USE_API_USER_DEFINED_ACTIONS void ListEntitiesServicesArgument::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->name_ref_); + buffer.encode_string(1, this->name); buffer.encode_uint32(2, static_cast(this->type)); } void ListEntitiesServicesArgument::calculate_size(ProtoSize &size) const { - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); size.add_uint32(1, static_cast(this->type)); } void ListEntitiesServicesResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->name_ref_); + buffer.encode_string(1, this->name); buffer.encode_fixed32(2, this->key); for (auto &it : this->args) { buffer.encode_message(3, it); @@ -993,7 +993,7 @@ void ListEntitiesServicesResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(4, static_cast(this->supports_response)); } void ListEntitiesServicesResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); size.add_fixed32(1, this->key); size.add_repeated_message(1, this->args); size.add_uint32(1, static_cast(this->supports_response)); @@ -1106,7 +1106,7 @@ void ExecuteServiceRequest::decode(const uint8_t *buffer, size_t length) { void ExecuteServiceResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(1, this->call_id); buffer.encode_bool(2, this->success); - buffer.encode_string(3, this->error_message_ref_); + buffer.encode_string(3, this->error_message); #ifdef USE_API_USER_DEFINED_ACTION_RESPONSES_JSON buffer.encode_bytes(4, this->response_data, this->response_data_len); #endif @@ -1114,7 +1114,7 @@ void ExecuteServiceResponse::encode(ProtoWriteBuffer buffer) const { void ExecuteServiceResponse::calculate_size(ProtoSize &size) const { size.add_uint32(1, this->call_id); size.add_bool(1, this->success); - size.add_length(1, this->error_message_ref_.size()); + size.add_length(1, this->error_message.size()); #ifdef USE_API_USER_DEFINED_ACTION_RESPONSES_JSON size.add_length(1, this->response_data_len); #endif @@ -1122,12 +1122,12 @@ void ExecuteServiceResponse::calculate_size(ProtoSize &size) const { #endif #ifdef USE_CAMERA void ListEntitiesCameraResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); buffer.encode_bool(5, this->disabled_by_default); #ifdef USE_ENTITY_ICON - buffer.encode_string(6, this->icon_ref_); + buffer.encode_string(6, this->icon); #endif buffer.encode_uint32(7, static_cast(this->entity_category)); #ifdef USE_DEVICES @@ -1135,12 +1135,12 @@ void ListEntitiesCameraResponse::encode(ProtoWriteBuffer buffer) const { #endif } void ListEntitiesCameraResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); size.add_bool(1, this->disabled_by_default); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_uint32(1, static_cast(this->entity_category)); #ifdef USE_DEVICES @@ -1179,9 +1179,9 @@ bool CameraImageRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { #endif #ifdef USE_CLIMATE void ListEntitiesClimateResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); buffer.encode_bool(5, this->supports_current_temperature); buffer.encode_bool(6, this->supports_two_point_target_temperature); for (const auto &it : *this->supported_modes) { @@ -1208,7 +1208,7 @@ void ListEntitiesClimateResponse::encode(ProtoWriteBuffer buffer) const { } buffer.encode_bool(18, this->disabled_by_default); #ifdef USE_ENTITY_ICON - buffer.encode_string(19, this->icon_ref_); + buffer.encode_string(19, this->icon); #endif buffer.encode_uint32(20, static_cast(this->entity_category)); buffer.encode_float(21, this->visual_current_temperature_step); @@ -1222,9 +1222,9 @@ void ListEntitiesClimateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(27, this->feature_flags); } void ListEntitiesClimateResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); size.add_bool(1, this->supports_current_temperature); size.add_bool(1, this->supports_two_point_target_temperature); if (!this->supported_modes->empty()) { @@ -1263,7 +1263,7 @@ void ListEntitiesClimateResponse::calculate_size(ProtoSize &size) const { } size.add_bool(2, this->disabled_by_default); #ifdef USE_ENTITY_ICON - size.add_length(2, this->icon_ref_.size()); + size.add_length(2, this->icon.size()); #endif size.add_uint32(2, static_cast(this->entity_category)); size.add_float(2, this->visual_current_temperature_step); @@ -1286,9 +1286,9 @@ void ClimateStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(8, static_cast(this->action)); buffer.encode_uint32(9, static_cast(this->fan_mode)); buffer.encode_uint32(10, static_cast(this->swing_mode)); - buffer.encode_string(11, this->custom_fan_mode_ref_); + buffer.encode_string(11, this->custom_fan_mode); buffer.encode_uint32(12, static_cast(this->preset)); - buffer.encode_string(13, this->custom_preset_ref_); + buffer.encode_string(13, this->custom_preset); buffer.encode_float(14, this->current_humidity); buffer.encode_float(15, this->target_humidity); #ifdef USE_DEVICES @@ -1305,9 +1305,9 @@ void ClimateStateResponse::calculate_size(ProtoSize &size) const { size.add_uint32(1, static_cast(this->action)); size.add_uint32(1, static_cast(this->fan_mode)); size.add_uint32(1, static_cast(this->swing_mode)); - size.add_length(1, this->custom_fan_mode_ref_.size()); + size.add_length(1, this->custom_fan_mode.size()); size.add_uint32(1, static_cast(this->preset)); - size.add_length(1, this->custom_preset_ref_.size()); + size.add_length(1, this->custom_preset.size()); size.add_float(1, this->current_humidity); size.add_float(1, this->target_humidity); #ifdef USE_DEVICES @@ -1408,11 +1408,11 @@ bool ClimateCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { #endif #ifdef USE_WATER_HEATER void ListEntitiesWaterHeaterResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); #ifdef USE_ENTITY_ICON - buffer.encode_string(4, this->icon_ref_); + buffer.encode_string(4, this->icon); #endif buffer.encode_bool(5, this->disabled_by_default); buffer.encode_uint32(6, static_cast(this->entity_category)); @@ -1428,11 +1428,11 @@ void ListEntitiesWaterHeaterResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(12, this->supported_features); } void ListEntitiesWaterHeaterResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_bool(1, this->disabled_by_default); size.add_uint32(1, static_cast(this->entity_category)); @@ -1516,39 +1516,39 @@ bool WaterHeaterCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value #endif #ifdef USE_NUMBER void ListEntitiesNumberResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); #ifdef USE_ENTITY_ICON - buffer.encode_string(5, this->icon_ref_); + buffer.encode_string(5, this->icon); #endif buffer.encode_float(6, this->min_value); buffer.encode_float(7, this->max_value); buffer.encode_float(8, this->step); buffer.encode_bool(9, this->disabled_by_default); buffer.encode_uint32(10, static_cast(this->entity_category)); - buffer.encode_string(11, this->unit_of_measurement_ref_); + buffer.encode_string(11, this->unit_of_measurement); buffer.encode_uint32(12, static_cast(this->mode)); - buffer.encode_string(13, this->device_class_ref_); + buffer.encode_string(13, this->device_class); #ifdef USE_DEVICES buffer.encode_uint32(14, this->device_id); #endif } void ListEntitiesNumberResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_float(1, this->min_value); size.add_float(1, this->max_value); size.add_float(1, this->step); size.add_bool(1, this->disabled_by_default); size.add_uint32(1, static_cast(this->entity_category)); - size.add_length(1, this->unit_of_measurement_ref_.size()); + size.add_length(1, this->unit_of_measurement.size()); size.add_uint32(1, static_cast(this->mode)); - size.add_length(1, this->device_class_ref_.size()); + size.add_length(1, this->device_class.size()); #ifdef USE_DEVICES size.add_uint32(1, this->device_id); #endif @@ -1597,11 +1597,11 @@ bool NumberCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { #endif #ifdef USE_SELECT void ListEntitiesSelectResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); #ifdef USE_ENTITY_ICON - buffer.encode_string(5, this->icon_ref_); + buffer.encode_string(5, this->icon); #endif for (const char *it : *this->options) { buffer.encode_string(6, it, strlen(it), true); @@ -1613,11 +1613,11 @@ void ListEntitiesSelectResponse::encode(ProtoWriteBuffer buffer) const { #endif } void ListEntitiesSelectResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif if (!this->options->empty()) { for (const char *it : *this->options) { @@ -1632,7 +1632,7 @@ void ListEntitiesSelectResponse::calculate_size(ProtoSize &size) const { } void SelectStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); - buffer.encode_string(2, this->state_ref_); + buffer.encode_string(2, this->state); buffer.encode_bool(3, this->missing_state); #ifdef USE_DEVICES buffer.encode_uint32(4, this->device_id); @@ -1640,7 +1640,7 @@ void SelectStateResponse::encode(ProtoWriteBuffer buffer) const { } void SelectStateResponse::calculate_size(ProtoSize &size) const { size.add_fixed32(1, this->key); - size.add_length(1, this->state_ref_.size()); + size.add_length(1, this->state.size()); size.add_bool(1, this->missing_state); #ifdef USE_DEVICES size.add_uint32(1, this->device_id); @@ -1682,11 +1682,11 @@ bool SelectCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { #endif #ifdef USE_SIREN void ListEntitiesSirenResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); #ifdef USE_ENTITY_ICON - buffer.encode_string(5, this->icon_ref_); + buffer.encode_string(5, this->icon); #endif buffer.encode_bool(6, this->disabled_by_default); for (const char *it : *this->tones) { @@ -1700,11 +1700,11 @@ void ListEntitiesSirenResponse::encode(ProtoWriteBuffer buffer) const { #endif } void ListEntitiesSirenResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_bool(1, this->disabled_by_default); if (!this->tones->empty()) { @@ -1790,35 +1790,35 @@ bool SirenCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { #endif #ifdef USE_LOCK void ListEntitiesLockResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); #ifdef USE_ENTITY_ICON - buffer.encode_string(5, this->icon_ref_); + buffer.encode_string(5, this->icon); #endif buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); buffer.encode_bool(8, this->assumed_state); buffer.encode_bool(9, this->supports_open); buffer.encode_bool(10, this->requires_code); - buffer.encode_string(11, this->code_format_ref_); + buffer.encode_string(11, this->code_format); #ifdef USE_DEVICES buffer.encode_uint32(12, this->device_id); #endif } void ListEntitiesLockResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_bool(1, this->disabled_by_default); size.add_uint32(1, static_cast(this->entity_category)); size.add_bool(1, this->assumed_state); size.add_bool(1, this->supports_open); size.add_bool(1, this->requires_code); - size.add_length(1, this->code_format_ref_.size()); + size.add_length(1, this->code_format.size()); #ifdef USE_DEVICES size.add_uint32(1, this->device_id); #endif @@ -1879,29 +1879,29 @@ bool LockCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { #endif #ifdef USE_BUTTON void ListEntitiesButtonResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); #ifdef USE_ENTITY_ICON - buffer.encode_string(5, this->icon_ref_); + buffer.encode_string(5, this->icon); #endif buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); - buffer.encode_string(8, this->device_class_ref_); + buffer.encode_string(8, this->device_class); #ifdef USE_DEVICES buffer.encode_uint32(9, this->device_id); #endif } void ListEntitiesButtonResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_bool(1, this->disabled_by_default); size.add_uint32(1, static_cast(this->entity_category)); - size.add_length(1, this->device_class_ref_.size()); + size.add_length(1, this->device_class.size()); #ifdef USE_DEVICES size.add_uint32(1, this->device_id); #endif @@ -1931,25 +1931,25 @@ bool ButtonCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { #endif #ifdef USE_MEDIA_PLAYER void MediaPlayerSupportedFormat::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->format_ref_); + buffer.encode_string(1, this->format); buffer.encode_uint32(2, this->sample_rate); buffer.encode_uint32(3, this->num_channels); buffer.encode_uint32(4, static_cast(this->purpose)); buffer.encode_uint32(5, this->sample_bytes); } void MediaPlayerSupportedFormat::calculate_size(ProtoSize &size) const { - size.add_length(1, this->format_ref_.size()); + size.add_length(1, this->format.size()); size.add_uint32(1, this->sample_rate); size.add_uint32(1, this->num_channels); size.add_uint32(1, static_cast(this->purpose)); size.add_uint32(1, this->sample_bytes); } void ListEntitiesMediaPlayerResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); #ifdef USE_ENTITY_ICON - buffer.encode_string(5, this->icon_ref_); + buffer.encode_string(5, this->icon); #endif buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); @@ -1963,11 +1963,11 @@ void ListEntitiesMediaPlayerResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(11, this->feature_flags); } void ListEntitiesMediaPlayerResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_bool(1, this->disabled_by_default); size.add_uint32(1, static_cast(this->entity_category)); @@ -2433,17 +2433,17 @@ void VoiceAssistantAudioSettings::calculate_size(ProtoSize &size) const { } void VoiceAssistantRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(1, this->start); - buffer.encode_string(2, this->conversation_id_ref_); + buffer.encode_string(2, this->conversation_id); buffer.encode_uint32(3, this->flags); buffer.encode_message(4, this->audio_settings); - buffer.encode_string(5, this->wake_word_phrase_ref_); + buffer.encode_string(5, this->wake_word_phrase); } void VoiceAssistantRequest::calculate_size(ProtoSize &size) const { size.add_bool(1, this->start); - size.add_length(1, this->conversation_id_ref_.size()); + size.add_length(1, this->conversation_id.size()); size.add_uint32(1, this->flags); size.add_message_object(1, this->audio_settings); - size.add_length(1, this->wake_word_phrase_ref_.size()); + size.add_length(1, this->wake_word_phrase.size()); } bool VoiceAssistantResponse::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { @@ -2590,15 +2590,15 @@ bool VoiceAssistantAnnounceRequest::decode_length(uint32_t field_id, ProtoLength void VoiceAssistantAnnounceFinished::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(1, this->success); } void VoiceAssistantAnnounceFinished::calculate_size(ProtoSize &size) const { size.add_bool(1, this->success); } void VoiceAssistantWakeWord::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->id_ref_); - buffer.encode_string(2, this->wake_word_ref_); + buffer.encode_string(1, this->id); + buffer.encode_string(2, this->wake_word); for (auto &it : this->trained_languages) { buffer.encode_string(3, it, true); } } void VoiceAssistantWakeWord::calculate_size(ProtoSize &size) const { - size.add_length(1, this->id_ref_.size()); - size.add_length(1, this->wake_word_ref_.size()); + size.add_length(1, this->id.size()); + size.add_length(1, this->wake_word.size()); if (!this->trained_languages.empty()) { for (const auto &it : this->trained_languages) { size.add_length_force(1, it.size()); @@ -2687,11 +2687,11 @@ bool VoiceAssistantSetConfiguration::decode_length(uint32_t field_id, ProtoLengt #endif #ifdef USE_ALARM_CONTROL_PANEL void ListEntitiesAlarmControlPanelResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); #ifdef USE_ENTITY_ICON - buffer.encode_string(5, this->icon_ref_); + buffer.encode_string(5, this->icon); #endif buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); @@ -2703,11 +2703,11 @@ void ListEntitiesAlarmControlPanelResponse::encode(ProtoWriteBuffer buffer) cons #endif } void ListEntitiesAlarmControlPanelResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_bool(1, this->disabled_by_default); size.add_uint32(1, static_cast(this->entity_category)); @@ -2771,34 +2771,34 @@ bool AlarmControlPanelCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit #endif #ifdef USE_TEXT void ListEntitiesTextResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); #ifdef USE_ENTITY_ICON - buffer.encode_string(5, this->icon_ref_); + buffer.encode_string(5, this->icon); #endif buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); buffer.encode_uint32(8, this->min_length); buffer.encode_uint32(9, this->max_length); - buffer.encode_string(10, this->pattern_ref_); + buffer.encode_string(10, this->pattern); buffer.encode_uint32(11, static_cast(this->mode)); #ifdef USE_DEVICES buffer.encode_uint32(12, this->device_id); #endif } void ListEntitiesTextResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_bool(1, this->disabled_by_default); size.add_uint32(1, static_cast(this->entity_category)); size.add_uint32(1, this->min_length); size.add_uint32(1, this->max_length); - size.add_length(1, this->pattern_ref_.size()); + size.add_length(1, this->pattern.size()); size.add_uint32(1, static_cast(this->mode)); #ifdef USE_DEVICES size.add_uint32(1, this->device_id); @@ -2806,7 +2806,7 @@ void ListEntitiesTextResponse::calculate_size(ProtoSize &size) const { } void TextStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); - buffer.encode_string(2, this->state_ref_); + buffer.encode_string(2, this->state); buffer.encode_bool(3, this->missing_state); #ifdef USE_DEVICES buffer.encode_uint32(4, this->device_id); @@ -2814,7 +2814,7 @@ void TextStateResponse::encode(ProtoWriteBuffer buffer) const { } void TextStateResponse::calculate_size(ProtoSize &size) const { size.add_fixed32(1, this->key); - size.add_length(1, this->state_ref_.size()); + size.add_length(1, this->state.size()); size.add_bool(1, this->missing_state); #ifdef USE_DEVICES size.add_uint32(1, this->device_id); @@ -2856,11 +2856,11 @@ bool TextCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { #endif #ifdef USE_DATETIME_DATE void ListEntitiesDateResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); #ifdef USE_ENTITY_ICON - buffer.encode_string(5, this->icon_ref_); + buffer.encode_string(5, this->icon); #endif buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); @@ -2869,11 +2869,11 @@ void ListEntitiesDateResponse::encode(ProtoWriteBuffer buffer) const { #endif } void ListEntitiesDateResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_bool(1, this->disabled_by_default); size.add_uint32(1, static_cast(this->entity_category)); @@ -2935,11 +2935,11 @@ bool DateCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { #endif #ifdef USE_DATETIME_TIME void ListEntitiesTimeResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); #ifdef USE_ENTITY_ICON - buffer.encode_string(5, this->icon_ref_); + buffer.encode_string(5, this->icon); #endif buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); @@ -2948,11 +2948,11 @@ void ListEntitiesTimeResponse::encode(ProtoWriteBuffer buffer) const { #endif } void ListEntitiesTimeResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_bool(1, this->disabled_by_default); size.add_uint32(1, static_cast(this->entity_category)); @@ -3014,15 +3014,15 @@ bool TimeCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { #endif #ifdef USE_EVENT void ListEntitiesEventResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); #ifdef USE_ENTITY_ICON - buffer.encode_string(5, this->icon_ref_); + buffer.encode_string(5, this->icon); #endif buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); - buffer.encode_string(8, this->device_class_ref_); + buffer.encode_string(8, this->device_class); for (const char *it : *this->event_types) { buffer.encode_string(9, it, strlen(it), true); } @@ -3031,15 +3031,15 @@ void ListEntitiesEventResponse::encode(ProtoWriteBuffer buffer) const { #endif } void ListEntitiesEventResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_bool(1, this->disabled_by_default); size.add_uint32(1, static_cast(this->entity_category)); - size.add_length(1, this->device_class_ref_.size()); + size.add_length(1, this->device_class.size()); if (!this->event_types->empty()) { for (const char *it : *this->event_types) { size.add_length_force(1, strlen(it)); @@ -3051,14 +3051,14 @@ void ListEntitiesEventResponse::calculate_size(ProtoSize &size) const { } void EventResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); - buffer.encode_string(2, this->event_type_ref_); + buffer.encode_string(2, this->event_type); #ifdef USE_DEVICES buffer.encode_uint32(3, this->device_id); #endif } void EventResponse::calculate_size(ProtoSize &size) const { size.add_fixed32(1, this->key); - size.add_length(1, this->event_type_ref_.size()); + size.add_length(1, this->event_type.size()); #ifdef USE_DEVICES size.add_uint32(1, this->device_id); #endif @@ -3066,15 +3066,15 @@ void EventResponse::calculate_size(ProtoSize &size) const { #endif #ifdef USE_VALVE void ListEntitiesValveResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); #ifdef USE_ENTITY_ICON - buffer.encode_string(5, this->icon_ref_); + buffer.encode_string(5, this->icon); #endif buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); - buffer.encode_string(8, this->device_class_ref_); + buffer.encode_string(8, this->device_class); buffer.encode_bool(9, this->assumed_state); buffer.encode_bool(10, this->supports_position); buffer.encode_bool(11, this->supports_stop); @@ -3083,15 +3083,15 @@ void ListEntitiesValveResponse::encode(ProtoWriteBuffer buffer) const { #endif } void ListEntitiesValveResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_bool(1, this->disabled_by_default); size.add_uint32(1, static_cast(this->entity_category)); - size.add_length(1, this->device_class_ref_.size()); + size.add_length(1, this->device_class.size()); size.add_bool(1, this->assumed_state); size.add_bool(1, this->supports_position); size.add_bool(1, this->supports_stop); @@ -3149,11 +3149,11 @@ bool ValveCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { #endif #ifdef USE_DATETIME_DATETIME void ListEntitiesDateTimeResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); #ifdef USE_ENTITY_ICON - buffer.encode_string(5, this->icon_ref_); + buffer.encode_string(5, this->icon); #endif buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); @@ -3162,11 +3162,11 @@ void ListEntitiesDateTimeResponse::encode(ProtoWriteBuffer buffer) const { #endif } void ListEntitiesDateTimeResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_bool(1, this->disabled_by_default); size.add_uint32(1, static_cast(this->entity_category)); @@ -3218,29 +3218,29 @@ bool DateTimeCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { #endif #ifdef USE_UPDATE void ListEntitiesUpdateResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->object_id_ref_); + buffer.encode_string(1, this->object_id); buffer.encode_fixed32(2, this->key); - buffer.encode_string(3, this->name_ref_); + buffer.encode_string(3, this->name); #ifdef USE_ENTITY_ICON - buffer.encode_string(5, this->icon_ref_); + buffer.encode_string(5, this->icon); #endif buffer.encode_bool(6, this->disabled_by_default); buffer.encode_uint32(7, static_cast(this->entity_category)); - buffer.encode_string(8, this->device_class_ref_); + buffer.encode_string(8, this->device_class); #ifdef USE_DEVICES buffer.encode_uint32(9, this->device_id); #endif } void ListEntitiesUpdateResponse::calculate_size(ProtoSize &size) const { - size.add_length(1, this->object_id_ref_.size()); + size.add_length(1, this->object_id.size()); size.add_fixed32(1, this->key); - size.add_length(1, this->name_ref_.size()); + size.add_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size.add_length(1, this->icon_ref_.size()); + size.add_length(1, this->icon.size()); #endif size.add_bool(1, this->disabled_by_default); size.add_uint32(1, static_cast(this->entity_category)); - size.add_length(1, this->device_class_ref_.size()); + size.add_length(1, this->device_class.size()); #ifdef USE_DEVICES size.add_uint32(1, this->device_id); #endif @@ -3251,11 +3251,11 @@ void UpdateStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(3, this->in_progress); buffer.encode_bool(4, this->has_progress); buffer.encode_float(5, this->progress); - buffer.encode_string(6, this->current_version_ref_); - buffer.encode_string(7, this->latest_version_ref_); - buffer.encode_string(8, this->title_ref_); - buffer.encode_string(9, this->release_summary_ref_); - buffer.encode_string(10, this->release_url_ref_); + buffer.encode_string(6, this->current_version); + buffer.encode_string(7, this->latest_version); + buffer.encode_string(8, this->title); + buffer.encode_string(9, this->release_summary); + buffer.encode_string(10, this->release_url); #ifdef USE_DEVICES buffer.encode_uint32(11, this->device_id); #endif @@ -3266,11 +3266,11 @@ void UpdateStateResponse::calculate_size(ProtoSize &size) const { size.add_bool(1, this->in_progress); size.add_bool(1, this->has_progress); size.add_float(1, this->progress); - size.add_length(1, this->current_version_ref_.size()); - size.add_length(1, this->latest_version_ref_.size()); - size.add_length(1, this->title_ref_.size()); - size.add_length(1, this->release_summary_ref_.size()); - size.add_length(1, this->release_url_ref_.size()); + size.add_length(1, this->current_version.size()); + size.add_length(1, this->latest_version.size()); + size.add_length(1, this->title.size()); + size.add_length(1, this->release_summary.size()); + size.add_length(1, this->release_url.size()); #ifdef USE_DEVICES size.add_uint32(1, this->device_id); #endif diff --git a/esphome/components/api/api_pb2.h b/esphome/components/api/api_pb2.h index 0605051e29..01fe44d7c7 100644 --- a/esphome/components/api/api_pb2.h +++ b/esphome/components/api/api_pb2.h @@ -315,15 +315,12 @@ enum ZWaveProxyRequestType : uint32_t { class InfoResponseProtoMessage : public ProtoMessage { public: ~InfoResponseProtoMessage() override = default; - StringRef object_id_ref_{}; - void set_object_id(const StringRef &ref) { this->object_id_ref_ = ref; } + StringRef object_id{}; uint32_t key{0}; - StringRef name_ref_{}; - void set_name(const StringRef &ref) { this->name_ref_ = ref; } + StringRef name{}; bool disabled_by_default{false}; #ifdef USE_ENTITY_ICON - StringRef icon_ref_{}; - void set_icon(const StringRef &ref) { this->icon_ref_ = ref; } + StringRef icon{}; #endif enums::EntityCategory entity_category{}; #ifdef USE_DEVICES @@ -381,10 +378,8 @@ class HelloResponse final : public ProtoMessage { #endif uint32_t api_version_major{0}; uint32_t api_version_minor{0}; - StringRef server_info_ref_{}; - void set_server_info(const StringRef &ref) { this->server_info_ref_ = ref; } - StringRef name_ref_{}; - void set_name(const StringRef &ref) { this->name_ref_ = ref; } + StringRef server_info{}; + StringRef name{}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP @@ -462,8 +457,7 @@ class DeviceInfoRequest final : public ProtoMessage { class AreaInfo final : public ProtoMessage { public: uint32_t area_id{0}; - StringRef name_ref_{}; - void set_name(const StringRef &ref) { this->name_ref_ = ref; } + StringRef name{}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP @@ -477,8 +471,7 @@ class AreaInfo final : public ProtoMessage { class DeviceInfo final : public ProtoMessage { public: uint32_t device_id{0}; - StringRef name_ref_{}; - void set_name(const StringRef &ref) { this->name_ref_ = ref; } + StringRef name{}; uint32_t area_id{0}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; @@ -496,26 +489,19 @@ class DeviceInfoResponse final : public ProtoMessage { #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "device_info_response"; } #endif - StringRef name_ref_{}; - void set_name(const StringRef &ref) { this->name_ref_ = ref; } - StringRef mac_address_ref_{}; - void set_mac_address(const StringRef &ref) { this->mac_address_ref_ = ref; } - StringRef esphome_version_ref_{}; - void set_esphome_version(const StringRef &ref) { this->esphome_version_ref_ = ref; } - StringRef compilation_time_ref_{}; - void set_compilation_time(const StringRef &ref) { this->compilation_time_ref_ = ref; } - StringRef model_ref_{}; - void set_model(const StringRef &ref) { this->model_ref_ = ref; } + StringRef name{}; + StringRef mac_address{}; + StringRef esphome_version{}; + StringRef compilation_time{}; + StringRef model{}; #ifdef USE_DEEP_SLEEP bool has_deep_sleep{false}; #endif #ifdef ESPHOME_PROJECT_NAME - StringRef project_name_ref_{}; - void set_project_name(const StringRef &ref) { this->project_name_ref_ = ref; } + StringRef project_name{}; #endif #ifdef ESPHOME_PROJECT_NAME - StringRef project_version_ref_{}; - void set_project_version(const StringRef &ref) { this->project_version_ref_ = ref; } + StringRef project_version{}; #endif #ifdef USE_WEBSERVER uint32_t webserver_port{0}; @@ -523,20 +509,16 @@ class DeviceInfoResponse final : public ProtoMessage { #ifdef USE_BLUETOOTH_PROXY uint32_t bluetooth_proxy_feature_flags{0}; #endif - StringRef manufacturer_ref_{}; - void set_manufacturer(const StringRef &ref) { this->manufacturer_ref_ = ref; } - StringRef friendly_name_ref_{}; - void set_friendly_name(const StringRef &ref) { this->friendly_name_ref_ = ref; } + StringRef manufacturer{}; + StringRef friendly_name{}; #ifdef USE_VOICE_ASSISTANT uint32_t voice_assistant_feature_flags{0}; #endif #ifdef USE_AREAS - StringRef suggested_area_ref_{}; - void set_suggested_area(const StringRef &ref) { this->suggested_area_ref_ = ref; } + StringRef suggested_area{}; #endif #ifdef USE_BLUETOOTH_PROXY - StringRef bluetooth_mac_address_ref_{}; - void set_bluetooth_mac_address(const StringRef &ref) { this->bluetooth_mac_address_ref_ = ref; } + StringRef bluetooth_mac_address{}; #endif #ifdef USE_API_NOISE bool api_encryption_supported{false}; @@ -611,8 +593,7 @@ class ListEntitiesBinarySensorResponse final : public InfoResponseProtoMessage { #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_binary_sensor_response"; } #endif - StringRef device_class_ref_{}; - void set_device_class(const StringRef &ref) { this->device_class_ref_ = ref; } + StringRef device_class{}; bool is_status_binary_sensor{false}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; @@ -651,8 +632,7 @@ class ListEntitiesCoverResponse final : public InfoResponseProtoMessage { bool assumed_state{false}; bool supports_position{false}; bool supports_tilt{false}; - StringRef device_class_ref_{}; - void set_device_class(const StringRef &ref) { this->device_class_ref_ = ref; } + StringRef device_class{}; bool supports_stop{false}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; @@ -733,8 +713,7 @@ class FanStateResponse final : public StateResponseProtoMessage { bool oscillating{false}; enums::FanDirection direction{}; int32_t speed_level{0}; - StringRef preset_mode_ref_{}; - void set_preset_mode(const StringRef &ref) { this->preset_mode_ref_ = ref; } + StringRef preset_mode{}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP @@ -808,8 +787,7 @@ class LightStateResponse final : public StateResponseProtoMessage { float color_temperature{0.0f}; float cold_white{0.0f}; float warm_white{0.0f}; - StringRef effect_ref_{}; - void set_effect(const StringRef &ref) { this->effect_ref_ = ref; } + StringRef effect{}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP @@ -869,12 +847,10 @@ class ListEntitiesSensorResponse final : public InfoResponseProtoMessage { #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_sensor_response"; } #endif - StringRef unit_of_measurement_ref_{}; - void set_unit_of_measurement(const StringRef &ref) { this->unit_of_measurement_ref_ = ref; } + StringRef unit_of_measurement{}; int32_t accuracy_decimals{0}; bool force_update{false}; - StringRef device_class_ref_{}; - void set_device_class(const StringRef &ref) { this->device_class_ref_ = ref; } + StringRef device_class{}; enums::SensorStateClass state_class{}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; @@ -911,8 +887,7 @@ class ListEntitiesSwitchResponse final : public InfoResponseProtoMessage { const char *message_name() const override { return "list_entities_switch_response"; } #endif bool assumed_state{false}; - StringRef device_class_ref_{}; - void set_device_class(const StringRef &ref) { this->device_class_ref_ = ref; } + StringRef device_class{}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP @@ -962,8 +937,7 @@ class ListEntitiesTextSensorResponse final : public InfoResponseProtoMessage { #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_text_sensor_response"; } #endif - StringRef device_class_ref_{}; - void set_device_class(const StringRef &ref) { this->device_class_ref_ = ref; } + StringRef device_class{}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP @@ -979,8 +953,7 @@ class TextSensorStateResponse final : public StateResponseProtoMessage { #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "text_sensor_state_response"; } #endif - StringRef state_ref_{}; - void set_state(const StringRef &ref) { this->state_ref_ = ref; } + StringRef state{}; bool missing_state{false}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; @@ -1079,8 +1052,7 @@ class SubscribeHomeassistantServicesRequest final : public ProtoMessage { }; class HomeassistantServiceMap final : public ProtoMessage { public: - StringRef key_ref_{}; - void set_key(const StringRef &ref) { this->key_ref_ = ref; } + StringRef key{}; std::string value{}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; @@ -1097,8 +1069,7 @@ class HomeassistantActionRequest final : public ProtoMessage { #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "homeassistant_action_request"; } #endif - StringRef service_ref_{}; - void set_service(const StringRef &ref) { this->service_ref_ = ref; } + StringRef service{}; FixedVector data{}; FixedVector data_template{}; FixedVector variables{}; @@ -1166,10 +1137,8 @@ class SubscribeHomeAssistantStateResponse final : public ProtoMessage { #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "subscribe_home_assistant_state_response"; } #endif - StringRef entity_id_ref_{}; - void set_entity_id(const StringRef &ref) { this->entity_id_ref_ = ref; } - StringRef attribute_ref_{}; - void set_attribute(const StringRef &ref) { this->attribute_ref_ = ref; } + StringRef entity_id{}; + StringRef attribute{}; bool once{false}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; @@ -1230,8 +1199,7 @@ class GetTimeResponse final : public ProtoDecodableMessage { #ifdef USE_API_USER_DEFINED_ACTIONS class ListEntitiesServicesArgument final : public ProtoMessage { public: - StringRef name_ref_{}; - void set_name(const StringRef &ref) { this->name_ref_ = ref; } + StringRef name{}; enums::ServiceArgType type{}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; @@ -1248,8 +1216,7 @@ class ListEntitiesServicesResponse final : public ProtoMessage { #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_services_response"; } #endif - StringRef name_ref_{}; - void set_name(const StringRef &ref) { this->name_ref_ = ref; } + StringRef name{}; uint32_t key{0}; FixedVector args{}; enums::SupportsResponseType supports_response{}; @@ -1318,8 +1285,7 @@ class ExecuteServiceResponse final : public ProtoMessage { #endif uint32_t call_id{0}; bool success{false}; - StringRef error_message_ref_{}; - void set_error_message(const StringRef &ref) { this->error_message_ref_ = ref; } + StringRef error_message{}; #ifdef USE_API_USER_DEFINED_ACTION_RESPONSES_JSON const uint8_t *response_data{nullptr}; uint16_t response_data_len{0}; @@ -1437,11 +1403,9 @@ class ClimateStateResponse final : public StateResponseProtoMessage { enums::ClimateAction action{}; enums::ClimateFanMode fan_mode{}; enums::ClimateSwingMode swing_mode{}; - StringRef custom_fan_mode_ref_{}; - void set_custom_fan_mode(const StringRef &ref) { this->custom_fan_mode_ref_ = ref; } + StringRef custom_fan_mode{}; enums::ClimatePreset preset{}; - StringRef custom_preset_ref_{}; - void set_custom_preset(const StringRef &ref) { this->custom_preset_ref_ = ref; } + StringRef custom_preset{}; float current_humidity{0.0f}; float target_humidity{0.0f}; void encode(ProtoWriteBuffer buffer) const override; @@ -1564,11 +1528,9 @@ class ListEntitiesNumberResponse final : public InfoResponseProtoMessage { float min_value{0.0f}; float max_value{0.0f}; float step{0.0f}; - StringRef unit_of_measurement_ref_{}; - void set_unit_of_measurement(const StringRef &ref) { this->unit_of_measurement_ref_ = ref; } + StringRef unit_of_measurement{}; enums::NumberMode mode{}; - StringRef device_class_ref_{}; - void set_device_class(const StringRef &ref) { this->device_class_ref_ = ref; } + StringRef device_class{}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP @@ -1635,8 +1597,7 @@ class SelectStateResponse final : public StateResponseProtoMessage { #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "select_state_response"; } #endif - StringRef state_ref_{}; - void set_state(const StringRef &ref) { this->state_ref_ = ref; } + StringRef state{}; bool missing_state{false}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; @@ -1735,8 +1696,7 @@ class ListEntitiesLockResponse final : public InfoResponseProtoMessage { bool assumed_state{false}; bool supports_open{false}; bool requires_code{false}; - StringRef code_format_ref_{}; - void set_code_format(const StringRef &ref) { this->code_format_ref_ = ref; } + StringRef code_format{}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP @@ -1789,8 +1749,7 @@ class ListEntitiesButtonResponse final : public InfoResponseProtoMessage { #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_button_response"; } #endif - StringRef device_class_ref_{}; - void set_device_class(const StringRef &ref) { this->device_class_ref_ = ref; } + StringRef device_class{}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP @@ -1818,8 +1777,7 @@ class ButtonCommandRequest final : public CommandProtoMessage { #ifdef USE_MEDIA_PLAYER class MediaPlayerSupportedFormat final : public ProtoMessage { public: - StringRef format_ref_{}; - void set_format(const StringRef &ref) { this->format_ref_ = ref; } + StringRef format{}; uint32_t sample_rate{0}; uint32_t num_channels{0}; enums::MediaPlayerFormatPurpose purpose{}; @@ -2424,12 +2382,10 @@ class VoiceAssistantRequest final : public ProtoMessage { const char *message_name() const override { return "voice_assistant_request"; } #endif bool start{false}; - StringRef conversation_id_ref_{}; - void set_conversation_id(const StringRef &ref) { this->conversation_id_ref_ = ref; } + StringRef conversation_id{}; uint32_t flags{0}; VoiceAssistantAudioSettings audio_settings{}; - StringRef wake_word_phrase_ref_{}; - void set_wake_word_phrase(const StringRef &ref) { this->wake_word_phrase_ref_ = ref; } + StringRef wake_word_phrase{}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP @@ -2560,10 +2516,8 @@ class VoiceAssistantAnnounceFinished final : public ProtoMessage { }; class VoiceAssistantWakeWord final : public ProtoMessage { public: - StringRef id_ref_{}; - void set_id(const StringRef &ref) { this->id_ref_ = ref; } - StringRef wake_word_ref_{}; - void set_wake_word(const StringRef &ref) { this->wake_word_ref_ = ref; } + StringRef id{}; + StringRef wake_word{}; std::vector trained_languages{}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; @@ -2703,8 +2657,7 @@ class ListEntitiesTextResponse final : public InfoResponseProtoMessage { #endif uint32_t min_length{0}; uint32_t max_length{0}; - StringRef pattern_ref_{}; - void set_pattern(const StringRef &ref) { this->pattern_ref_ = ref; } + StringRef pattern{}; enums::TextMode mode{}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; @@ -2721,8 +2674,7 @@ class TextStateResponse final : public StateResponseProtoMessage { #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "text_state_response"; } #endif - StringRef state_ref_{}; - void set_state(const StringRef &ref) { this->state_ref_ = ref; } + StringRef state{}; bool missing_state{false}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; @@ -2866,8 +2818,7 @@ class ListEntitiesEventResponse final : public InfoResponseProtoMessage { #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_event_response"; } #endif - StringRef device_class_ref_{}; - void set_device_class(const StringRef &ref) { this->device_class_ref_ = ref; } + StringRef device_class{}; const FixedVector *event_types{}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; @@ -2884,8 +2835,7 @@ class EventResponse final : public StateResponseProtoMessage { #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "event_response"; } #endif - StringRef event_type_ref_{}; - void set_event_type(const StringRef &ref) { this->event_type_ref_ = ref; } + StringRef event_type{}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP @@ -2903,8 +2853,7 @@ class ListEntitiesValveResponse final : public InfoResponseProtoMessage { #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_valve_response"; } #endif - StringRef device_class_ref_{}; - void set_device_class(const StringRef &ref) { this->device_class_ref_ = ref; } + StringRef device_class{}; bool assumed_state{false}; bool supports_position{false}; bool supports_stop{false}; @@ -3010,8 +2959,7 @@ class ListEntitiesUpdateResponse final : public InfoResponseProtoMessage { #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "list_entities_update_response"; } #endif - StringRef device_class_ref_{}; - void set_device_class(const StringRef &ref) { this->device_class_ref_ = ref; } + StringRef device_class{}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP @@ -3031,16 +2979,11 @@ class UpdateStateResponse final : public StateResponseProtoMessage { bool in_progress{false}; bool has_progress{false}; float progress{0.0f}; - StringRef current_version_ref_{}; - void set_current_version(const StringRef &ref) { this->current_version_ref_ = ref; } - StringRef latest_version_ref_{}; - void set_latest_version(const StringRef &ref) { this->latest_version_ref_ = ref; } - StringRef title_ref_{}; - void set_title(const StringRef &ref) { this->title_ref_ = ref; } - StringRef release_summary_ref_{}; - void set_release_summary(const StringRef &ref) { this->release_summary_ref_ = ref; } - StringRef release_url_ref_{}; - void set_release_url(const StringRef &ref) { this->release_url_ref_ = ref; } + StringRef current_version{}; + StringRef latest_version{}; + StringRef title{}; + StringRef release_summary{}; + StringRef release_url{}; void encode(ProtoWriteBuffer buffer) const override; void calculate_size(ProtoSize &size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP diff --git a/esphome/components/api/api_pb2_dump.cpp b/esphome/components/api/api_pb2_dump.cpp index ac5f04f3fb..160a9a93c9 100644 --- a/esphome/components/api/api_pb2_dump.cpp +++ b/esphome/components/api/api_pb2_dump.cpp @@ -735,9 +735,7 @@ template<> const char *proto_enum_to_string(enums: void HelloRequest::dump_to(std::string &out) const { MessageDumpHelper helper(out, "HelloRequest"); - out.append(" client_info: "); - out.append("'").append(this->client_info.c_str(), this->client_info.size()).append("'"); - out.append("\n"); + dump_field(out, "client_info", this->client_info); dump_field(out, "api_version_major", this->api_version_major); dump_field(out, "api_version_minor", this->api_version_minor); } @@ -745,8 +743,8 @@ void HelloResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "HelloResponse"); dump_field(out, "api_version_major", this->api_version_major); dump_field(out, "api_version_minor", this->api_version_minor); - dump_field(out, "server_info", this->server_info_ref_); - dump_field(out, "name", this->name_ref_); + dump_field(out, "server_info", this->server_info); + dump_field(out, "name", this->name); } void DisconnectRequest::dump_to(std::string &out) const { out.append("DisconnectRequest {}"); } void DisconnectResponse::dump_to(std::string &out) const { out.append("DisconnectResponse {}"); } @@ -757,32 +755,32 @@ void DeviceInfoRequest::dump_to(std::string &out) const { out.append("DeviceInfo void AreaInfo::dump_to(std::string &out) const { MessageDumpHelper helper(out, "AreaInfo"); dump_field(out, "area_id", this->area_id); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); } #endif #ifdef USE_DEVICES void DeviceInfo::dump_to(std::string &out) const { MessageDumpHelper helper(out, "DeviceInfo"); dump_field(out, "device_id", this->device_id); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); dump_field(out, "area_id", this->area_id); } #endif void DeviceInfoResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "DeviceInfoResponse"); - dump_field(out, "name", this->name_ref_); - dump_field(out, "mac_address", this->mac_address_ref_); - dump_field(out, "esphome_version", this->esphome_version_ref_); - dump_field(out, "compilation_time", this->compilation_time_ref_); - dump_field(out, "model", this->model_ref_); + dump_field(out, "name", this->name); + dump_field(out, "mac_address", this->mac_address); + dump_field(out, "esphome_version", this->esphome_version); + dump_field(out, "compilation_time", this->compilation_time); + dump_field(out, "model", this->model); #ifdef USE_DEEP_SLEEP dump_field(out, "has_deep_sleep", this->has_deep_sleep); #endif #ifdef ESPHOME_PROJECT_NAME - dump_field(out, "project_name", this->project_name_ref_); + dump_field(out, "project_name", this->project_name); #endif #ifdef ESPHOME_PROJECT_NAME - dump_field(out, "project_version", this->project_version_ref_); + dump_field(out, "project_version", this->project_version); #endif #ifdef USE_WEBSERVER dump_field(out, "webserver_port", this->webserver_port); @@ -790,16 +788,16 @@ void DeviceInfoResponse::dump_to(std::string &out) const { #ifdef USE_BLUETOOTH_PROXY dump_field(out, "bluetooth_proxy_feature_flags", this->bluetooth_proxy_feature_flags); #endif - dump_field(out, "manufacturer", this->manufacturer_ref_); - dump_field(out, "friendly_name", this->friendly_name_ref_); + dump_field(out, "manufacturer", this->manufacturer); + dump_field(out, "friendly_name", this->friendly_name); #ifdef USE_VOICE_ASSISTANT dump_field(out, "voice_assistant_feature_flags", this->voice_assistant_feature_flags); #endif #ifdef USE_AREAS - dump_field(out, "suggested_area", this->suggested_area_ref_); + dump_field(out, "suggested_area", this->suggested_area); #endif #ifdef USE_BLUETOOTH_PROXY - dump_field(out, "bluetooth_mac_address", this->bluetooth_mac_address_ref_); + dump_field(out, "bluetooth_mac_address", this->bluetooth_mac_address); #endif #ifdef USE_API_NOISE dump_field(out, "api_encryption_supported", this->api_encryption_supported); @@ -836,14 +834,14 @@ void SubscribeStatesRequest::dump_to(std::string &out) const { out.append("Subsc #ifdef USE_BINARY_SENSOR void ListEntitiesBinarySensorResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesBinarySensorResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); - dump_field(out, "device_class", this->device_class_ref_); + dump_field(out, "name", this->name); + dump_field(out, "device_class", this->device_class); dump_field(out, "is_status_binary_sensor", this->is_status_binary_sensor); dump_field(out, "disabled_by_default", this->disabled_by_default); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "entity_category", static_cast(this->entity_category)); #ifdef USE_DEVICES @@ -863,16 +861,16 @@ void BinarySensorStateResponse::dump_to(std::string &out) const { #ifdef USE_COVER void ListEntitiesCoverResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesCoverResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); dump_field(out, "assumed_state", this->assumed_state); dump_field(out, "supports_position", this->supports_position); dump_field(out, "supports_tilt", this->supports_tilt); - dump_field(out, "device_class", this->device_class_ref_); + dump_field(out, "device_class", this->device_class); dump_field(out, "disabled_by_default", this->disabled_by_default); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "entity_category", static_cast(this->entity_category)); dump_field(out, "supports_stop", this->supports_stop); @@ -906,16 +904,16 @@ void CoverCommandRequest::dump_to(std::string &out) const { #ifdef USE_FAN void ListEntitiesFanResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesFanResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); dump_field(out, "supports_oscillation", this->supports_oscillation); dump_field(out, "supports_speed", this->supports_speed); dump_field(out, "supports_direction", this->supports_direction); dump_field(out, "supported_speed_count", this->supported_speed_count); dump_field(out, "disabled_by_default", this->disabled_by_default); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "entity_category", static_cast(this->entity_category)); for (const auto &it : *this->supported_preset_modes) { @@ -932,7 +930,7 @@ void FanStateResponse::dump_to(std::string &out) const { dump_field(out, "oscillating", this->oscillating); dump_field(out, "direction", static_cast(this->direction)); dump_field(out, "speed_level", this->speed_level); - dump_field(out, "preset_mode", this->preset_mode_ref_); + dump_field(out, "preset_mode", this->preset_mode); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); #endif @@ -949,9 +947,7 @@ void FanCommandRequest::dump_to(std::string &out) const { dump_field(out, "has_speed_level", this->has_speed_level); dump_field(out, "speed_level", this->speed_level); dump_field(out, "has_preset_mode", this->has_preset_mode); - out.append(" preset_mode: "); - out.append("'").append(this->preset_mode.c_str(), this->preset_mode.size()).append("'"); - out.append("\n"); + dump_field(out, "preset_mode", this->preset_mode); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); #endif @@ -960,9 +956,9 @@ void FanCommandRequest::dump_to(std::string &out) const { #ifdef USE_LIGHT void ListEntitiesLightResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesLightResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); for (const auto &it : *this->supported_color_modes) { dump_field(out, "supported_color_modes", static_cast(it), 4); } @@ -973,7 +969,7 @@ void ListEntitiesLightResponse::dump_to(std::string &out) const { } dump_field(out, "disabled_by_default", this->disabled_by_default); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "entity_category", static_cast(this->entity_category)); #ifdef USE_DEVICES @@ -994,7 +990,7 @@ void LightStateResponse::dump_to(std::string &out) const { dump_field(out, "color_temperature", this->color_temperature); dump_field(out, "cold_white", this->cold_white); dump_field(out, "warm_white", this->warm_white); - dump_field(out, "effect", this->effect_ref_); + dump_field(out, "effect", this->effect); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); #endif @@ -1027,9 +1023,7 @@ void LightCommandRequest::dump_to(std::string &out) const { dump_field(out, "has_flash_length", this->has_flash_length); dump_field(out, "flash_length", this->flash_length); dump_field(out, "has_effect", this->has_effect); - out.append(" effect: "); - out.append("'").append(this->effect.c_str(), this->effect.size()).append("'"); - out.append("\n"); + dump_field(out, "effect", this->effect); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); #endif @@ -1038,16 +1032,16 @@ void LightCommandRequest::dump_to(std::string &out) const { #ifdef USE_SENSOR void ListEntitiesSensorResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesSensorResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif - dump_field(out, "unit_of_measurement", this->unit_of_measurement_ref_); + dump_field(out, "unit_of_measurement", this->unit_of_measurement); dump_field(out, "accuracy_decimals", this->accuracy_decimals); dump_field(out, "force_update", this->force_update); - dump_field(out, "device_class", this->device_class_ref_); + dump_field(out, "device_class", this->device_class); dump_field(out, "state_class", static_cast(this->state_class)); dump_field(out, "disabled_by_default", this->disabled_by_default); dump_field(out, "entity_category", static_cast(this->entity_category)); @@ -1068,16 +1062,16 @@ void SensorStateResponse::dump_to(std::string &out) const { #ifdef USE_SWITCH void ListEntitiesSwitchResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesSwitchResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "assumed_state", this->assumed_state); dump_field(out, "disabled_by_default", this->disabled_by_default); dump_field(out, "entity_category", static_cast(this->entity_category)); - dump_field(out, "device_class", this->device_class_ref_); + dump_field(out, "device_class", this->device_class); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); #endif @@ -1102,15 +1096,15 @@ void SwitchCommandRequest::dump_to(std::string &out) const { #ifdef USE_TEXT_SENSOR void ListEntitiesTextSensorResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesTextSensorResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "disabled_by_default", this->disabled_by_default); dump_field(out, "entity_category", static_cast(this->entity_category)); - dump_field(out, "device_class", this->device_class_ref_); + dump_field(out, "device_class", this->device_class); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); #endif @@ -1118,7 +1112,7 @@ void ListEntitiesTextSensorResponse::dump_to(std::string &out) const { void TextSensorStateResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "TextSensorStateResponse"); dump_field(out, "key", this->key); - dump_field(out, "state", this->state_ref_); + dump_field(out, "state", this->state); dump_field(out, "missing_state", this->missing_state); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); @@ -1144,7 +1138,10 @@ void NoiseEncryptionSetKeyRequest::dump_to(std::string &out) const { out.append(format_hex_pretty(this->key, this->key_len)); out.append("\n"); } -void NoiseEncryptionSetKeyResponse::dump_to(std::string &out) const { dump_field(out, "success", this->success); } +void NoiseEncryptionSetKeyResponse::dump_to(std::string &out) const { + MessageDumpHelper helper(out, "NoiseEncryptionSetKeyResponse"); + dump_field(out, "success", this->success); +} #endif #ifdef USE_API_HOMEASSISTANT_SERVICES void SubscribeHomeassistantServicesRequest::dump_to(std::string &out) const { @@ -1152,12 +1149,12 @@ void SubscribeHomeassistantServicesRequest::dump_to(std::string &out) const { } void HomeassistantServiceMap::dump_to(std::string &out) const { MessageDumpHelper helper(out, "HomeassistantServiceMap"); - dump_field(out, "key", this->key_ref_); + dump_field(out, "key", this->key); dump_field(out, "value", this->value); } void HomeassistantActionRequest::dump_to(std::string &out) const { MessageDumpHelper helper(out, "HomeassistantActionRequest"); - dump_field(out, "service", this->service_ref_); + dump_field(out, "service", this->service); for (const auto &it : this->data) { out.append(" data: "); it.dump_to(out); @@ -1190,9 +1187,7 @@ void HomeassistantActionResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "HomeassistantActionResponse"); dump_field(out, "call_id", this->call_id); dump_field(out, "success", this->success); - out.append(" error_message: "); - out.append("'").append(this->error_message.c_str(), this->error_message.size()).append("'"); - out.append("\n"); + dump_field(out, "error_message", this->error_message); #ifdef USE_API_HOMEASSISTANT_ACTION_RESPONSES_JSON out.append(" response_data: "); out.append(format_hex_pretty(this->response_data, this->response_data_len)); @@ -1206,40 +1201,32 @@ void SubscribeHomeAssistantStatesRequest::dump_to(std::string &out) const { } void SubscribeHomeAssistantStateResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "SubscribeHomeAssistantStateResponse"); - dump_field(out, "entity_id", this->entity_id_ref_); - dump_field(out, "attribute", this->attribute_ref_); + dump_field(out, "entity_id", this->entity_id); + dump_field(out, "attribute", this->attribute); dump_field(out, "once", this->once); } void HomeAssistantStateResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "HomeAssistantStateResponse"); - out.append(" entity_id: "); - out.append("'").append(this->entity_id.c_str(), this->entity_id.size()).append("'"); - out.append("\n"); - out.append(" state: "); - out.append("'").append(this->state.c_str(), this->state.size()).append("'"); - out.append("\n"); - out.append(" attribute: "); - out.append("'").append(this->attribute.c_str(), this->attribute.size()).append("'"); - out.append("\n"); + dump_field(out, "entity_id", this->entity_id); + dump_field(out, "state", this->state); + dump_field(out, "attribute", this->attribute); } #endif void GetTimeRequest::dump_to(std::string &out) const { out.append("GetTimeRequest {}"); } void GetTimeResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "GetTimeResponse"); dump_field(out, "epoch_seconds", this->epoch_seconds); - out.append(" timezone: "); - out.append("'").append(this->timezone.c_str(), this->timezone.size()).append("'"); - out.append("\n"); + dump_field(out, "timezone", this->timezone); } #ifdef USE_API_USER_DEFINED_ACTIONS void ListEntitiesServicesArgument::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesServicesArgument"); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); dump_field(out, "type", static_cast(this->type)); } void ListEntitiesServicesResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesServicesResponse"); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); dump_field(out, "key", this->key); for (const auto &it : this->args) { out.append(" args: "); @@ -1253,9 +1240,7 @@ void ExecuteServiceArgument::dump_to(std::string &out) const { dump_field(out, "bool_", this->bool_); dump_field(out, "legacy_int", this->legacy_int); dump_field(out, "float_", this->float_); - out.append(" string_: "); - out.append("'").append(this->string_.c_str(), this->string_.size()).append("'"); - out.append("\n"); + dump_field(out, "string_", this->string_); dump_field(out, "int_", this->int_); for (const auto it : this->bool_array) { dump_field(out, "bool_array", static_cast(it), 4); @@ -1291,7 +1276,7 @@ void ExecuteServiceResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ExecuteServiceResponse"); dump_field(out, "call_id", this->call_id); dump_field(out, "success", this->success); - dump_field(out, "error_message", this->error_message_ref_); + dump_field(out, "error_message", this->error_message); #ifdef USE_API_USER_DEFINED_ACTION_RESPONSES_JSON out.append(" response_data: "); out.append(format_hex_pretty(this->response_data, this->response_data_len)); @@ -1302,12 +1287,12 @@ void ExecuteServiceResponse::dump_to(std::string &out) const { #ifdef USE_CAMERA void ListEntitiesCameraResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesCameraResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); dump_field(out, "disabled_by_default", this->disabled_by_default); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "entity_category", static_cast(this->entity_category)); #ifdef USE_DEVICES @@ -1334,9 +1319,9 @@ void CameraImageRequest::dump_to(std::string &out) const { #ifdef USE_CLIMATE void ListEntitiesClimateResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesClimateResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); dump_field(out, "supports_current_temperature", this->supports_current_temperature); dump_field(out, "supports_two_point_target_temperature", this->supports_two_point_target_temperature); for (const auto &it : *this->supported_modes) { @@ -1363,7 +1348,7 @@ void ListEntitiesClimateResponse::dump_to(std::string &out) const { } dump_field(out, "disabled_by_default", this->disabled_by_default); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "entity_category", static_cast(this->entity_category)); dump_field(out, "visual_current_temperature_step", this->visual_current_temperature_step); @@ -1387,9 +1372,9 @@ void ClimateStateResponse::dump_to(std::string &out) const { dump_field(out, "action", static_cast(this->action)); dump_field(out, "fan_mode", static_cast(this->fan_mode)); dump_field(out, "swing_mode", static_cast(this->swing_mode)); - dump_field(out, "custom_fan_mode", this->custom_fan_mode_ref_); + dump_field(out, "custom_fan_mode", this->custom_fan_mode); dump_field(out, "preset", static_cast(this->preset)); - dump_field(out, "custom_preset", this->custom_preset_ref_); + dump_field(out, "custom_preset", this->custom_preset); dump_field(out, "current_humidity", this->current_humidity); dump_field(out, "target_humidity", this->target_humidity); #ifdef USE_DEVICES @@ -1412,15 +1397,11 @@ void ClimateCommandRequest::dump_to(std::string &out) const { dump_field(out, "has_swing_mode", this->has_swing_mode); dump_field(out, "swing_mode", static_cast(this->swing_mode)); dump_field(out, "has_custom_fan_mode", this->has_custom_fan_mode); - out.append(" custom_fan_mode: "); - out.append("'").append(this->custom_fan_mode.c_str(), this->custom_fan_mode.size()).append("'"); - out.append("\n"); + dump_field(out, "custom_fan_mode", this->custom_fan_mode); dump_field(out, "has_preset", this->has_preset); dump_field(out, "preset", static_cast(this->preset)); dump_field(out, "has_custom_preset", this->has_custom_preset); - out.append(" custom_preset: "); - out.append("'").append(this->custom_preset.c_str(), this->custom_preset.size()).append("'"); - out.append("\n"); + dump_field(out, "custom_preset", this->custom_preset); dump_field(out, "has_target_humidity", this->has_target_humidity); dump_field(out, "target_humidity", this->target_humidity); #ifdef USE_DEVICES @@ -1431,11 +1412,11 @@ void ClimateCommandRequest::dump_to(std::string &out) const { #ifdef USE_WATER_HEATER void ListEntitiesWaterHeaterResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesWaterHeaterResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "disabled_by_default", this->disabled_by_default); dump_field(out, "entity_category", static_cast(this->entity_category)); @@ -1480,20 +1461,20 @@ void WaterHeaterCommandRequest::dump_to(std::string &out) const { #ifdef USE_NUMBER void ListEntitiesNumberResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesNumberResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "min_value", this->min_value); dump_field(out, "max_value", this->max_value); dump_field(out, "step", this->step); dump_field(out, "disabled_by_default", this->disabled_by_default); dump_field(out, "entity_category", static_cast(this->entity_category)); - dump_field(out, "unit_of_measurement", this->unit_of_measurement_ref_); + dump_field(out, "unit_of_measurement", this->unit_of_measurement); dump_field(out, "mode", static_cast(this->mode)); - dump_field(out, "device_class", this->device_class_ref_); + dump_field(out, "device_class", this->device_class); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); #endif @@ -1519,11 +1500,11 @@ void NumberCommandRequest::dump_to(std::string &out) const { #ifdef USE_SELECT void ListEntitiesSelectResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesSelectResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif for (const auto &it : *this->options) { dump_field(out, "options", it, 4); @@ -1537,7 +1518,7 @@ void ListEntitiesSelectResponse::dump_to(std::string &out) const { void SelectStateResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "SelectStateResponse"); dump_field(out, "key", this->key); - dump_field(out, "state", this->state_ref_); + dump_field(out, "state", this->state); dump_field(out, "missing_state", this->missing_state); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); @@ -1546,9 +1527,7 @@ void SelectStateResponse::dump_to(std::string &out) const { void SelectCommandRequest::dump_to(std::string &out) const { MessageDumpHelper helper(out, "SelectCommandRequest"); dump_field(out, "key", this->key); - out.append(" state: "); - out.append("'").append(this->state.c_str(), this->state.size()).append("'"); - out.append("\n"); + dump_field(out, "state", this->state); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); #endif @@ -1557,11 +1536,11 @@ void SelectCommandRequest::dump_to(std::string &out) const { #ifdef USE_SIREN void ListEntitiesSirenResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesSirenResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "disabled_by_default", this->disabled_by_default); for (const auto &it : *this->tones) { @@ -1588,9 +1567,7 @@ void SirenCommandRequest::dump_to(std::string &out) const { dump_field(out, "has_state", this->has_state); dump_field(out, "state", this->state); dump_field(out, "has_tone", this->has_tone); - out.append(" tone: "); - out.append("'").append(this->tone.c_str(), this->tone.size()).append("'"); - out.append("\n"); + dump_field(out, "tone", this->tone); dump_field(out, "has_duration", this->has_duration); dump_field(out, "duration", this->duration); dump_field(out, "has_volume", this->has_volume); @@ -1603,18 +1580,18 @@ void SirenCommandRequest::dump_to(std::string &out) const { #ifdef USE_LOCK void ListEntitiesLockResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesLockResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "disabled_by_default", this->disabled_by_default); dump_field(out, "entity_category", static_cast(this->entity_category)); dump_field(out, "assumed_state", this->assumed_state); dump_field(out, "supports_open", this->supports_open); dump_field(out, "requires_code", this->requires_code); - dump_field(out, "code_format", this->code_format_ref_); + dump_field(out, "code_format", this->code_format); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); #endif @@ -1632,9 +1609,7 @@ void LockCommandRequest::dump_to(std::string &out) const { dump_field(out, "key", this->key); dump_field(out, "command", static_cast(this->command)); dump_field(out, "has_code", this->has_code); - out.append(" code: "); - out.append("'").append(this->code.c_str(), this->code.size()).append("'"); - out.append("\n"); + dump_field(out, "code", this->code); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); #endif @@ -1643,15 +1618,15 @@ void LockCommandRequest::dump_to(std::string &out) const { #ifdef USE_BUTTON void ListEntitiesButtonResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesButtonResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "disabled_by_default", this->disabled_by_default); dump_field(out, "entity_category", static_cast(this->entity_category)); - dump_field(out, "device_class", this->device_class_ref_); + dump_field(out, "device_class", this->device_class); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); #endif @@ -1667,7 +1642,7 @@ void ButtonCommandRequest::dump_to(std::string &out) const { #ifdef USE_MEDIA_PLAYER void MediaPlayerSupportedFormat::dump_to(std::string &out) const { MessageDumpHelper helper(out, "MediaPlayerSupportedFormat"); - dump_field(out, "format", this->format_ref_); + dump_field(out, "format", this->format); dump_field(out, "sample_rate", this->sample_rate); dump_field(out, "num_channels", this->num_channels); dump_field(out, "purpose", static_cast(this->purpose)); @@ -1675,11 +1650,11 @@ void MediaPlayerSupportedFormat::dump_to(std::string &out) const { } void ListEntitiesMediaPlayerResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesMediaPlayerResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "disabled_by_default", this->disabled_by_default); dump_field(out, "entity_category", static_cast(this->entity_category)); @@ -1712,9 +1687,7 @@ void MediaPlayerCommandRequest::dump_to(std::string &out) const { dump_field(out, "has_volume", this->has_volume); dump_field(out, "volume", this->volume); dump_field(out, "has_media_url", this->has_media_url); - out.append(" media_url: "); - out.append("'").append(this->media_url.c_str(), this->media_url.size()).append("'"); - out.append("\n"); + dump_field(out, "media_url", this->media_url); dump_field(out, "has_announcement", this->has_announcement); dump_field(out, "announcement", this->announcement); #ifdef USE_DEVICES @@ -1758,7 +1731,10 @@ void BluetoothDeviceConnectionResponse::dump_to(std::string &out) const { dump_field(out, "mtu", this->mtu); dump_field(out, "error", this->error); } -void BluetoothGATTGetServicesRequest::dump_to(std::string &out) const { dump_field(out, "address", this->address); } +void BluetoothGATTGetServicesRequest::dump_to(std::string &out) const { + MessageDumpHelper helper(out, "BluetoothGATTGetServicesRequest"); + dump_field(out, "address", this->address); +} void BluetoothGATTDescriptor::dump_to(std::string &out) const { MessageDumpHelper helper(out, "BluetoothGATTDescriptor"); for (const auto &it : this->uuid) { @@ -1930,12 +1906,12 @@ void VoiceAssistantAudioSettings::dump_to(std::string &out) const { void VoiceAssistantRequest::dump_to(std::string &out) const { MessageDumpHelper helper(out, "VoiceAssistantRequest"); dump_field(out, "start", this->start); - dump_field(out, "conversation_id", this->conversation_id_ref_); + dump_field(out, "conversation_id", this->conversation_id); dump_field(out, "flags", this->flags); out.append(" audio_settings: "); this->audio_settings.dump_to(out); out.append("\n"); - dump_field(out, "wake_word_phrase", this->wake_word_phrase_ref_); + dump_field(out, "wake_word_phrase", this->wake_word_phrase); } void VoiceAssistantResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "VoiceAssistantResponse"); @@ -1944,12 +1920,8 @@ void VoiceAssistantResponse::dump_to(std::string &out) const { } void VoiceAssistantEventData::dump_to(std::string &out) const { MessageDumpHelper helper(out, "VoiceAssistantEventData"); - out.append(" name: "); - out.append("'").append(this->name.c_str(), this->name.size()).append("'"); - out.append("\n"); - out.append(" value: "); - out.append("'").append(this->value.c_str(), this->value.size()).append("'"); - out.append("\n"); + dump_field(out, "name", this->name); + dump_field(out, "value", this->value); } void VoiceAssistantEventResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "VoiceAssistantEventResponse"); @@ -1970,59 +1942,42 @@ void VoiceAssistantAudio::dump_to(std::string &out) const { void VoiceAssistantTimerEventResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "VoiceAssistantTimerEventResponse"); dump_field(out, "event_type", static_cast(this->event_type)); - out.append(" timer_id: "); - out.append("'").append(this->timer_id.c_str(), this->timer_id.size()).append("'"); - out.append("\n"); - out.append(" name: "); - out.append("'").append(this->name.c_str(), this->name.size()).append("'"); - out.append("\n"); + dump_field(out, "timer_id", this->timer_id); + dump_field(out, "name", this->name); dump_field(out, "total_seconds", this->total_seconds); dump_field(out, "seconds_left", this->seconds_left); dump_field(out, "is_active", this->is_active); } void VoiceAssistantAnnounceRequest::dump_to(std::string &out) const { MessageDumpHelper helper(out, "VoiceAssistantAnnounceRequest"); - out.append(" media_id: "); - out.append("'").append(this->media_id.c_str(), this->media_id.size()).append("'"); - out.append("\n"); - out.append(" text: "); - out.append("'").append(this->text.c_str(), this->text.size()).append("'"); - out.append("\n"); - out.append(" preannounce_media_id: "); - out.append("'").append(this->preannounce_media_id.c_str(), this->preannounce_media_id.size()).append("'"); - out.append("\n"); + dump_field(out, "media_id", this->media_id); + dump_field(out, "text", this->text); + dump_field(out, "preannounce_media_id", this->preannounce_media_id); dump_field(out, "start_conversation", this->start_conversation); } -void VoiceAssistantAnnounceFinished::dump_to(std::string &out) const { dump_field(out, "success", this->success); } +void VoiceAssistantAnnounceFinished::dump_to(std::string &out) const { + MessageDumpHelper helper(out, "VoiceAssistantAnnounceFinished"); + dump_field(out, "success", this->success); +} void VoiceAssistantWakeWord::dump_to(std::string &out) const { MessageDumpHelper helper(out, "VoiceAssistantWakeWord"); - dump_field(out, "id", this->id_ref_); - dump_field(out, "wake_word", this->wake_word_ref_); + dump_field(out, "id", this->id); + dump_field(out, "wake_word", this->wake_word); for (const auto &it : this->trained_languages) { dump_field(out, "trained_languages", it, 4); } } void VoiceAssistantExternalWakeWord::dump_to(std::string &out) const { MessageDumpHelper helper(out, "VoiceAssistantExternalWakeWord"); - out.append(" id: "); - out.append("'").append(this->id.c_str(), this->id.size()).append("'"); - out.append("\n"); - out.append(" wake_word: "); - out.append("'").append(this->wake_word.c_str(), this->wake_word.size()).append("'"); - out.append("\n"); + dump_field(out, "id", this->id); + dump_field(out, "wake_word", this->wake_word); for (const auto &it : this->trained_languages) { dump_field(out, "trained_languages", it, 4); } - out.append(" model_type: "); - out.append("'").append(this->model_type.c_str(), this->model_type.size()).append("'"); - out.append("\n"); + dump_field(out, "model_type", this->model_type); dump_field(out, "model_size", this->model_size); - out.append(" model_hash: "); - out.append("'").append(this->model_hash.c_str(), this->model_hash.size()).append("'"); - out.append("\n"); - out.append(" url: "); - out.append("'").append(this->url.c_str(), this->url.size()).append("'"); - out.append("\n"); + dump_field(out, "model_hash", this->model_hash); + dump_field(out, "url", this->url); } void VoiceAssistantConfigurationRequest::dump_to(std::string &out) const { MessageDumpHelper helper(out, "VoiceAssistantConfigurationRequest"); @@ -2054,11 +2009,11 @@ void VoiceAssistantSetConfiguration::dump_to(std::string &out) const { #ifdef USE_ALARM_CONTROL_PANEL void ListEntitiesAlarmControlPanelResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesAlarmControlPanelResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "disabled_by_default", this->disabled_by_default); dump_field(out, "entity_category", static_cast(this->entity_category)); @@ -2081,9 +2036,7 @@ void AlarmControlPanelCommandRequest::dump_to(std::string &out) const { MessageDumpHelper helper(out, "AlarmControlPanelCommandRequest"); dump_field(out, "key", this->key); dump_field(out, "command", static_cast(this->command)); - out.append(" code: "); - out.append("'").append(this->code.c_str(), this->code.size()).append("'"); - out.append("\n"); + dump_field(out, "code", this->code); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); #endif @@ -2092,17 +2045,17 @@ void AlarmControlPanelCommandRequest::dump_to(std::string &out) const { #ifdef USE_TEXT void ListEntitiesTextResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesTextResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "disabled_by_default", this->disabled_by_default); dump_field(out, "entity_category", static_cast(this->entity_category)); dump_field(out, "min_length", this->min_length); dump_field(out, "max_length", this->max_length); - dump_field(out, "pattern", this->pattern_ref_); + dump_field(out, "pattern", this->pattern); dump_field(out, "mode", static_cast(this->mode)); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); @@ -2111,7 +2064,7 @@ void ListEntitiesTextResponse::dump_to(std::string &out) const { void TextStateResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "TextStateResponse"); dump_field(out, "key", this->key); - dump_field(out, "state", this->state_ref_); + dump_field(out, "state", this->state); dump_field(out, "missing_state", this->missing_state); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); @@ -2120,9 +2073,7 @@ void TextStateResponse::dump_to(std::string &out) const { void TextCommandRequest::dump_to(std::string &out) const { MessageDumpHelper helper(out, "TextCommandRequest"); dump_field(out, "key", this->key); - out.append(" state: "); - out.append("'").append(this->state.c_str(), this->state.size()).append("'"); - out.append("\n"); + dump_field(out, "state", this->state); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); #endif @@ -2131,11 +2082,11 @@ void TextCommandRequest::dump_to(std::string &out) const { #ifdef USE_DATETIME_DATE void ListEntitiesDateResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesDateResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "disabled_by_default", this->disabled_by_default); dump_field(out, "entity_category", static_cast(this->entity_category)); @@ -2168,11 +2119,11 @@ void DateCommandRequest::dump_to(std::string &out) const { #ifdef USE_DATETIME_TIME void ListEntitiesTimeResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesTimeResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "disabled_by_default", this->disabled_by_default); dump_field(out, "entity_category", static_cast(this->entity_category)); @@ -2205,15 +2156,15 @@ void TimeCommandRequest::dump_to(std::string &out) const { #ifdef USE_EVENT void ListEntitiesEventResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesEventResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "disabled_by_default", this->disabled_by_default); dump_field(out, "entity_category", static_cast(this->entity_category)); - dump_field(out, "device_class", this->device_class_ref_); + dump_field(out, "device_class", this->device_class); for (const auto &it : *this->event_types) { dump_field(out, "event_types", it, 4); } @@ -2224,7 +2175,7 @@ void ListEntitiesEventResponse::dump_to(std::string &out) const { void EventResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "EventResponse"); dump_field(out, "key", this->key); - dump_field(out, "event_type", this->event_type_ref_); + dump_field(out, "event_type", this->event_type); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); #endif @@ -2233,15 +2184,15 @@ void EventResponse::dump_to(std::string &out) const { #ifdef USE_VALVE void ListEntitiesValveResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesValveResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "disabled_by_default", this->disabled_by_default); dump_field(out, "entity_category", static_cast(this->entity_category)); - dump_field(out, "device_class", this->device_class_ref_); + dump_field(out, "device_class", this->device_class); dump_field(out, "assumed_state", this->assumed_state); dump_field(out, "supports_position", this->supports_position); dump_field(out, "supports_stop", this->supports_stop); @@ -2272,11 +2223,11 @@ void ValveCommandRequest::dump_to(std::string &out) const { #ifdef USE_DATETIME_DATETIME void ListEntitiesDateTimeResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesDateTimeResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "disabled_by_default", this->disabled_by_default); dump_field(out, "entity_category", static_cast(this->entity_category)); @@ -2305,15 +2256,15 @@ void DateTimeCommandRequest::dump_to(std::string &out) const { #ifdef USE_UPDATE void ListEntitiesUpdateResponse::dump_to(std::string &out) const { MessageDumpHelper helper(out, "ListEntitiesUpdateResponse"); - dump_field(out, "object_id", this->object_id_ref_); + dump_field(out, "object_id", this->object_id); dump_field(out, "key", this->key); - dump_field(out, "name", this->name_ref_); + dump_field(out, "name", this->name); #ifdef USE_ENTITY_ICON - dump_field(out, "icon", this->icon_ref_); + dump_field(out, "icon", this->icon); #endif dump_field(out, "disabled_by_default", this->disabled_by_default); dump_field(out, "entity_category", static_cast(this->entity_category)); - dump_field(out, "device_class", this->device_class_ref_); + dump_field(out, "device_class", this->device_class); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); #endif @@ -2325,11 +2276,11 @@ void UpdateStateResponse::dump_to(std::string &out) const { dump_field(out, "in_progress", this->in_progress); dump_field(out, "has_progress", this->has_progress); dump_field(out, "progress", this->progress); - dump_field(out, "current_version", this->current_version_ref_); - dump_field(out, "latest_version", this->latest_version_ref_); - dump_field(out, "title", this->title_ref_); - dump_field(out, "release_summary", this->release_summary_ref_); - dump_field(out, "release_url", this->release_url_ref_); + dump_field(out, "current_version", this->current_version); + dump_field(out, "latest_version", this->latest_version); + dump_field(out, "title", this->title); + dump_field(out, "release_summary", this->release_summary); + dump_field(out, "release_url", this->release_url); #ifdef USE_DEVICES dump_field(out, "device_id", this->device_id); #endif diff --git a/esphome/components/api/custom_api_device.h b/esphome/components/api/custom_api_device.h index 7f655a2479..b16164270b 100644 --- a/esphome/components/api/custom_api_device.h +++ b/esphome/components/api/custom_api_device.h @@ -240,7 +240,7 @@ class CustomAPIDevice { */ void call_homeassistant_service(const std::string &service_name) { HomeassistantActionRequest resp; - resp.set_service(StringRef(service_name)); + resp.service = StringRef(service_name); global_api_server->send_homeassistant_action(resp); } @@ -260,12 +260,12 @@ class CustomAPIDevice { */ void call_homeassistant_service(const std::string &service_name, const std::map &data) { HomeassistantActionRequest resp; - resp.set_service(StringRef(service_name)); + resp.service = StringRef(service_name); resp.data.init(data.size()); for (auto &it : data) { auto &kv = resp.data.emplace_back(); - kv.set_key(StringRef(it.first)); - kv.value = it.second; + kv.key = StringRef(it.first); + kv.value = it.second; // value is std::string (no_zero_copy), assign directly } global_api_server->send_homeassistant_action(resp); } @@ -282,7 +282,7 @@ class CustomAPIDevice { */ void fire_homeassistant_event(const std::string &event_name) { HomeassistantActionRequest resp; - resp.set_service(StringRef(event_name)); + resp.service = StringRef(event_name); resp.is_event = true; global_api_server->send_homeassistant_action(resp); } @@ -302,13 +302,13 @@ class CustomAPIDevice { */ void fire_homeassistant_event(const std::string &service_name, const std::map &data) { HomeassistantActionRequest resp; - resp.set_service(StringRef(service_name)); + resp.service = StringRef(service_name); resp.is_event = true; resp.data.init(data.size()); for (auto &it : data) { auto &kv = resp.data.emplace_back(); - kv.set_key(StringRef(it.first)); - kv.value = it.second; + kv.key = StringRef(it.first); + kv.value = it.second; // value is std::string (no_zero_copy), assign directly } global_api_server->send_homeassistant_action(resp); } diff --git a/esphome/components/api/homeassistant_service.h b/esphome/components/api/homeassistant_service.h index 1fdcc51803..a17c99b8ba 100644 --- a/esphome/components/api/homeassistant_service.h +++ b/esphome/components/api/homeassistant_service.h @@ -147,7 +147,7 @@ template class HomeAssistantServiceCallAction : public Actionservice_.value(x...); - resp.set_service(StringRef(service_value)); + resp.service = StringRef(service_value); resp.is_event = this->flags_.is_event; this->populate_service_map(resp.data, this->data_, x...); this->populate_service_map(resp.data_template, this->data_template_, x...); @@ -209,7 +209,7 @@ template class HomeAssistantServiceCallAction : public Actionsend_message(msg); // temp is valid during encoding * * Unsafe Patterns (WILL cause crashes/corruption): - * 1. Temporaries: msg.set_field(StringRef(obj.get_string())) // get_string() returns by value - * 2. Concatenation: msg.set_field(StringRef(str1 + str2)) // Result is temporary + * 1. Temporaries: msg.field = StringRef(obj.get_string()) // get_string() returns by value + * 2. Concatenation: msg.field = StringRef(str1 + str2) // Result is temporary * * For unsafe patterns, store in a local variable first: * std::string temp = get_string(); // or str1 + str2 - * msg.set_field(StringRef(temp)); + * msg.field = StringRef(temp); * * The send_*_response pattern ensures proper lifetime management by encoding * within the same function scope where temporaries are created. diff --git a/esphome/components/api/user_services.h b/esphome/components/api/user_services.h index 8e3a61b279..85fba2a435 100644 --- a/esphome/components/api/user_services.h +++ b/esphome/components/api/user_services.h @@ -46,7 +46,7 @@ template class UserServiceBase : public UserServiceDescriptor { ListEntitiesServicesResponse encode_list_service_response() override { ListEntitiesServicesResponse msg; - msg.set_name(StringRef(this->name_)); + msg.name = StringRef(this->name_); msg.key = this->key_; msg.supports_response = this->supports_response_; std::array arg_types = {to_service_arg_type()...}; @@ -54,7 +54,7 @@ template class UserServiceBase : public UserServiceDescriptor { for (size_t i = 0; i < sizeof...(Ts); i++) { auto &arg = msg.args.emplace_back(); arg.type = arg_types[i]; - arg.set_name(StringRef(this->arg_names_[i])); + arg.name = StringRef(this->arg_names_[i]); } return msg; } @@ -108,7 +108,7 @@ template class UserServiceDynamic : public UserServiceDescriptor ListEntitiesServicesResponse encode_list_service_response() override { ListEntitiesServicesResponse msg; - msg.set_name(StringRef(this->name_)); + msg.name = StringRef(this->name_); msg.key = this->key_; msg.supports_response = enums::SUPPORTS_RESPONSE_NONE; // Dynamic services don't support responses yet std::array arg_types = {to_service_arg_type()...}; @@ -116,7 +116,7 @@ template class UserServiceDynamic : public UserServiceDescriptor for (size_t i = 0; i < sizeof...(Ts); i++) { auto &arg = msg.args.emplace_back(); arg.type = arg_types[i]; - arg.set_name(StringRef(this->arg_names_[i])); + arg.name = StringRef(this->arg_names_[i]); } return msg; } diff --git a/esphome/components/homeassistant/number/homeassistant_number.cpp b/esphome/components/homeassistant/number/homeassistant_number.cpp index 8c0d415c23..82387a81e9 100644 --- a/esphome/components/homeassistant/number/homeassistant_number.cpp +++ b/esphome/components/homeassistant/number/homeassistant_number.cpp @@ -86,15 +86,15 @@ void HomeassistantNumber::control(float value) { static constexpr auto VALUE_KEY = StringRef::from_lit("value"); api::HomeassistantActionRequest resp; - resp.set_service(SERVICE_NAME); + resp.service = SERVICE_NAME; resp.data.init(2); auto &entity_id = resp.data.emplace_back(); - entity_id.set_key(ENTITY_ID_KEY); + entity_id.key = ENTITY_ID_KEY; entity_id.value = this->entity_id_; auto &entity_value = resp.data.emplace_back(); - entity_value.set_key(VALUE_KEY); + entity_value.key = VALUE_KEY; entity_value.value = to_string(value); api::global_api_server->send_homeassistant_action(resp); diff --git a/esphome/components/homeassistant/switch/homeassistant_switch.cpp b/esphome/components/homeassistant/switch/homeassistant_switch.cpp index d08d761442..79d17eb290 100644 --- a/esphome/components/homeassistant/switch/homeassistant_switch.cpp +++ b/esphome/components/homeassistant/switch/homeassistant_switch.cpp @@ -47,14 +47,14 @@ void HomeassistantSwitch::write_state(bool state) { api::HomeassistantActionRequest resp; if (state) { - resp.set_service(SERVICE_ON); + resp.service = SERVICE_ON; } else { - resp.set_service(SERVICE_OFF); + resp.service = SERVICE_OFF; } resp.data.init(1); auto &entity_id_kv = resp.data.emplace_back(); - entity_id_kv.set_key(ENTITY_ID_KEY); + entity_id_kv.key = ENTITY_ID_KEY; entity_id_kv.value = this->entity_id_; api::global_api_server->send_homeassistant_action(resp); diff --git a/esphome/components/voice_assistant/voice_assistant.cpp b/esphome/components/voice_assistant/voice_assistant.cpp index 0e0616c508..e2516d5fb8 100644 --- a/esphome/components/voice_assistant/voice_assistant.cpp +++ b/esphome/components/voice_assistant/voice_assistant.cpp @@ -239,10 +239,10 @@ void VoiceAssistant::loop() { api::VoiceAssistantRequest msg; msg.start = true; - msg.set_conversation_id(StringRef(this->conversation_id_)); + msg.conversation_id = StringRef(this->conversation_id_); msg.flags = flags; msg.audio_settings = audio_settings; - msg.set_wake_word_phrase(StringRef(this->wake_word_)); + msg.wake_word_phrase = StringRef(this->wake_word_); // Reset media player state tracking #ifdef USE_MEDIA_PLAYER diff --git a/script/api_protobuf/api_protobuf.py b/script/api_protobuf/api_protobuf.py index 7293f2abbc..274a672c7c 100755 --- a/script/api_protobuf/api_protobuf.py +++ b/script/api_protobuf/api_protobuf.py @@ -373,13 +373,11 @@ def create_field_type_info( return BytesType(field, needs_decode, needs_encode) - # Special handling for string fields + # Special handling for string fields - use StringRef for zero-copy unless no_zero_copy is set if field.type == 9: - # For SOURCE_CLIENT only messages (decode but no encode), use StringRef - # for zero-copy access to the receive buffer - if needs_decode and not needs_encode: - return PointerToStringBufferType(field, None) - return StringType(field, needs_decode, needs_encode) + if get_field_opt(field, pb.no_zero_copy, False): + return StringType(field, needs_decode, needs_encode) + return PointerToStringBufferType(field, None) validate_field_type(field.type, field.name) return TYPE_INFO[field.type](field) @@ -915,6 +913,10 @@ class PointerToStringBufferType(PointerToBufferTypeBase): reference_type = "StringRef &" const_reference_type = "const StringRef &" + @classmethod + def can_use_dump_field(cls) -> bool: + return True + @property def public_content(self) -> list[str]: return [f"StringRef {self.field_name}{{}};"] @@ -931,19 +933,19 @@ class PointerToStringBufferType(PointerToBufferTypeBase): }}""" def dump(self, name: str) -> str: - return f'out.append("\'").append(this->{self.field_name}.c_str(), this->{self.field_name}.size()).append("\'");' + # Not used since we use dump_field, but required by abstract base class + return f'out.append("\'").append({name}.c_str(), {name}.size()).append("\'");' @property def dump_content(self) -> str: - return ( - f'out.append(" {self.name}: ");\n' - + f"{self.dump(self.field_name)}\n" - + 'out.append("\\n");' - ) + return f'dump_field(out, "{self.name}", this->{self.field_name});' def get_size_calculation(self, name: str, force: bool = False) -> str: return f"size.add_length({self.calculate_field_id_size()}, this->{self.field_name}.size());" + def get_estimated_size(self) -> int: + return self.calculate_field_id_size() + 8 # field ID + 8 bytes typical string + class FixedArrayBytesType(TypeInfo): """Special type for fixed-size byte arrays.""" @@ -2149,12 +2151,10 @@ def build_message_type( # dump_to implementation will go in dump_cpp dump_impl = f"void {desc.name}::dump_to(std::string &out) const {{" if dump: - if len(dump) == 1 and len(dump[0]) + len(dump_impl) + 3 < 120: - dump_impl += f" {dump[0]} " - else: - dump_impl += "\n" - dump_impl += f' MessageDumpHelper helper(out, "{desc.name}");\n' - dump_impl += indent("\n".join(dump)) + "\n" + # Always use MessageDumpHelper for consistent output formatting + dump_impl += "\n" + dump_impl += f' MessageDumpHelper helper(out, "{desc.name}");\n' + dump_impl += indent("\n".join(dump)) + "\n" else: o2 = f'out.append("{desc.name} {{}}");' if len(dump_impl) + len(o2) + 3 < 120: