@uSlackr thanks for the dev work till here. I will pull it all together and add some remarks for beginners, I also fixed some bad indentations and spaces, that resulted in errors on my system.
Into the template part of the configuration.yaml (or if you have included a templates.yaml, then there) goes:
# Sump Pump running stats#
- sensor:
- name: "Sump running"
state: "{% if states('sensor.smartplug_name_energy_power')|float(0) > 0 %} true {% else %} false {% endif %}"
you have to replace sensor.smartplug_name_energy_power
with your pump metering entity. Watts and Amps are okay, but watt is preferable, bigger change, but even 0.001A is more than zero, so make sure your metering device is calibrated. With my nous A1 with tasmota I see 0 Watts and 0.02a all the time so check what you pick for a sensor.
Next step:
Into the Sensor part of the configuration.yaml (or if you have included a sensors.yaml, then there) goes:
#sump pump history run count#
- platform: history_stats
name: sump run count today
entity_id: sensor.sump_running
state: "true"
type: count
start: "{{ now().replace(hour=0, minute=0, second=0) }}"
duration:
hours: 24
#sump pump history run time#
- platform: history_stats
name: sump run time today
entity_id: sensor.sump_running
state: "true"
type: time
start: "{{ now().replace(hour=0, minute=0, second=0) }}"
duration:
hours: 24
And finally the monitoring via the utility_meter thing. same applies as above, it goes into configuration.yaml, of if you included a utility_meters.yaml, then there:
utility_meter:
monthly_sump_pump_power:
source: sensor.smartplug_name_energy_total
cycle: monthly
where you have to replace the sensor.smartplug_name_energy_total
with your own delivery metering device, not the current consumption!
In this whole setup, I miss a “stuck float switch” check.
If the consumption goes down due to sucking air and still running, or if it is on for way longer than usual, it should trip an alarm, same goes for unusual long times with no consumption. So the average consumption over the past 7 days should be tracked in relation to the average of the last 2 days, if it varies significantly downward, there should also be an alarm. Ill add this when Im done and have proven it working. Why, my float gets suck about once a month, and then I need rubber boots to fix it and have to clean up afterward. If HA would alert me half a day earlier compared to the the water sensor, I would just need to walk to the pump and tuck on the cable to fix it.