mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 17:27:59 +01:00
Adopt to StrinfRef changes in entity_base.h
This commit is contained in:
parent
596362a99f
commit
3330272070
9 changed files with 10 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue