From 6edcafe27c2bfa45a67e2bdd6a71e2d4546e7fe5 Mon Sep 17 00:00:00 2001 From: Nicu Hodos Date: Fri, 3 Oct 2025 10:24:33 +0200 Subject: [PATCH] adjust battery percent formula: max 3.3V and min 2.7V (the minimum voltage required by ATTiny85) --- include/devices.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/devices.h b/include/devices.h index bb2068c..35acd0c 100644 --- a/include/devices.h +++ b/include/devices.h @@ -58,7 +58,7 @@ auto presenceTracker = Builder::instance(PRESENCE_SENSOR) .withParent(gatewayDevice)) .withValueTemplate("{{ value_json.sensor.state }}") .addDiagnostic(new VoltageSensor{PRESENCE_SENSOR, "Battery voltage", "{{ value_json.sensor.diagnostic.voltage }}"}) - .addDiagnostic(new BatterySensor{PRESENCE_SENSOR, "Battery level", "{{ ((value_json.sensor.diagnostic.voltage|float-2.5)|round(2)*100/2)|int }}"}) + .addDiagnostic(new BatterySensor{PRESENCE_SENSOR, "Battery level", "{{ ((value_json.sensor.diagnostic.voltage|float-2.7)|round(2)*100/0.6)|int }}"}) .withOffDelaySeconds(5*60) .withDeviceClass("presence") .build();