add restart reason sensor
This commit is contained in:
parent
f1901a1b53
commit
6468db5565
11
src/esp.h
11
src/esp.h
@ -12,6 +12,10 @@ namespace HaESP {
|
|||||||
Sensor::mapSensors["heap_max_free_block"]->updateState(to_string(ESP.getMaxFreeBlockSize()).c_str());
|
Sensor::mapSensors["heap_max_free_block"]->updateState(to_string(ESP.getMaxFreeBlockSize()).c_str());
|
||||||
}, &ts);
|
}, &ts);
|
||||||
|
|
||||||
|
Task tRestartInfo(TASK_IMMEDIATE, TASK_ONCE, [](){
|
||||||
|
Sensor::mapSensors["restart_reason"]->updateState(ESP.getResetReason().c_str());
|
||||||
|
}, &ts);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
Builder<T>& heapStats(Builder<T>& builder) {
|
Builder<T>& heapStats(Builder<T>& builder) {
|
||||||
builder.addDiagnostic(Builder<Sensor>::instance(new Sensor{ "Heap fragmentation", "heap_fragmentation" })
|
builder.addDiagnostic(Builder<Sensor>::instance(new Sensor{ "Heap fragmentation", "heap_fragmentation" })
|
||||||
@ -33,4 +37,11 @@ namespace HaESP {
|
|||||||
tHeap.enable();
|
tHeap.enable();
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
Builder<T>& restartInfo(Builder<T>& builder) {
|
||||||
|
builder.addDiagnostic(Builder<Sensor>::instance((new Sensor{"Restart reason", "restart_reason"})).build());
|
||||||
|
tRestartInfo.enable();
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user