Water-meter Sensor, help configuring it

Hey everyone,
I have set up my home assistant and installed a (hall effect) water-meter sensor to my house’s main water pipe.
I managed to make the sensor work with HASS with the following code:

  - platform: statistics
    entity_id: binary_sensor.Watermeter
    name: watermeter

(this is in my sensor.yaml file)
And this:

  - platform: rpi_gpio
    ports:
      5: #Watermeter

(in my binary_sensors.yaml file)

Both files are called in the configuration.yaml file.

This configuration enables the sensor icon, which adds up the pulses of the water meter and displays them into my front end.

Why i need your help and guidance:

  1. I need two separate counters, one to live display the current consumption rate, and one that would reset every day at XX time
  2. I need a way to turn pulses into Liters, which means i would need the displayed amount to be substracted by xxx ( i think in my case is 225) in order to have an understandable indication.
  3. i would love to have all those numbers show up (they dont currently) in my History tab, and be able to have statistics (select date like in the picture below) or even be able to set the time frame and have a report of the total consumption between those two dates.

Here is what i have set up right now with temperature and my Electricity consumption (the two upper graphs) and i would like water consumption to be displayed this way, with the added features above (if possible)

Edit (additional info): When setting up the sensor with the statistics platform, it seems to be keeping my system very busy (the sensor would add pulses to the total constantly - which is normal as it should increase about 230 pulses per liter consumed). Is there any way to achieve the aforementioned targets while keeping the system usage as low as possible?

Any help or reading material would be very helpful,
Regards,
K

what sensor are you using? (make/model)

1 Like

Presume you have something like this? Appears to be a simple calculation for Litres, and that site provides Arduino code.
Re stats checkout the stats sensor, and for the time window query checkout influxdb sensor.
I’m interested to know how you are monitoring electricity consumption too?
Cheers

1 Like

Hey @robmarkcole thanks for the info,
I’ll check out the documentation you linked and come back with questions if any :slight_smile:
The water meter is something similar to the one you pasted, I’ll come back with the exact model when I’m home.
As for energy consumption I am using the Efergy monitoring hub, with the respective code to integrate it to Hass. (I’ll be happy to provide further info if you want)
Thanks again.

Edit: fs400a-g1 is the model, and here is a link https://www.robotics.org.za/FS400A-G1

1 Like

I am using something like @robmarkcole linked, I’ll check the exact model and let you know once I’m home.

Edit: fs400a-g1 is the model, and here is a link https://www.robotics.org.za/FS400A-G1

Ok this 6 quid sensor flow sensor was easy enough to setup using the script on here.

Looks a lot like the one i have, how do you set it up to work with HA if its directly plugged to a Raspberry pi though? The code is for arduino.

You will have to find or write a pi compatible library or read from the adruino over the serial (USB).
Alternatively just use MQTT post from the arduino, or use the arduino component

I can already read the sensor data inside HA.
What i want is to manipulate it, in order to change the unit from pulses to liters and have it showing up like the temperature and other sensors (i have a link in my OP).
Any ideas?

The arduino code sums the number of pulses in a second (pulses_in_a_second )then calculates the hourly flow in litres from:

hourly_litres = pulses_in_a_second * 60 / 7.5

I would personally use a python_script to do the timing/summing/calculation and write hourly_litres to a sensor that is displayed on the front end.

1 Like

Did you ever worked out the code? I am strubbling the same. Already have sensor data but want to create dummy sensors with the right output (liters)

To be honest, i set the project aside as it seemed to gather a heavy load of data and turned my DB huge and my HA slow.

I will come back to it after i have looked into mariaDB and template sensors, so i can better manipulate the stored presented data.

Here is a block of code from the link above that will give you an idea on how to go forward and mathematically manipulate your data:

sensor:
  - platform: template
    sensors:
      transmission_down_speed_kbps:
        friendly_name: "Transmission Down Speed"
        unit_of_measurement: 'kB/s'
        value_template: "{{ states('sensor.transmission_down_speed')|float * 1024 }}"

One small update would be that i am working on connecting the flow sensor to a nodeMCU chip which i have flashed with the ESPeasy firmware, as it is really far from my main rpi running HA.

The ESPeasy has functionality that manipulates the data before sending it through mqtt to my HA. There you can enter someting like %value%/220 which in my case turns pulses to liters and send actual liter information to HA.

I have not managed to get it to work yet but here is some info.

Thanks for your reply. To bad is has such a load on your ha unit. Do you have any idea how to interpretate and split the code here: Watermeter pulse sensor S0PCM
?

Thanks

No clue mate, due to my lack of experience and expertise, i am just looking into problems as soon as they come up.
Never had to fiddle with that sensor before :slight_smile:

Hi Krash, just an update, I’ve decided to go your route and use the EspEasy firmware instead, I have it connected and hoping to conduct some testing to calibrate the meter. As I’m guessing you mentioned %value%/220 and 220 isn’t the default correct?

Exactly what i was referring to.
No, 220 isnt a default, it’s just a number i figured out by filling water bottles :slight_smile:
Every liter was about 220-230 pulses on my sensor.
Some testing should tell you what the number you should use is.

Did you get it to work? Because i never managed to get a steady reading with it.

Having the same issue, working with the pulses seems to be giving inconsistent readings, with tasmota on the sonoff trying to use pulse timer, however cant seem to get the math working on Hass to calculate flow…

hoping some1 can shed some light on this? :exploding_head:

Maybe the sensor data can be manipulated with this new option, Filter Sensor?

Found a non invasive possible alternative, if any1’s interested i posted a question here.
Would love any input.

Hey, im back on the project again :slight_smile:
I managed to get it to work with the tasmota’d sonoff but had to do a little soldering 1st.
My waterflow sensor works with 5v in so, i had to get that from the chip by soldering a cable on the 5v pin on this picture:

Here is the final 5v out soldered:

Routed the cable that way to avoid crossing the sonoff’s power rails:

And finally cut a small nick on the case to bring the cable where i wanted it. Again, i didnt use the little missing corner of the board to avoid running the little cable over the 230VAC power lines:

So now i get an increasing pulse counter:
image

It is not really accurate but, i think that’s the flow meter’s problem, when i fill in 1 liter with small flow i get a smaller reading than when i fill it at full flow of the tap.
That’s not a big problem for me as i want to keep track of the irrigation system in my country house remotely, to check for leaks and stuff, so i dont need great accuracy.

Now heading to do the HA part, ill keep you guys posted.


Update with HA code:

sensors.yaml:

  - platform: mqtt
    name: "water_meter"
    state_topic: "tele/sonoff_water_meter/SENSOR"
    value_template: "{{ value_json.Counter1 }}"
    unit_of_measurement: "Pulses"

And using a template sensor in order to make it read liters:

  - platform: template
    sensors:
      water_meter_liters:
        friendly_name: "Water Meter in Lt"
        unit_of_measurement: 'lt'
        value_template: "{{ (states('sensor.water_meter')|int *1/225) | round(2) }}"
        #The conversion rate is a result of testing, and not very accurate.
        #The round(2) is to only get two decimals at the end of the liter count.

I also made a script that would reset the Tasmota counter to 0, for future use in an automation:
scripts.yaml:

water_meter_reset:
  sequence:
    - service: shell_command.water_meter_reset

and shell_commands.yaml:

  water_meter_reset: 'curl http://sonoffIP/cm?cmnd=counter1%200'
  #that's command "counter1 0"

Now im working on a Trend binary sensor in order to know when the water is running or not:
binary_sensors.yaml:

  - platform: trend
    sensors:
      water_meter_running:
        entity_id: sensor.water_meter
        device_class: moisture
        max_samples: 2
        sample_duration: 30

It works half good, triggers when the water is running, but wont reset to off when the water stops, i must be doing something wrong. (posted about it here)

Will post further updates when any.

4 Likes