Water sensor template (water tank) for Energy dashboard

SOLUTION:

Prerequisite:
You must have water tank with current water level in L.
slika

1: Utility Meter (https://www.home-assistant.io/integrations/utility_meter/)
Create “Utility Meter” which add consumption to your virtual sensor.

2: Create sensor with m³ unit measurement (not m3, but m³).

sensor.yaml:

  - platform: template
    sensors:
      vodostanje_povratna_voda:
        unit_of_measurement: "m³"
        device_class: water
        friendly_name: "Vodostanje (povratna voda)"
        value_template: >
          {% if states('sensor.vodostanje_skupna_poraba_vode') == 'unknown' %}
            {{ '0' | int  }}
          {% else %}
            {{ states('sensor.vodostanje_skupna_poraba_vode') | float * 0.001 }}
          {% endif %}

customize.yaml:

sensor.vodostanje_povratna_voda:
  state_class: total_increasing

CONCLUSION:

With that setting every hour you will get consumption under Energy dashboard for your water tank on which you use only level measurement on which you have consumption with L unit measurement.

slika