add pre-configured button for updating the heap statistics

This commit is contained in:
Nicu Hodos 2025-10-08 14:32:49 +02:00
parent a23bf27c50
commit 98fbf2a55e

View File

@ -47,19 +47,24 @@ namespace HaESP {
.withPrecision(0)
.withValueTemplate("{{ value_json.fragmentation }}")
.withJsonAttributes("{{ value_json.heap | tojson }}")
.build());
builder.addDiagnostic(Builder<Sensor>(new Sensor{ "Heap free", "heap_free" })
.build())
.addDiagnostic(Builder<Sensor>(new Sensor{ "Heap free", "heap_free" })
.withDeviceClass("data_size")
.withUnitMeasure("B")
.withPrecision(0)
.build()
);
builder.addDiagnostic(Builder<Sensor>(new Sensor{ "Heap max free block", "heap_max_free_block" })
.build())
.addDiagnostic(Builder<Sensor>(new Sensor{ "Heap max free block", "heap_max_free_block" })
.withDeviceClass("data_size")
.withUnitMeasure("B")
.withPrecision(0)
.build()
);
.build())
.addSecondary(new Button{"Update heap stats", "update_heap_stats",
[](const char* msg) {
if ((strcmp("PRESS", msg) == 0) && tHeap.isEnabled()) {
tHeap.cancel();
tHeap.restart();
}}});
activeSensors.heapStats = true;
return builder;
}