Adopt to StrinfRef changes in entity_base.h

This commit is contained in:
j0ta29 2023-04-01 10:35:12 +00:00 committed by root
parent 596362a99f
commit 3330272070
9 changed files with 10 additions and 9 deletions

View file

@ -23,7 +23,7 @@ class OptolinkBinarySensor : public OptolinkSensorBase,
void setup() override { setup_datapoint_(); }
void update() override { optolink_->read_value(datapoint_); }
const std::string &get_sensor_name() override { return get_name(); }
const StringRef &get_sensor_name() override { return get_name(); }
void value_changed(float state) override { publish_state(state); };
};
} // namespace optolink

View file

@ -14,7 +14,7 @@ class OptolinkDeviceInfoSensor : public esphome::text_sensor::TextSensor, public
public:
OptolinkDeviceInfoSensor(const std::string &name, Optolink *optolink) {
optolink_ = optolink;
set_name(name);
set_name(name.c_str());
set_update_interval(1800000);
set_entity_category(esphome::ENTITY_CATEGORY_DIAGNOSTIC);
}

View file

@ -18,7 +18,7 @@ class OptolinkNumber : public OptolinkSensorBase, public esphome::number::Number
void setup() override { setup_datapoint_(); }
void update() override { optolink_->read_value(datapoint_); }
const std::string &get_sensor_name() override { return get_name(); }
const StringRef &get_sensor_name() override { return get_name(); }
void value_changed(float state) override { publish_state(state); };
void control(float value) override;

View file

@ -28,7 +28,7 @@ class OptolinkSelect : public OptolinkSensorBase, public esphome::select::Select
void setup() override { setup_datapoint_(); }
void update() override { optolink_->read_value(datapoint_); }
const std::string &get_sensor_name() override { return get_name(); }
const StringRef &get_sensor_name() override { return get_name(); }
void value_changed(float state) override;
void control(const std::string &value) override;

View file

@ -20,7 +20,7 @@ class OptolinkSensor : public OptolinkSensorBase, public esphome::sensor::Sensor
void setup() { setup_datapoint_(); }
void update() override { optolink_->read_value(datapoint_); }
const std::string &get_sensor_name() override { return get_name(); }
const StringRef &get_sensor_name() override { return get_name(); }
void value_changed(float state) override { publish_state(state); };
};
} // namespace optolink

View file

@ -3,6 +3,7 @@
#ifdef USE_ARDUINO
#include "esphome/core/log.h"
#include "esphome/core/string_ref.h"
#include "VitoWiFi.h"
namespace esphome {
@ -33,7 +34,7 @@ class OptolinkSensorBase {
void set_div_ratio(int div_ratio) { div_ratio_ = div_ratio; }
protected:
virtual const std::string &get_sensor_name() = 0;
virtual const StringRef &get_sensor_name() = 0;
virtual void value_changed(float state) = 0;
};

View file

@ -14,7 +14,7 @@ class OptolinkStateSensor : public esphome::text_sensor::TextSensor, public esph
public:
OptolinkStateSensor(std::string name, Optolink *optolink) {
optolink_ = optolink;
set_name(name);
set_name(name.c_str());
set_update_interval(1000);
set_entity_category(esphome::ENTITY_CATEGORY_DIAGNOSTIC);
}

View file

@ -21,7 +21,7 @@ class OptolinkSwitch : public OptolinkSensorBase, public esphome::switch_::Switc
void setup() override { setup_datapoint_(); }
void update() override { optolink_->read_value(datapoint_); }
const std::string &get_sensor_name() override { return get_name(); }
const StringRef &get_sensor_name() override { return get_name(); }
void value_changed(float state) override { publish_state(state); };
void write_state(bool value) override;

View file

@ -22,7 +22,7 @@ class OptolinkTextSensor : public OptolinkSensorBase,
void setup() override;
void update() override { optolink_->read_value(datapoint_); }
const std::string &get_sensor_name() override { return get_name(); }
const StringRef &get_sensor_name() override { return get_name(); }
void value_changed(float state) override { publish_state(std::to_string(state)); };
private: