mirror of
https://github.com/esphome/esphome.git
synced 2026-09-11 15:27:33 +00:00
[sensor] Remove deprecated raw_state member
This commit is contained in:
@@ -23,7 +23,6 @@ void ModbusNumber::parse_and_publish(std::span<const uint8_t> data) {
|
||||
}
|
||||
}
|
||||
ESP_LOGD(TAG, "Number new state : %.02f", result);
|
||||
// this->sensor_->raw_state = result;
|
||||
this->publish_state(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ void ModbusSensor::parse_and_publish(std::span<const uint8_t> data) {
|
||||
}
|
||||
}
|
||||
ESP_LOGD(TAG, "Sensor new state: %.02f", result);
|
||||
// this->sensor_->raw_state = result;
|
||||
this->publish_state(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ const LogString *state_class_to_string(StateClass state_class) {
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
Sensor::Sensor() : state(NAN), raw_state(NAN) {}
|
||||
Sensor::Sensor() : state(NAN), raw_state_(NAN) {}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
int8_t Sensor::get_accuracy_decimals() {
|
||||
@@ -66,10 +66,7 @@ StateClass Sensor::get_state_class() {
|
||||
}
|
||||
|
||||
void Sensor::publish_state(float state) {
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
this->raw_state = state;
|
||||
#pragma GCC diagnostic pop
|
||||
this->raw_state_ = state;
|
||||
#ifdef USE_SENSOR_FILTER
|
||||
this->raw_callback_.call(state);
|
||||
#endif
|
||||
|
||||
@@ -96,13 +96,8 @@ class Sensor : public EntityBase {
|
||||
|
||||
/// Getter-syntax for .state.
|
||||
float get_state() const { return this->state; }
|
||||
/// Getter-syntax for .raw_state
|
||||
float get_raw_state() const {
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
return this->raw_state;
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
/// Get the last state received by publish_state(), before any filters were applied.
|
||||
float get_raw_state() const { return this->raw_state_; }
|
||||
|
||||
/** Publish a new state to the front-end.
|
||||
*
|
||||
@@ -137,16 +132,11 @@ class Sensor : public EntityBase {
|
||||
*/
|
||||
float 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.10.0.
|
||||
ESPDEPRECATED("Use get_raw_state() instead of .raw_state. Will be removed in 2026.10.0", "2026.4.0")
|
||||
float raw_state;
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
void internal_send_state_to_frontend(float state);
|
||||
|
||||
protected:
|
||||
float raw_state_; ///< The last state passed to publish_state(), before filters.
|
||||
|
||||
#ifdef USE_SENSOR_FILTER
|
||||
LazyCallbackManager<void(float)> raw_callback_; ///< Storage for raw state callbacks.
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user