mirror of
https://github.com/esphome/esphome.git
synced 2026-10-14 10:12:52 +00:00
[micronova] Keep the stove state table in flash
This commit is contained in:
@@ -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) {}
|
||||
|
||||
Reference in New Issue
Block a user