Detect Power On via peak of power consumation

I have a Submersible dirty water pump and Iwould like to monitor how many times per hour the pump is running.
The pump is strating and stopping automaticly via a integrated flow siwtch (not integrated in home assistant)
The good point is that I can see via the monitored electric consumtion when the pomp is running. = ± 250W
The bad point is that there is another device on the same electric line . But I know the consumation of this one ± 800W)

From an human eye, it’s easy when you look at the graph.
But how could I do that in home assisatnt ? Via a new manual sensor ?

Thanks in advance

A template sensor that checks if the power is between 200 and 300w or between 900w and 1100w.

template:
  - binary_sensor:
      - name: "Pump Running"
        state: >
          {% set power = states('sensor.your_pump_power')|float(0) %}
          {{ (200 <= power <= 300) or (900 <= power <= 1100) }}

Then feed that to. History stats count sensor.

1 Like

My first attempt would be to create an automation like this:

alias: New Automation
description: ''
mode: single
trigger:
  - platform: numeric_state
    entity_id: sensor.power
    above: '200'
    below: '300'
    for: '00:00:02'
  - platform: numeric_state
    entity_id: sensor.power
    above: '1000'
    for: '00:00:02'
condition: []
action:
  - service: input_boolean.turn_on
    target:
      entity_id: input_boolean.pump_running
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.pump_running
  - delay:
      hours: 0
      minutes: 0
      seconds: 20 # longer than normal run time but less than between runs, to keep it from triggering twice in the same run
      milliseconds: 0

Then an statistics or history stats on the boolean.

1 Like

Thank you so much to both of you.
I think I actually understand both solution (but was not enough fluent with HA to think about it :wink: )

Is there some points to take into consideration before to choose betwennn automation and template sensor ?

Not a lot. You can reload automations or helpers without affecting the binary sensor implementation.

You can’t (easily) edit the binary sensor state.

You can add a device class to the binary sensor to affect how its state and icon are displayed in the frontend.

Spool up time?

What does the graph look like when you zoom in to the 800 peak? Will it be between 200 and 300 or does it just skip it completely?

we continue to see peak but around 1050W
image

That is not what I meant.
Set the timespan to a smaller window. Say 05:00 to 05:05 (or whatever timespan it was started).
Then use the cursor to see if you get a reading along the line where it says between 200 and 300 w.

If it does then the sensor based may trigger when it was on it’s way to 800, but the automation based needs 2 seconds where it stays between 200 and 300 w to trigger.

Actually it’s directly moving from 0 to 800
image

So I think I can use the sensor based solution

Here is a first look:
image

template:
  - sensor:
      - name: "Temperature Exterieur"
        unit_of_measurement: "°C"
        state: "{{ state_attr('weather.p_hourly', 'temperature')  }}"
  - binary_sensor:
    - name: "Pompe puisard"
      state: >
        {% set power = states('sensor.smart_meter_electric_consumption_w')|float(0) %}
        {{ (200 <= power <= 300) or (900 <= power <= 1100) }}        

# Example configuration.yaml entry
sensor:
  - platform: history_stats
    name: Pompe puisard Count
    entity_id: binary_sensor.pompe_puisard
    state: "on"
    type: count
    start: "{{ now().replace(minute=0, second=0) }}"
    end: "{{ now() }}"

You can also use the derivative sensor to see the rises and only accept rises that are at a specific rate. It would be pretty easy to see the differences here, however if they both turn on at the same time, you’d have a problem.

oohhh probably something I still need to learn or experience :wink: