From afc1c83af45da1ed2a95c2cd5a2567342b497497 Mon Sep 17 00:00:00 2001 From: Oxan van Leeuwen Date: Thu, 9 Mar 2023 01:06:20 +0100 Subject: [PATCH] Mark unique_id() override as deprecated (#4538) --- esphome/components/sensor/sensor.h | 5 ++--- esphome/components/text_sensor/text_sensor.h | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/esphome/components/sensor/sensor.h b/esphome/components/sensor/sensor.h index bba69ed0bb..4a6b1fe3dc 100644 --- a/esphome/components/sensor/sensor.h +++ b/esphome/components/sensor/sensor.h @@ -150,10 +150,9 @@ class Sensor : public EntityBase { /// Return whether this sensor has gotten a full state (that passed through all filters) yet. bool has_state() const; - /** A unique ID for this sensor, empty for no unique id. See unique ID requirements: - * https://developers.home-assistant.io/docs/en/entity_registry_index.html#unique-id-requirements + /** Override this method to set the unique ID of this sensor. * - * @return The unique id as a string. + * @deprecated Do not use for new sensors, a suitable unique ID is automatically generated (2023.4). */ virtual std::string unique_id(); diff --git a/esphome/components/text_sensor/text_sensor.h b/esphome/components/text_sensor/text_sensor.h index 60e9e30b6e..cf7b6b86ef 100644 --- a/esphome/components/text_sensor/text_sensor.h +++ b/esphome/components/text_sensor/text_sensor.h @@ -61,6 +61,10 @@ class TextSensor : public EntityBase { // ========== INTERNAL METHODS ========== // (In most use cases you won't need these) + /** Override this method to set the unique ID of this sensor. + * + * @deprecated Do not use for new sensors, a suitable unique ID is automatically generated (2023.4). + */ virtual std::string unique_id(); bool has_state();