How to calculate total water consumption in ESPHome when calibration for flow rate is used?

Using without calibration is wrong, due to the sensor readings vary significantly depending on the flow rate. Using the same calibration for total is also wrong - it breaks calculation at all.

Using two YF-S402B with individual calibrations on water flow rate and stock configuration with fixed ratio is very erroneous (with calibration they are much more accurate).

  • How do I make the total calculate based on actual flow rate calibrated data?
  • Is separate calibration necessary (I don’t understand how to produce it mathematically), and is it possible to do without it?

Thanks!

sensor:
  - platform: pulse_counter 
    id: "raw_water"
    name: "Input (actual)"
    pin: GPIO12 
    update_interval: ${update_interval}
    accuracy_decimals: 3
    force_update: True
    unit_of_measurement: L/min
    device_class: water
    state_class: measurement
    entity_category: "diagnostic"
    filters:
      - calibrate_linear:
          method: exact
          datapoints:
            - 0 -> 0
            - 149 -> 0
            - 445 -> 0.299
            - 1174 -> 0.643
            - 2102 -> 1.134
            - 2453 -> 1.262
            - 2642 -> 1.310
            - 2730 -> 1.350
            - 2883 -> 1.434
            - 3052 -> 1.469
            - 3540 -> 1.535
            - 4000 -> 1.600
    total:
      id: "raw_water_total"
      name: "Input"
      accuracy_decimals: 3
      unit_of_measurement: L
      filters:
            ???

That would be quite complicated. Total is just a counter of the pulses your meter outputs, it doesn’t consider how fast or slow they come or what calibrations you make on pulse_counter.
You need to build your own Total, for example you could set pulse_counter update interval to 1s and use on_value automation to add corresponding quantity to template sensor or global variable. For example if your flow is 15L/min, you add 0.25L to the counter. That might work if you have simple esphome setup and not any component is hanging the update intervals.

1 Like

I was wary of options like this, as they feel like crutches.
But at least it could be a way out of the situation, thank you!