Skip to content

[esp32_ble_tracker] BLE tracker lambda example uses deprecated to_string() function #6471

@danielkent-net

Description

@danielkent-net

Feedback

Summary

The esp32_ble_tracker component deprecated the UUID to_string() function in 2026.2 in favor of to_str(buf), which requires a buffer input argument. The examples in the the esp32_ble_tracker documentation still use to_string(), which will raise deprecation notices on compile (and eventually stop working in 2026.8).

Suggested changes

  • The examples should be updated
  • The breaking changes / checklist in the 2026.2 changelog should be updated to mention the deprecation

Example Suggested Code

Snippet of (probably) correct code:

esp32_ble_tracker:
  on_ble_advertise:
    - mac_address:
        - XX:XX:XX:XX:XX:XX
        - XX:XX:XX:XX:XX:XX
      then:
        - lambda: |-
            ESP_LOGD("ble_adv", "New BLE device");
            ESP_LOGD("ble_adv", "  address: %s", x.address_str().c_str());
            ESP_LOGD("ble_adv", "  name: %s", x.get_name().c_str());
            ESP_LOGD("ble_adv", "  Advertised service UUIDs:");
            char buf[esphome::esp32_ble::UUID_STR_LEN];
            for (auto uuid : x.get_service_uuids()) {
                ESP_LOGD("ble_adv", "    - %s", uuid.to_str(buf));
            }
            ESP_LOGD("ble_adv", "  Advertised service data:");
            for (auto data : x.get_service_datas()) {
                ESP_LOGD("ble_adv", "    - %s: (length %i)", data.uuid.to_str(buf), data.data.size());
            }
            ESP_LOGD("ble_adv", "  Advertised manufacturer data:");
            for (auto data : x.get_manufacturer_datas()) {
                ESP_LOGD("ble_adv", "    - %s: (length %i)", data.uuid.to_str(buf), data.data.size());
            }

URL

https://esphome.io/components/esp32_ble_tracker/

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions