diff --git a/src/esp.h b/src/esp.h index 9b78bdb..a438d5c 100644 --- a/src/esp.h +++ b/src/esp.h @@ -47,19 +47,24 @@ namespace HaESP { .withPrecision(0) .withValueTemplate("{{ value_json.fragmentation }}") .withJsonAttributes("{{ value_json.heap | tojson }}") - .build()); - builder.addDiagnostic(Builder(new Sensor{ "Heap free", "heap_free" }) + .build()) + .addDiagnostic(Builder(new Sensor{ "Heap free", "heap_free" }) .withDeviceClass("data_size") .withUnitMeasure("B") .withPrecision(0) - .build() - ); - builder.addDiagnostic(Builder(new Sensor{ "Heap max free block", "heap_max_free_block" }) + .build()) + .addDiagnostic(Builder(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; }