Compare commits

...
5 changed files with 8 additions and 33 deletions

No files matched your search

@@ -14,11 +14,7 @@ void BQ25186TextSensor::on_status(const BQ25186StatusRegisters &status) {
if (value == this->last_)
return;
this->last_ = value;
const ProgmemStr name = StatusStrings::get_progmem_str(this->first_ + value, StatusStrings::LAST_INDEX);
char text[32];
ESPHOME_strncpy_P(text, reinterpret_cast<ESPHOME_PGM_P>(name), sizeof(text));
text[sizeof(text) - 1] = '\0';
this->publish_state(text);
this->publish_state(StatusStrings::get_progmem_str(this->first_ + value, StatusStrings::LAST_INDEX));
}
} // namespace esphome::bq25186
@@ -287,12 +287,8 @@ void HonWaterHeater::publish_status_(const Status &status) {
if (this->heating_sensor_ != nullptr)
this->heating_sensor_->publish_state(status.heating);
if (this->mode_sensor_ != nullptr) {
char label[HonModeLabels::MAX_LENGTH + 1];
ESPHOME_strncpy_P(label,
reinterpret_cast<ESPHOME_PGM_P>(HonModeLabels::get_progmem_str(
static_cast<uint8_t>(status.mode), static_cast<uint8_t>(HonMode::HON_MODE_UNKNOWN))),
sizeof(label));
this->mode_sensor_->publish_state(label);
this->mode_sensor_->publish_state(HonModeLabels::get_progmem_str(static_cast<uint8_t>(status.mode),
static_cast<uint8_t>(HonMode::HON_MODE_UNKNOWN)));
}
this->publish_state();
}
@@ -1,7 +1,5 @@
#include "hoermann_hcp_text_sensor.h"
#include <cstring>
#include "esphome/core/log.h"
#include "esphome/core/progmem.h"
@@ -37,13 +35,7 @@ void HoermannHcpDoorStateTextSensor::update_from_state_() {
return;
this->published_ = true;
this->published_state_ = state;
char text[16];
ESPHOME_strncpy_P(text,
reinterpret_cast<ESPHOME_PGM_P>(
DoorStateStrings::get_progmem_str(static_cast<uint8_t>(state), DoorStateStrings::LAST_INDEX)),
sizeof(text));
text[sizeof(text) - 1] = '\0';
this->publish_state(text);
this->publish_state(DoorStateStrings::get_progmem_str(static_cast<uint8_t>(state), DoorStateStrings::LAST_INDEX));
}
} // namespace esphome::hoermann_hcp
@@ -12,12 +12,8 @@ PROGMEM_STRING_TABLE(FieldStatusStrings, "OK", "TOO_STRONG", "TOO_WEAK", "UNKNOW
void MT6701SPIFieldStatus::update() {
if (!this->parent_->read_encoder())
return;
char text[FieldStatusStrings::MAX_LENGTH + 1];
ESPHOME_strncpy_P(text,
reinterpret_cast<ESPHOME_PGM_P>(FieldStatusStrings::get_progmem_str(
this->parent_->get_status() & 0x03, FieldStatusStrings::LAST_INDEX)),
sizeof(text));
this->publish_state(text);
this->publish_state(
FieldStatusStrings::get_progmem_str(this->parent_->get_status() & 0x03, FieldStatusStrings::LAST_INDEX));
}
void MT6701SPIFieldStatus::dump_config() {
+2 -7
View File
@@ -334,13 +334,8 @@ bool TMP102Component::set_limit_temperature_(TMP102LimitType limit, float temper
void TMP102Component::publish_threshold_status_(uint8_t status) {
if (this->threshold_status_text_sensor_ == nullptr)
return;
char text[40];
ESPHOME_strncpy_P(
text,
reinterpret_cast<ESPHOME_PGM_P>(ThresholdStatusStrings::get_progmem_str(status, TMP102_THRESHOLD_STATUS_OK)),
sizeof(text));
text[sizeof(text) - 1] = '\0';
this->threshold_status_text_sensor_->publish_state(text);
this->threshold_status_text_sensor_->publish_state(
ThresholdStatusStrings::get_progmem_str(status, TMP102_THRESHOLD_STATUS_OK));
}
void TMP102Component::publish_threshold_rejection_(bool high, float value, float other) {