Measure water consumption for different sources

Overview
I wanted to know where in my household I use my water. My approach does not measure the entire consumption, but only takes into account sources that I was able to measure.
In the end, I wanted to display my measurements in the energy dashboard.
For my setup, I differentiated between time-based consumption and consumption per use.

Examples of time-based consumption:

  • Shower (motion sensor)
  • Irrigation (valve open / closed)

Examples of consumption per use:

  • Toilet flush (Aqara motion sensor)
  • Dishwasher
  • Washing machine

Time based consumption

  1. Set up a template sensor for the flow ot the water. Example for my shower:
  template:
    - sensor:
         - name: "Shower Flow"
           unit_of_measurement: "L/min"
           state: >
             {% if is_state('input_boolean.shower', 'on')%}11 #uses 11 L/min
             {% else %}0
             {% endif %}
           state_class: measurement
  1. Set up an Integral (Riemann sum), based on the template sensor.
    The unit_time (here min) has to correspond to the unit_of_measurement (here L/min) of your source sensor.
    sensor:
      - platform: integration
        source: sensor.shower_flow
        name: Shower Consumption
        unit_time: min
        method: left
  1. For the sensor sensor.shower_consumption to show up in the energy dashboard as water, the device class must be set to water. The GUI for the Integral setup does not allow for device class modification (rel. 2025.5). You have to customize the device class in your configuration.yaml, using:
    homeassistant:
      customize:
        sensor.shower_consumption:
          device_class: "water"

Per use consumption
Example: Washing machine using 50 L per run

  1. Set up a counter (counter.washing_machine)
  2. Set up an automation to increment the counter:
  triggers:
    - trigger: state
      entity_id:
        - input_boolean.washing_machine_running
      to: "on"
  actions:
    - action: counter.increment
      target:
        entity_id: counter.washing_machine
  1. Set up a template sensor for the water consumption
template:
  - sensor:
       - name: "Washing machine consumption"
         unit_of_measurement: "L"
         state: >
           {% if has_value('counter.washing_machine') %}
           {{states('counter.washing_machine')|int*50}}
           {% endif%}
         state_class: total_increasing
         device_class: water #to show up in the energy dashboard

Pardon me for being blunt, but I don’t see a clear question