ESPHome Water meter: convert liter/min to liters per day

Hi,

I have build a Water Meter based on a Wemos D1 mini and have integrated it in Home Assistant via the ESPHome Add-on and integration. It measures and displays the Pulses per minute. As every pulse is exactly one liter, it currently displays the Liters per minute in Lovelace. However I would like to display the total amount of liters per day. I have spend multiple days to find a solution, however I am not able to find a workable solution on the internet. Can you please help me? Thanks in advance.

My current ESP Home config:

esphome:
  name: watermeter
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: "XYZ"
  password: "XYZPass"
  manual_ip:
    # Set this to the IP of the ESP
    static_ip: 192.168.3.6
    # Set this to the IP address of the router. Often ends with .1
    gateway: 192.168.3.1
    # The subnet of the network. 255.255.255.0 works for most home networks.
    subnet: 255.255.255.0
    
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Watermeter Fallback Hotspot"
    password: "xYyJLmQ7UcbO"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "watermeter"

ota:
  password: "watermeter"
  
sensor:
  - platform: pulse_counter
    pin: 14
    name: "Water Meter"
    update_interval : 60s
    accuracy_decimals: 0
1 Like

Have you tried a integral sensor in home assistant? Seems like the thing you need

1 Like

You could do it in home assistant with the utility meter on a daily cycle.

Though you just want a litres total (not litres per whatever) for this. I.e. just the plain pulse count.

3 Likes

Hi Daan, thanks for your help!

Hi Tom, I have implemented the Utility Meter in Home Assistant and it works like a charm! I have spend a lot of hours to build this functionality in ESPHome. However, I didn’t know that Home Assistant was also able to deliver this functionality. Thanks for your help!

1 Like

Would you mind sharing the hardware which creates the pulse to measure the water consumption?

Hi Ralf, please find attached the schemes and pictures. I use a Wemos D1 Mini in combination with a LJ12A3-4-Z-BX-Inductieve-Proximity-Sensor.

3 Likes

Hi Corne,

Would you be so kind to share your yaml file?
I have build the same watermeter but stuck on the utility_meter setup.

Thanks for sharing.

Greets
Bastiaan

(tagging @cmartens who wouldn’t necessarily see your message)

Another possibility is to use ESPHome’s total_daily_energy sensor and just lie about the units. I do this with my electricity metering: I have a pulse_counter counting the flashes on the meter (1 flash = 1Wh) and a total_daily_energy integrating the pulses:

sensor:
  - platform: pulse_counter
    pin: D5
    unit_of_measurement: 'kW'
    name: 'Power Meter House'
    filters:
      - multiply: 0.06
    id: house_power

  - platform: total_daily_energy
    name: "Total Daily Energy"
    power_id: house_power
    accuracy_decimals: 1

giving this instant meter (electric shower being used atm!) and 7-day barchart (custom:mini-graph-card):

image

Hi Troon,
Thanks for your response.
I am a newbie and mu problem is that I want to add “utility_meter” to my watermeter. I want to see daily-monthly water usage.
My watermeter.yaml is saying " Component not found: utility_meter
Nothing found on Google so far.
(btw how can I show my yaml. file?

Just copy-paste it in a response here, surrounded by three backticks (```) before and after.

You are aware that utility_meter is a Home Assistant integration, not an ESPHome component?

no I didn’t know. every day learning new things!

1 Like

Hi Bastiaan,

I hereby send you the part of my config file regarding the utility meter. The ESPHome pulse counter measures the number of pulses per second. As every pulse is exactly 1 liter, it measures liters per second. To convert this to liters per day, the utility meter can be used. Add the following code to configuration.yaml:

utility_meter:
  water_daily:
    source: sensor.water_per_second
    cycle: daily

After a restart of Home Assistant, the entity “sensor.water_daily” will be added to Home Assistant, which can be added to Lovelace. I hope this will help you.

Greetings, Corne

You can also considerably simplify that schematic by enabling the ESP internal GPIO pull-up resistor:

8deabfa3ae5328f980847a3774b99c756f49ee76_2_642x500

Hi Corne,

I had trouble with the utility_meter because it should not be in the esphome file but in the configuration yaml.file . But now in your file I can see also the set-up for more than one sensor reading. I have made water_hourly / water_daily / water_monthly / water_yearly

Thanks for sharing!

Bastiaan

1 Like

Hi Corne,
Thanks for your help, the job is fantastic. I now see how much water I use per hour. Just a few more questions:

  • with me the wheel was hanging exactly under the meter so that it continued to count, thereby adding an amount of “unreal used” liters, do you have experience / solution with this?

-how can I get the counters to zero? Searched the internet and came across a code against “reset values utility_meter” but I can’t get it done. Maybe you want to give a small addition to your yaml.code At least I assume that you reset your counting after a day.

utility_meter:
  water_hourly:
    source: sensor.watermeter
    cycle: hourly
  water_daily:
    source: sensor.watermeter
    cycle: daily
  water_monthly:
    source: sensor.watermeter
    cycle: monthly
  water_yearly:
    source: sensor.watermeter
    cycle: yearly

Kind regards

Bastiaan

Hi,

Based on the defined cycle, the meter will be reset every hour, day, month, etc. In the example which I have send to you, the watermeter is reset every day at 0:00h. Please see the photo below how I mounted the meter. It is important to place it exactly above the wheel so that ever liter is counted once.

1 Like

Hallo Corne,

Thank you for your response. Clearly answer, I have to center my sensor above the wheel. And all my sensors will be set to zero when the time is ready.

Thanks again
Bastiaan

Hallo Corne,

I Have mounted the sensor exactly above the wheel but now my values are very strange. This hour I flush toilet once and the sensor output is 140 ltr. Little bit too much.
Do you have any tips so I can count a realistic amount?

Your sincerely,

Bastiaan

What you need to check if you flush the toilet, is to have a look at the wheel and count the number of times that the wheel was going round. For every round, the LED on the sensor should be on just one time. So 7 times for one flush, when 7 liter of water is used. If this is not the case, you have to re-mount the sensor in such a way that with one round, the sensor is measuring only one signal. So it is important not to mount the sensor exactly above the wheel.