add support for precondfigured components - heap stats
This commit is contained in:
parent
7327533b24
commit
f1901a1b53
36
src/esp.h
Normal file
36
src/esp.h
Normal file
@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include "TaskScheduler.h"
|
||||
#include "ha.h"
|
||||
|
||||
using namespace Ha;
|
||||
|
||||
namespace HaESP {
|
||||
Task tHeap(1 * TASK_MINUTE, TASK_FOREVER, []() {
|
||||
Sensor::mapSensors["heap_fragmentation"]->updateState(to_string(ESP.getHeapFragmentation()).c_str());
|
||||
Sensor::mapSensors["heap_free"]->updateState(to_string(ESP.getFreeHeap()).c_str());
|
||||
Sensor::mapSensors["heap_max_free_block"]->updateState(to_string(ESP.getMaxFreeBlockSize()).c_str());
|
||||
}, &ts);
|
||||
|
||||
template <class T>
|
||||
Builder<T>& heapStats(Builder<T>& builder) {
|
||||
builder.addDiagnostic(Builder<Sensor>::instance(new Sensor{ "Heap fragmentation", "heap_fragmentation" })
|
||||
.withUnitMeasure("%")
|
||||
.withPrecision(0)
|
||||
.build());
|
||||
builder.addDiagnostic(Builder<Sensor>::instance(new Sensor{ "Heap free", "heap_free" })
|
||||
.withDeviceClass("data_size")
|
||||
.withUnitMeasure("B")
|
||||
.withPrecision(0)
|
||||
.build()
|
||||
);
|
||||
builder.addDiagnostic(Builder<Sensor>::instance(new Sensor{ "Heap max free block", "heap_max_free_block" })
|
||||
.withDeviceClass("data_size")
|
||||
.withUnitMeasure("B")
|
||||
.withPrecision(0)
|
||||
.build()
|
||||
);
|
||||
tHeap.enable();
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user