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) .withPrecision(0)
.withValueTemplate("{{ value_json.fragmentation }}") .withValueTemplate("{{ value_json.fragmentation }}")
.withJsonAttributes("{{ value_json.heap | tojson }}") .withJsonAttributes("{{ value_json.heap | tojson }}")
.build()); .build())
builder.addDiagnostic(Builder<Sensor>(new Sensor{ "Heap free", "heap_free" }) .addDiagnostic(Builder<Sensor>(new Sensor{ "Heap free", "heap_free" })
.withDeviceClass("data_size") .withDeviceClass("data_size")
.withUnitMeasure("B") .withUnitMeasure("B")
.withPrecision(0) .withPrecision(0)
.build() .build())
); .addDiagnostic(Builder<Sensor>(new Sensor{ "Heap max free block", "heap_max_free_block" })
builder.addDiagnostic(Builder<Sensor>(new Sensor{ "Heap max free block", "heap_max_free_block" })
.withDeviceClass("data_size") .withDeviceClass("data_size")
.withUnitMeasure("B") .withUnitMeasure("B")
.withPrecision(0) .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; activeSensors.heapStats = true;
return builder; return builder;
} }