add support of unitMeasure for Numbers

This commit is contained in:
Nicu Hodos 2025-03-26 13:37:38 +01:00
parent 4037ede011
commit 94ff72aefc

View File

@ -245,6 +245,7 @@ namespace Ha {
unsigned int min = 1;
unsigned int max = 100;
unsigned int step = 1;
const char* unitMeasure = nullptr;
Number(const char* name, const char* id, onMessage f) : Component(id, name, "number"), StatefulCommand(this, f) {}
@ -258,6 +259,7 @@ namespace Ha {
jsonDoc["min"] = min;
jsonDoc["max"] = max;
jsonDoc["step"] = step;
if (unitMeasure) jsonDoc["unit_of_measurement"] = unitMeasure;
}
};