1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-16 10:12:21 +01:00

Merge remote-tracking branch 'upstream/has_state_' into integration

This commit is contained in:
J. Nick Koston
2025-06-14 17:32:40 -05:00
25 changed files with 258 additions and 86 deletions

View File

@@ -93,13 +93,12 @@ float Sensor::get_raw_state() const { return this->raw_state; }
std::string Sensor::unique_id() { return ""; }
void Sensor::internal_send_state_to_frontend(float state) {
this->has_state_ = true;
this->set_has_state(true);
this->state = state;
ESP_LOGD(TAG, "'%s': Sending state %.5f %s with %d decimals of accuracy", this->get_name().c_str(), state,
this->get_unit_of_measurement().c_str(), this->get_accuracy_decimals());
this->callback_.call(state);
}
bool Sensor::has_state() const { return this->has_state_; }
} // namespace sensor
} // namespace esphome

View File

@@ -141,9 +141,6 @@ class Sensor : public EntityBase, public EntityBase_DeviceClass, public EntityBa
*/
float raw_state;
/// Return whether this sensor has gotten a full state (that passed through all filters) yet.
bool has_state() const;
/** 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).
@@ -161,7 +158,6 @@ class Sensor : public EntityBase, public EntityBase_DeviceClass, public EntityBa
optional<int8_t> accuracy_decimals_; ///< Accuracy in decimals override
optional<StateClass> state_class_{STATE_CLASS_NONE}; ///< State class override
bool force_update_{false}; ///< Force update mode
bool has_state_{false};
};
} // namespace sensor