upgrade to ha-mqtt 1.3.0 and add included diagnostic sensors

This commit is contained in:
Nicu Hodos 2024-10-09 11:09:08 +02:00
parent a25746cfc9
commit 3f00d8c506
2 changed files with 8 additions and 4 deletions

View File

@ -2,6 +2,7 @@
#define MAIN_DEVICE_ID "rc-gateway"
#include "esp.h"
#include "ha.h"
using namespace Ha;
@ -40,11 +41,11 @@ namespace OilTank {
return Builder<Sensor>::instance(new Sensor{ "Depth", id })
.asDevice(device)
.withDeviceClass("distance")
.withUnitMseasure("cm")
.withUnitMeasure("cm")
.withValueTemplate("{{ value_json.sensor.value }}")
.addSecondary(
Builder<Sensor>::instance(new Sensor{ "Level", id })
.withUnitMseasure("%")
.withUnitMeasure("%")
.withValueTemplate("{{ 100 - ((value_json.sensor.value-12)|float*100/120)|round(2) }}")
.build()
)
@ -116,7 +117,10 @@ Command* commands[] = {
[](const char* msg) {
if (strcmp("PRESS", msg) == 0) ESP.restart();
}
}).asDevice(gatewayDevice).build(),
}).asDevice(gatewayDevice)
.addPreconfigured(HaESP::heapStats)
.addPreconfigured(HaESP::restartInfo)
.build(),
Builder<Button>::instance(new Button{"Front door", "doorbell_front",
[](const char* msg) {
if (strcmp("PRESS", msg) == 0) doorbell.ring("00000000110100101000100");

View File

@ -33,7 +33,7 @@ framework = arduino
lib_deps =
${env.lib_deps}
arkhipenko/TaskScheduler@^3.8.5
https://git.hodos.ro/libraries/ha-mqtt.git@^1.0.0
https://git.hodos.ro/libraries/ha-mqtt.git@^1.3.0
https://git.hodos.ro/libraries/wifi.git@^2.0.0
upload_port = 192.168.6.161
upload_protocol = espota