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

Deprecate virtual methods to set entity properties (#3021)

This commit is contained in:
Oxan van Leeuwen
2022-01-10 13:32:39 +01:00
committed by GitHub
parent 41bcc8c0f4
commit 073828235f
12 changed files with 76 additions and 32 deletions

View File

@@ -48,7 +48,10 @@ void BinarySensor::set_device_class(const std::string &device_class) { this->dev
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
}
void BinarySensor::add_filter(Filter *filter) {
filter->parent_ = this;

View File

@@ -75,6 +75,7 @@ class BinarySensor : public EntityBase {
// ========== OVERRIDE METHODS ==========
// (You'll only need this when creating your own custom binary sensor)
/// Get the default device class for this sensor, or empty string for no default.
ESPDEPRECATED("device_class() is deprecated, set property during config validation instead.", "2022.01")
virtual std::string device_class();
protected: