Calculate times toilet flushed

Hi! So in this diagram you see my rainwater pump working when someone flushes the toilet:

Every time the pump is working the idle (around 1W) power jumps to around 550W.
Is there a way to create an automation and sensor to show how many times a day the pump does its work? :slight_smile:

My experience in YAML is rather basic and I don’t even know where to begin.

1 Like

Hey!
I’ve solved a similar task here: Trigger on Washing Machine finish - #26 by ThomDietrich

What you basically want to do is describe to HA what you count as a “flush”, as well as when this single flush is over so a second flush can be detected.

I guess a rule like the following should do the job:

  1. If power goes above 10W (any suited threshold)
  2. Count as flush, increment an input_number, send notification, trigger a service, …

As simple as that. It might become tricky when your power consumption varies over one flush, e.g. goes back to 1W on-between. In this case a simple for in the trigger might be sufficient.

automation:
  - alias: Detect flush
    trigger:
      - platform: numeric_state
        entity_id: sensor.water_pump_power
        above: 10
        for:
          seconds: 10
    action:
      - service: notify.mobile_app
        data:
          message: "Good boy!"

Sweet, I’m going to try that, thanks!

I did try this:

alias: Detect flush
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.regenwaterpomp_power
    for:
      hours: 0
      minutes: 0
      seconds: 1
    attribute: unit_of_measurement
    above: "2"
condition: []
action:
  - service: counter.increment
    data: {}
    target:
      entity_id: counter.flushcounter
mode: single

But it doesn’t do anything.
If I paste your code, the system reports:
Message malformed: extra keys not allowed @ data['automation']

Edit: seems to work now!

1 Like