[micronova] Keep the stove state table in flash

This commit is contained in:
J. Nick Koston
2026-10-13 09:56:21 -10:00
parent 918b7d2553
commit 43e0a18d41
2 changed files with 11 additions and 13 deletions
@@ -1,9 +1,13 @@
#include "micronova_text_sensor.h"
#include "esphome/core/progmem.h"
namespace esphome::micronova {
ESPHOME_LOG_TAG(TAG, "micronova.text_sensor");
PROGMEM_STRING_TABLE(StoveStateStrings, "Off", "Start", "Pellets loading", "Ignition", "Working", "Brazier Cleaning",
"Final Cleaning", "Standby", "No pellets alarm", "No ignition alarm", "Undefined alarm");
void MicroNovaTextSensor::dump_config() {
LOG_TEXT_SENSOR("", "Micronova text sensor", this);
this->dump_base_config();
@@ -15,7 +19,13 @@ void MicroNovaTextSensor::process_value_from_stove(int value_from_stove) {
return;
}
this->publish_state(STOVE_STATES[value_from_stove]);
// Values past the table read as "Undefined alarm"
const ProgmemStr name =
StoveStateStrings::get_progmem_str(static_cast<uint8_t>(value_from_stove), StoveStateStrings::LAST_INDEX);
char text[20];
ESPHOME_strncpy_P(text, reinterpret_cast<ESPHOME_PGM_P>(name), sizeof(text));
text[sizeof(text) - 1] = '\0';
this->publish_state(text);
}
} // namespace esphome::micronova
@@ -5,18 +5,6 @@
namespace esphome::micronova {
static const char *const STOVE_STATES[11] = {"Off",
"Start",
"Pellets loading",
"Ignition",
"Working",
"Brazier Cleaning",
"Final Cleaning",
"Standby",
"No pellets alarm",
"No ignition alarm",
"Undefined alarm"};
class MicroNovaTextSensor final : public text_sensor::TextSensor, public MicroNovaListener {
public:
MicroNovaTextSensor(MicroNova *m) : MicroNovaListener(m) {}