From 9c2917e8ec46756b21e0f5374e7ce2e771b27a6b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 17 Jan 2026 14:15:29 -1000 Subject: [PATCH] [pipsolar] Store command strings in flash --- .../components/pipsolar/switch/pipsolar_switch.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/esphome/components/pipsolar/switch/pipsolar_switch.h b/esphome/components/pipsolar/switch/pipsolar_switch.h index 11ff6c853a..bb62d4794a 100644 --- a/esphome/components/pipsolar/switch/pipsolar_switch.h +++ b/esphome/components/pipsolar/switch/pipsolar_switch.h @@ -9,15 +9,18 @@ namespace pipsolar { class Pipsolar; class PipsolarSwitch : public switch_::Switch, public Component { public: - void set_parent(Pipsolar *parent) { this->parent_ = parent; }; - void set_on_command(const std::string &command) { this->on_command_ = command; }; - void set_off_command(const std::string &command) { this->off_command_ = command; }; + void set_parent(Pipsolar *parent) { this->parent_ = parent; } + void set_on_command(const char *command) { this->on_command_ = command; } + void set_off_command(const char *command) { this->off_command_ = command; } + /// Prevent accidental use of std::string which would dangle + void set_on_command(const std::string &command) = delete; + void set_off_command(const std::string &command) = delete; void dump_config() override; protected: void write_state(bool state) override; - std::string on_command_; - std::string off_command_; + const char *on_command_{nullptr}; + const char *off_command_{nullptr}; Pipsolar *parent_; };