Leakage detection using pump current

Hello,

Recently I noticed that there is a leakage in my watering system because I was able to see that the pump was active way more frequently while the system did nothing, therefore trying to keep the pressure in the pipes high.

I only found this because I looked at the charts, but it would be great to have an automation that would find those short peaks and check their frequency. If the frequency is too high, there must be something wrong and I want to trigger a notification. I tried my luck with regular automation, however, did not find a way to check for a recent peak.

In general those peaks have typically a duration of about 2 seconds.

Is there an easy way to solve this problem?

Since the peaks are so few and temporary then I would think a statistics sensor would work.
If you have it set to say 10 minutes or so then you should see a larger average consumption than when its normal.
Normal should be close to 0 even when the pump runs, but perhaps you will get 100-150-ish average when there is a leak.
Perhaps not at the start but at the morning of May 16 I guess it would be noticeable.

EDIT;
I just remembered that is not how the statistics sensor calculates the average.
But I believe there is a HACS sensor that do calculate it that way.

Or you could use an automation to increment a counter every time the pump power goes above 200W (numeric state trigger), reset the the counter at midnight (time trigger) and alert you if the counter exceeds 10 (or whatever) counts a day (another numeric state trigger).

Thank you! Both suggestions seem to be great, however, I chose the counter-based approach simply because I do not need any additional sensor or complicated calculation that might be error-prone ( if done by me :wink: )

One automation to count upwards:

alias: Pumpe Wasserzisterne Active Counter
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.eg_garten_pumpe_wasserzisterne_leistung
    above: 400
condition: []
action:
  - service: counter.increment
    target:
      entity_id: counter.eg_garten_pumpe_wasserzisterne_aktiv_zaehler
    data: {}
mode: single

One automation for notification:

alias: Pumpe Wasserzisterne Leakage Detection Notification
description: >-
  Notifies you when the pump turns on/off over 20x per day which indicates
  frequent pressure loss.
trigger:
  - platform: time
    at: "12:00:00"
condition: []
action:
  - if:
      - condition: numeric_state
        entity_id: counter.eg_garten_pumpe_wasserzisterne_aktiv_zaehler
        above: 20
    then:
      - service: notify.mobile_app_iphone
        metadata: {}
        data:
          message: Wasserzisterne Pumpe Leakage Detection!
  - service: counter.reset
    target:
      entity_id: counter.eg_garten_pumpe_wasserzisterne_aktiv_zaehler
    data: {}
mode: single

One thing that I have not figured out yet is if it is possible to check for a minimal peak duration. This would be useful because in case somebody uses the water more frequently (= more peaks) it would result in a false positive. If I could filter for short peak duration (eg. 1-2 seconds) I would reduce the risk to almost zero. Am I lucky and is there an option that I am not aware of?

Why do you trigger at 12:00 in the last automation?

Why not trigger at counter == 20?
You could have a leak for almost 24 hours before that message gets to you.

@Hellis81 Good point, changed to your suggestion :slight_smile:

Consider also adding a long run cutoff. If the pipe completely burst it may never get back up to pressure.

  • Long Run cutoff - if the well runs for more than X minutes generate an alert and turn it off. You’ll need to derive what X should be based on your usage. Use an input number for X so its easy to tweak. Based on your description if its running for 1 minute you have a problem.
1 Like

You can use a wait_for_trigger to check how long the pump has been on for.

This is an automation I wrote yesterday for a similar type of question, you should be able to adapt the concept to your needs. But if you have trouble or questions just ask.

alias: Test Hold
description: ""
trigger:
  - platform: state
    entity_id: input_boolean.test
    from: "off"
    to: "on"
condition: []
action:
  - variables:
      timeout: 10
  - wait_for_trigger:
      - platform: state
        entity_id: input_boolean.test
        from: "on"
        to: "off"
    continue_on_timeout: false
    timeout: "{{ timeout }}"
  - variables:
      press_duration: "{{ timeout - wait.remaining }}"
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ press_duration < 2 }}"
        sequence:
          - service: notify.mobile_phone
            data:
              message: Less than 2 seconds
    default:
      - service: notify.mobile_phone
        data:
          message: Greater than or equal to 2 seconds
mode: single
1 Like

Thank you for all the great suggestions. This is what I ended up with so far not taking into account “Long Run cutoff” yet (still not fully tested, but could be a good starting point for others) :slight_smile:

alias: Pumpe Wasserzisterne Active Counter
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.eg_garten_pumpe_wasserzisterne_leistung
    above: 400
condition: []
action:
  - wait_for_trigger:
      - platform: numeric_state
        entity_id:
          - sensor.eg_garten_pumpe_wasserzisterne_leistung
        below: 100
    timeout:
      hours: 0
      minutes: 0
      seconds: 3
      milliseconds: 0
    continue_on_timeout: false
  - service: counter.increment
    target:
      entity_id: counter.eg_garten_pumpe_wasserzisterne_aktiv_zaehler
    data: {}
mode: single
alias: Pumpe Wasserzisterne Active Counter - Reset
description: ""
trigger:
  - platform: time
    at: "00:00:00"
condition: []
action:
  - service: counter.increment
    target:
      entity_id: counter.eg_garten_pumpe_wasserzisterne_aktiv_zaehler
    data: {}
mode: single
alias: Pumpe Wasserzisterne Leakage Detection Notification
description: >-
  Notifies you when the pump turns on/off over 20x per day which indicates
  frequent pressure loss.
trigger:
  - platform: numeric_state
    entity_id:
      - counter.eg_garten_pumpe_wasserzisterne_aktiv_zaehler
    above: 20
condition: []
action:
  - service: notify.mobile_app_lukass_iphone
    metadata: {}
    data:
      message: Wasserzisterne Pumpe Leakage Detection!
      title: Check pipes for leaks.
mode: single

Counter.increment?
Shouldn’t that be reset?

You could make that all in to one automation also.

alias: Pumpe Wasserzisterne count up/reset/notify
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.eg_garten_pumpe_wasserzisterne_leistung
    above: 400
    id: count_up
  - platform: time
    at: "00:00:00"
    id: count_reset
  - platform: numeric_state
    entity_id:
      - counter.eg_garten_pumpe_wasserzisterne_aktiv_zaehler
    above: 20
    id: notify
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - count_up
        sequence:
          - wait_for_trigger:
              - platform: numeric_state
                entity_id:
                  - sensor.eg_garten_pumpe_wasserzisterne_leistung
                below: 100
            timeout:
              hours: 0
              minutes: 0
              seconds: 3
              milliseconds: 0
            continue_on_timeout: false
          - service: counter.increment
            target:
              entity_id: counter.eg_garten_pumpe_wasserzisterne_aktiv_zaehler
            data: {}

      - conditions:
          - condition: trigger
            id:
              - count_reset
        sequence:
          - service: counter.reset  #### Changed this to reset
            target:
              entity_id: counter.eg_garten_pumpe_wasserzisterne_aktiv_zaehler
            data: {}

      - conditions:
          - condition: trigger
            id:
              - notify
        sequence:
          - service: notify.mobile_app_lukass_iphone
            metadata: {}
            data:
              message: Wasserzisterne Pumpe Leakage Detection!
              title: Check pipes for leaks.
                    
mode: single

Had posted about something like this a year or so ago but never got around to doing it. A spigot got left on again so back to being important.

Rather than the counter approach above, would a derivative helper sensor be another option? Haven’t worked much with them but looking at kwh vs w, seems like it would work?

Pros/cons to one vs the other?

(The drop was a electric company power outage)