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

make sure cover works

This commit is contained in:
J. Nick Koston
2026-01-30 22:02:57 -06:00
parent 726c5daa74
commit b298837276
3 changed files with 11 additions and 10 deletions

View File

@@ -22,17 +22,14 @@ const LogString *cover_command_to_str(float pos) {
return LOG_STR("UNKNOWN");
}
}
// Cover operation strings indexed by CoverOperation enum (0-2): IDLE, OPENING, CLOSING, plus UNKNOWN
PROGMEM_STRING_TABLE(CoverOperationStrings, "IDLE", "OPENING", "CLOSING", "UNKNOWN");
const LogString *cover_operation_to_str(CoverOperation op) {
switch (op) {
case COVER_OPERATION_IDLE:
return LOG_STR("IDLE");
case COVER_OPERATION_OPENING:
return LOG_STR("OPENING");
case COVER_OPERATION_CLOSING:
return LOG_STR("CLOSING");
default:
return LOG_STR("UNKNOWN");
}
uint8_t index = static_cast<uint8_t>(op);
if (index > COVER_OPERATION_LAST)
index = COVER_OPERATION_UNKNOWN_INDEX;
return CoverOperationStrings::get_log_str(index);
}
Cover::Cover() : position{COVER_OPEN} {}

View File

@@ -84,6 +84,8 @@ enum CoverOperation : uint8_t {
/// The cover is currently closing.
COVER_OPERATION_CLOSING,
};
constexpr uint8_t COVER_OPERATION_LAST = static_cast<uint8_t>(COVER_OPERATION_CLOSING);
constexpr uint8_t COVER_OPERATION_UNKNOWN_INDEX = COVER_OPERATION_LAST + 1;
const LogString *cover_operation_to_str(CoverOperation op);

View File

@@ -79,6 +79,8 @@ enum ValveOperation : uint8_t {
/// The valve is currently closing.
VALVE_OPERATION_CLOSING,
};
constexpr uint8_t VALVE_OPERATION_LAST = static_cast<uint8_t>(VALVE_OPERATION_CLOSING);
constexpr uint8_t VALVE_OPERATION_UNKNOWN_INDEX = VALVE_OPERATION_LAST + 1;
const LogString *valve_operation_to_str(ValveOperation op);