add long term statistics for oil level and depth

This commit is contained in:
Nicu Hodos 2025-06-07 10:42:44 +02:00
parent 0a7554d843
commit ff53fa9831
2 changed files with 3 additions and 1 deletions

View File

@ -41,12 +41,14 @@ namespace OilTank {
return Builder<Sensor>::instance(new Sensor{ "Level", id }) return Builder<Sensor>::instance(new Sensor{ "Level", id })
.asDevice(device) .asDevice(device)
.withUnitMeasure("%") .withUnitMeasure("%")
.withSensorStateClass(MEASUREMENT)
.withIcon("mdi:hydraulic-oil-level") .withIcon("mdi:hydraulic-oil-level")
.withValueTemplate("{{ 100 - ((value_json.sensor.value-12)|float*100/120)|round(2) }}") .withValueTemplate("{{ 100 - ((value_json.sensor.value-12)|float*100/120)|round(2) }}")
.addSecondary( .addSecondary(
Builder<Sensor>::instance(new Sensor{ "Depth", id }) Builder<Sensor>::instance(new Sensor{ "Depth", id })
.withDeviceClass("distance") .withDeviceClass("distance")
.withUnitMeasure("cm") .withUnitMeasure("cm")
.withSensorStateClass(MEASUREMENT)
.withValueTemplate("{{ value_json.sensor.value }}") .withValueTemplate("{{ value_json.sensor.value }}")
.build() .build()
) )

View File

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