15 virtual bool save(
const std::string &value) {
return true; }
17 virtual void setup(uint32_t
id, std::string &value) {}
26 bool save(
const std::string &value)
override {
27 int diff = value.compare(this->
prev_);
31 int size = value.size();
34 unsigned char temp[SZ + 1];
35 memcpy(temp + 1, value.c_str(), size);
37 temp[0] = ((
unsigned char) size);
39 this->
prev_.assign(value);
48 void setup(uint32_t
id, std::string &value)
override {
55 value.assign(temp + 1, (
size_t) temp[0]);
58 this->
prev_.assign(value);
66 void setup()
override;
67 void update()
override;
68 void dump_config()
override;
73 void set_initial_value(
const std::string &initial_value) { this->initial_value_ = initial_value; }
77 void control(
const std::string &value)
override;
78 bool optimistic_ =
false;
void setup(uint32_t id, std::string &value) override
Trigger< std::string > * get_set_trigger() const
virtual void setup(uint32_t id, std::string &value)
T id(T value)
Helper function to make id(var) known from lambdas work in custom components.
This class simplifies creating components that periodically check a state.
Base-class for all text inputs.
void set_initial_value(const std::string &initial_value)
ESPPreferenceObject pref_
void set_value_saver(TemplateTextSaverBase *restore_value_saver)
ESPPreferences * global_preferences
float get_setup_priority() const override
virtual bool save(const std::string &value)
void set_optimistic(bool optimistic)
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
virtual ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash)=0
void set_template(std::function< optional< std::string >()> &&f)
std::string initial_value_
Implementation of SPI Controller mode.
bool save(const std::string &value) override