make min, max & step optional

This commit is contained in:
Nicu Hodos 2024-10-28 08:50:00 +01:00
parent 3a374bf685
commit 47a5bfc81c

View File

@ -196,6 +196,21 @@ namespace Ha {
return *this;
}
Builder& withMin(unsigned int value) {
cmp->min = value;
return *this;
}
Builder& withMax(unsigned int value) {
cmp->max = value;
return *this;
}
Builder& withStep(unsigned int value) {
cmp->step = value;
return *this;
}
Builder& overrideConfig(const char* key, bool value) {
cmp->jsonBooleans.add({key, value});
return *this;
@ -334,8 +349,7 @@ namespace Ha {
struct Number : StatefulCommand {
unsigned int min, max, step;
Number(const char* name, const char* id, unsigned int min, unsigned int max, unsigned int step, onMessage f)
: StatefulCommand(name, id, "number", f), min(min), max(max), step(step) {}
Number(const char* name, const char* id, onMessage f) : StatefulCommand(name, id, "number", f) {}
void updateState(unsigned int value) {
StateConfig::updateState(to_string(value).c_str());