1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-08 08:41:59 +00:00

convert sensor to make sure it works

This commit is contained in:
J. Nick Koston
2026-01-30 21:31:17 -06:00
parent e23d295e8b
commit 69be581346
2 changed files with 2 additions and 1 deletions

View File

@@ -36,7 +36,7 @@ PROGMEM_STRING_TABLE(StateClassStrings, "", "measurement", "total_increasing", "
const LogString *state_class_to_string(StateClass state_class) {
uint8_t index = static_cast<uint8_t>(state_class);
if (index > 4)
if (index > STATE_CLASS_LAST)
index = 0; // Default to empty string (STATE_CLASS_NONE)
return StateClassStrings::get_log_str(index);
}

View File

@@ -32,6 +32,7 @@ enum StateClass : uint8_t {
STATE_CLASS_TOTAL = 3,
STATE_CLASS_MEASUREMENT_ANGLE = 4
};
constexpr uint8_t STATE_CLASS_LAST = STATE_CLASS_MEASUREMENT_ANGLE;
const LogString *state_class_to_string(StateClass state_class);