1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-08 00:31:58 +00:00

[text_sensor] Fix spurious raw_state deprecation warnings (#12262)

This commit is contained in:
J. Nick Koston
2025-12-03 10:22:06 -06:00
committed by GitHub
parent 87ac4baf3a
commit b3812b5811

View File

@@ -24,7 +24,17 @@ void log_text_sensor(const char *tag, const char *prefix, const char *type, Text
class TextSensor : public EntityBase, public EntityBase_DeviceClass { class TextSensor : public EntityBase, public EntityBase_DeviceClass {
public: public:
std::string state;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
/// @deprecated Use get_raw_state() instead. This member will be removed in ESPHome 2026.6.0.
ESPDEPRECATED("Use get_raw_state() instead of .raw_state. Will be removed in 2026.6.0", "2025.12.0")
std::string raw_state;
TextSensor() = default; TextSensor() = default;
~TextSensor() = default;
#pragma GCC diagnostic pop
/// Getter-syntax for .state. /// Getter-syntax for .state.
std::string get_state() const; std::string get_state() const;
@@ -49,15 +59,6 @@ class TextSensor : public EntityBase, public EntityBase_DeviceClass {
/// Add a callback that will be called every time the sensor sends a raw value. /// Add a callback that will be called every time the sensor sends a raw value.
void add_on_raw_state_callback(std::function<void(std::string)> callback); void add_on_raw_state_callback(std::function<void(std::string)> callback);
std::string state;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
/// @deprecated Use get_raw_state() instead. This member will be removed in ESPHome 2026.6.0.
ESPDEPRECATED("Use get_raw_state() instead of .raw_state. Will be removed in 2026.6.0", "2025.12.0")
std::string raw_state;
#pragma GCC diagnostic pop
// ========== INTERNAL METHODS ========== // ========== INTERNAL METHODS ==========
// (In most use cases you won't need these) // (In most use cases you won't need these)