Hi all, is there a way to build a leak detector system or water flow meter for an irrigation system to integrate with home assistant? I ask because I have a Rain Bird sprinkler controller and 11 sprinklers zones and have had a leak for a month or two before recently discovering it, and would like to prevent similar from happening again. Rain bird has a flow detector but it only works with its higher end controllers, which I don’t have. I can also buy another Brand’s controller I don’t want to spend a huge amount of money to do so. Is there an existing flow controller for the feed line, or leak controller? Or could I build something with ESP home? Thank you for any assistance, Ari
Don’t know if they make a low enough flow meter that is cost effective. You could do it by pressure if every head had a water/air tight/pressure valve in front of it (pressure loss means a leak). Plus a head selector valve(s) to isolate each leg to head/valve. That again makes it a cost issue.
I haven’t completed mine, but my plan is to use my Flume (straps to the water main meter) as a psuedo flow detector. I will characterize how much water flow each zone uses and then monitor it when a zone turns on. If much greater than the expected, there is a potential leak.
Yes that’s possible. But it depends on how bad the leak is and the sensitivity of the flow sensor you buy.
I just built a dual bank irrigation controller integrated via ESPHome and it has a flow sensor I built-in.
Here is the flow sensor I bought:
https://www.amazon.com/gp/product/B00VKATCRQ?th=1
but it only goes down to 1 liter per minute.
There may be more sensitive ones but I haven’t seen one that could connect to a garden hose sized system.
I can show you the code I used in ESPHome for it if you are interested.
Here is what I did. I have a Rachio controller and Flume Gen 2 water meter, integrated with HA. I monitor flow from the Flume meter when each zone runs and get alerted if there is a significant change from the prior run, which would occur with a pipe leak or blockage. (Unique to my situation is that this is for a vacation residence, where I have a water valve shutoff for the house, but not the irrigation system. I only monitor the irrigation system when the house water valve is closed, so as not to capture flow from a flushed toilet, dishwasher, etc.).
Here are the template sensors I created. I created one set for each zone. :
# Zone 1 Front Grass
- trigger: # Samples flow value and keeps it until next time zone turns on
- platform: state
entity_id: switch.zone_1_front_grass_2
to: "on"
for: "00:02:30" # Provides sufficient time for water flow to come up to steady state and Flume to update
sensor:
- name: zone1_flow
state: >
{% if is_state('switch.vedge_switch_7', 'off') %}
{{ states('sensor.flume_current') }}
{% else %}
{{ states('sensor.zone1_flow') }}
{% endif %}
- trigger: # Stores penultimate run flow value and keeps it until next time zone turns off
- platform: state
entity_id: switch.zone_1_front_grass_2
to: "off"
for: "00:02:30" # Provides sufficient time for water flow to taper off and Flume to update
sensor:
- name: zone1_flow_penultimate
state: >
{% if is_state('switch.vedge_switch_7', 'off') %}
{{ states('sensor.zone1_flow') }}
{% else %}
{{ states('sensor.zone1_flow_penultimate') }}
{% endif %}
- trigger: # Calculates ratio between current run and penultimate run
- platform: state
entity_id: switch.zone_1_front_grass_2
to: "on"
for: "00:02:45" # Waits for current run to update, allows 15 sec, but before run stops
sensor:
- name: zone1_flow_ratio
state: >
{% if is_state('switch.vedge_switch_7', 'off') %}
{{ (states('sensor.zone1_flow')) | float(0) / (states('sensor.zone1_flow_penultimate')) | float(0) }}
{% else %}
{{ states('sensor.zone1_flow_ratio') }}
{% endif %}
- sensor: # Sensors turn on when flow limits exceeded
- name: zone1_hi_flow
state: >
{% if ((states('sensor.zone1_flow_ratio')) | float(0)) > ((states('input_number.sprinkler_upper')) | float(0)) %}
on
{% else %}
off
{% endif %}
- name: zone1_low_flow
state: >
{% if ((states('sensor.zone1_flow_ratio')) | float(0)) < ((states('input_number.sprinkler_lower')) | float(0)) %}
on
{% else %}
off
{% endif %}
Since I am uncertain what constitutes a significant change in flow rate, especially since water pressure can fluctuate from day-to-day, I can adjust the upper and lower alert thresholds, based on a graphical representation of flow over the last seven days.
Here is an example of what a dismissible alert looks like.
Here is the YAML for the card, utilizing custom cards via HACS, input_number and input_boolean Helpers, as noted:
type: custom:stack-in-card
mode: vertical
title: Sprinkler Leaks & Blockages
cards:
- entities:
- entity: sensor.zone1_flow_ratio
name: 1 - Front Grass
show_fill: false
- entity: sensor.zone2_flow_ratio
name: 2 - Backyard Grass
show_fill: false
- entity: sensor.zone3_flow_ratio
name: 3 - Side Yards
show_fill: false
- entity: sensor.zone4_flow_ratio
name: 4 - Backyard Shrubs
show_fill: false
- entity: sensor.zone5_flow_ratio
name: 5 - Mailbox Grass
show_fill: false
- entity: sensor.zone6_flow_ratio
name: 6 - Front Shrubs
show_fill: false
- entity: input_number.sprinkler_lower
show_fill: false
show_legend: false
color: gray
- entity: input_number.sprinkler_upper
show_fill: false
show_legend: false
color: gray
- color: gray
entity: binary_sensor.night
show_legend: false
show_line: false
show_points: false
show_state: false
y_axis: secondary
- color: red
entity: binary_sensor.workday_sensor
show_legend: false
show_line: false
show_points: false
show_state: false
y_axis: secondary
icon: mdi:pipe-leak
hours_to_show: 168
aggregate_func: max
name: Flow compared to prior run - last 7 days
points_per_hour: 10
smoothing: true
show:
state: false
state_map:
- label: Day
value: 'off'
- label: Night
value: 'on'
line_width: 3
type: custom:mini-graph-card
- type: entities
entities:
- type: divider
- type: markdown
content: Alert thresholds
card_mod:
style: |
ha-card {
font-size: 14px;
font-weight: medium;
}
- type: entities
entities:
- entity: input_number.sprinkler_upper
name: High Flow
icon: mdi:code-greater-than
- entity: input_number.sprinkler_lower
name: Low Flow
icon: mdi:code-less-than
- type: conditional
conditions:
- entity: input_boolean.zone1_leak
state: 'on'
card:
type: entities
entities:
- type: divider
- entity: input_boolean.zone1_leak
name: Zone 1 - Front Grass Pipe Leak
secondary_info: Dismiss
icon: mdi:liquid-spot
state_color: true
- type: conditional
conditions:
- entity: input_boolean.zone2_leak
state: 'on'
card:
type: entities
entities:
- type: divider
- entity: input_boolean.zone2_leak
name: Zone 2 - Backyard Grass Pipe Leak
secondary_info: Dismiss
icon: mdi:liquid-spot
state_color: true
- type: conditional
conditions:
- entity: input_boolean.zone3_leak
state: 'on'
card:
type: entities
entities:
- type: divider
- entity: input_boolean.zone3_leak
name: Zone 3 - Side Yards Pipe Leak
secondary_info: Dismiss
icon: mdi:liquid-spot
state_color: true
- type: conditional
conditions:
- entity: input_boolean.zone4_leak
state: 'on'
card:
type: entities
entities:
- type: divider
- entity: input_boolean.zone4_leak
name: Zone 4 - Backyard Shrubs Pipe Leak
secondary_info: Dismiss
icon: mdi:liquid-spot
state_color: true
- type: conditional
conditions:
- entity: input_boolean.zone5_leak
state: 'on'
card:
type: entities
entities:
- type: divider
- entity: input_boolean.zone5_leak
name: Zone 5 - Mailbox Grass Pipe Leak
secondary_info: Dismiss
icon: mdi:liquid-spot
state_color: true
- type: conditional
conditions:
- entity: input_boolean.zone6_leak
state: 'on'
card:
type: entities
entities:
- type: divider
- entity: input_boolean.zone6_leak
name: Zone 6 - Front Shrubs Pipe Leak
secondary_info: Dismiss
icon: mdi:liquid-spot
state_color: true
- type: conditional
conditions:
- entity: input_boolean.zone1_block
state: 'on'
card:
type: entities
entities:
- type: divider
- entity: input_boolean.zone1_block
name: Zone 1 - Front Grass Blockage
secondary_info: Dismiss
icon: mdi:cancel
state_color: true
- type: conditional
conditions:
- entity: input_boolean.zone2_block
state: 'on'
card:
type: entities
entities:
- type: divider
- entity: input_boolean.zone2_block
name: Zone 2 - Backyard Grass Blockage
secondary_info: Dismiss
icon: mdi:cancel
state_color: true
- type: conditional
conditions:
- entity: input_boolean.zone3_block
state: 'on'
card:
type: entities
entities:
- type: divider
- entity: input_boolean.zone3_block
name: Zone 3 - Side Yards Blockage
secondary_info: Dismiss
icon: mdi:cancel
state_color: true
- type: conditional
conditions:
- entity: input_boolean.zone4_block
state: 'on'
card:
type: entities
entities:
- type: divider
- entity: input_boolean.zone4_block
name: Zone 4 - Backyard Shrubs Blockage
secondary_info: Dismiss
icon: mdi:cancel
state_color: true
- type: conditional
conditions:
- entity: input_boolean.zone5_block
state: 'on'
card:
type: entities
entities:
- type: divider
- entity: input_boolean.zone5_block
name: Zone 5 - Mailbox Grass Blockage
secondary_info: Dismiss
icon: mdi:cancel
state_color: true
- type: conditional
conditions:
- entity: input_boolean.zone6_block
state: 'on'
card:
type: entities
entities:
- type: divider
- entity: input_boolean.zone6_block
name: Zone 6 - Front Shrubs Blockage
secondary_info: Dismiss
icon: mdi:cancel
state_color: true
- type: conditional
conditions:
- entity: input_boolean.zone1_block
state: 'off'
- entity: input_boolean.zone1_leak
state: 'off'
- entity: input_boolean.zone2_block
state: 'off'
- entity: input_boolean.zone2_leak
state: 'off'
- entity: input_boolean.zone3_block
state: 'off'
- entity: input_boolean.zone3_leak
state: 'off'
- entity: input_boolean.zone4_block
state: 'off'
- entity: input_boolean.zone4_leak
state: 'off'
- entity: input_boolean.zone5_block
state: 'off'
- entity: input_boolean.zone5_leak
state: 'off'
- entity: input_boolean.zone6_block
state: 'off'
- entity: input_boolean.zone6_leak
state: 'off'
card:
type: custom:stack-in-card
mode: vertical
cards:
- type: entities
entities:
- type: divider
- type: markdown
content: No issues
card_mod:
style: |
ha-card {
font-size: 14px;
font-weight: medium;
}
I also created an automation to alert me through the mobile app (not shown). Since the sprinklers run in the middle of the night, I set it up to delay notification until the morning, instead of being awakened in real time.