1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-11 15:52:20 +01:00

Drop deprecated entity property base methods (#4539)

This commit is contained in:
Oxan van Leeuwen
2023-03-09 01:08:45 +01:00
committed by GitHub
parent afc1c83af4
commit ba1416cc0e
6 changed files with 7 additions and 68 deletions

View File

@@ -41,16 +41,13 @@ void BinarySensor::send_state_internal(bool state, bool is_initial) {
this->state_callback_.call(state);
}
}
std::string BinarySensor::device_class() { return ""; }
BinarySensor::BinarySensor() : state(false) {}
void BinarySensor::set_device_class(const std::string &device_class) { this->device_class_ = device_class; }
std::string BinarySensor::get_device_class() {
if (this->device_class_.has_value())
return *this->device_class_;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
return this->device_class();
#pragma GCC diagnostic pop
return "";
}
void BinarySensor::add_filter(Filter *filter) {
filter->parent_ = this;

View File

@@ -80,14 +80,6 @@ class BinarySensor : public EntityBase {
virtual bool is_status_binary_sensor() const;
// ========== OVERRIDE METHODS ==========
// (You'll only need this when creating your own custom binary sensor)
/** Override this to set the default device class.
*
* @deprecated This method is deprecated, set the property during config validation instead. (2022.1)
*/
virtual std::string device_class();
protected:
CallbackManager<void(bool)> state_callback_{};
optional<std::string> device_class_{}; ///< Stores the override of the device class