Hi @ all
I have a drainage pit with a pump running to get rid of excess water. There is a hydrostatic sensor measuring the water content in the pit and a Shelly that is controlled by Home Assistant to start the pump if the water level is above 50%.
I monitor the runtime using a binary sensor that reacts to the output power of the Shelly (consider running if power output is > 20W:
template:
- binary_sensor:
- name: "heESP24: Drainage Pump Status"
unique_id: 883fe33e-7b55-4a35-a2e8-8759ec277e88
device_class: running
state: >
{{ states('sensor.heesp24_power_realtime')|float > 20 }}
icon: >
{% if states('sensor.heesp24_power_realtime')|float > 20 %}
mdi:pump
{% else %}
mdi:pump-off
{% endif %}
Now with the history_stats
component I’d like to monitor the “runtime” of the pump: daily, weekly, monthly and TOTAL.
sensor:
- platform: history_stats
name: "heESP24: Drainage Pump Runtime This Day Decimal"
entity_id: binary_sensor.heesp24_drainage_pump_status
state: "on"
type: time
start: "{{ now().replace(hour=0, minute=0, second=0, microsecond=0) }}"
end: "{{ now() }}"
- platform: history_stats
name: "heESP24: Drainage Pump Runtime This Week Decimal"
entity_id: binary_sensor.heesp24_drainage_pump_status
state: "on"
type: time
#Ref: https://www.home-assistant.io/integrations/history_stats/
start: "{{ as_timestamp( now().replace(hour=0, minute=0, second=0, microsecond=0) ) - now().weekday() * 86400 }}"
end: "{{ now() }}"
- platform: history_stats
name: "heESP24: Drainage Pump Runtime This Month Decimal"
entity_id: binary_sensor.heesp24_drainage_pump_status
state: "on"
type: time
#Ref: https://www.home-assistant.io/integrations/history_stats/
start: "{{ now().replace(day=1, hour=0, minute=0, second=0, microsecond=0) }}"
end: "{{ now() }}"
- platform: history_stats
name: "heESP24: Drainage Pump Runtime Total Decimal"
entity_id: binary_sensor.heesp24_drainage_pump_status
state: "on"
type: time
#Ref: https://www.home-assistant.io/integrations/history_stats/
start: "{{ 0 }}"
end: "{{ now() }}"
- platform: history_stats
name: "heESP24: Drainage Pump Start Events"
entity_id: binary_sensor.heesp24_drainage_pump_status
state: "on"
type: count
start: "{{ now().replace(hour=0, minute=0, second=0, microsecond=0) }}"
end: "{{ now() }}"
For the most part the values appear to be valid (I’m also trying to convert them from decimal to “human readable” (weeks,days,hours,minutes) - but that is a different story
The system is running for approximately 1.5 years now. Pump start events are between 0/day (summer) up to 30/day (autumn, winter), with each run pumping approximately 120 l water.
Now the Drainage Pump Runtime Total Decimal seems to be off:
473.230 h / 24 ~ 19.718 days RUNtime in 1.5 years!
The start and stop values for the sensor are from the integrations support page, so I guess they are fine?
Furthermore, in the second screen shot the “current value” is 473232:44:24 which does not look like a valid number to me.
Any ideas what I might be missing / overseeing?
Thanks in advance for any insight / input!
Cheers,