diff --git a/esphome/components/text_sensor/filter.cpp b/esphome/components/text_sensor/filter.cpp index a6d0ae0c93..52c2bd394e 100644 --- a/esphome/components/text_sensor/filter.cpp +++ b/esphome/components/text_sensor/filter.cpp @@ -62,7 +62,10 @@ optional AppendFilter::new_value(std::string value) { } // Prepend -optional PrependFilter::new_value(std::string value) { return this->prefix_ + value; } +optional PrependFilter::new_value(std::string value) { + value.insert(0, this->prefix_.c_str(), this->prefix_.size()); + return value; +} // Substitute SubstituteFilter::SubstituteFilter(const std::initializer_list &substitutions)