diff --git a/configurations/home-assistant/configuration.yaml b/configurations/home-assistant/configuration.yaml index b13f87a..014af9e 100644 --- a/configurations/home-assistant/configuration.yaml +++ b/configurations/home-assistant/configuration.yaml @@ -60,10 +60,11 @@ template: unit_of_measurement: "mm" state_class: measurement state: > - {% set sensor_offset = 2090 %} {# distance (mm) from sensor to tank bottom #} - {% set distance = states('sensor.regenput_sensor_distance') | float(0) %} - {% set height = sensor_offset - distance %} - {{ [ [height, 0] | max, sensor_offset] | min | round(1) }} + {% set mount_gap = 290 %} {# mm from sensor down to the "full" water line #} + {% set max_water_height = 2090 %} {# mm, tank depth from full line to bottom #} + {% set distance = states('sensor.cistern_distance') | float(0) %} + {% set height = max_water_height - (distance - mount_gap) %} + {{ [ [height, 0] | max, max_water_height] | min | round(1) }} - name: "Cistern Volume" unique_id: cistern_volume @@ -82,6 +83,6 @@ template: unit_of_measurement: "%" state_class: measurement state: > - {% set sensor_offset = 2090 %} {# same as above, = full tank height #} + {% set sensor_offset = 2090 - 290 %} {# full tank height - sensor_mount #} {% set height = states('sensor.cistern_water_height') | float(0) %} {{ (height / sensor_offset * 100) | round(1) }}