Hi there, I’m new to HA and this is my first request for a little help from you.
I would like to use my hall flowmeter for detecting a hose burst in my irrigation system. The flow meter works well and shows met the current liters per hour. What can I do best to test if the flow is below or above some levels for a period and then use it to shut off my water pump and send me a notification? For now I make use of some simple automations in my irrigation system.
I used ESPHome with a NodeMCU to achieve what you are looking for. Here is the ESPHome config. Not sure it is the best or only way of doing things but it appears to work.
esphome:
name: potager_watering
platform: ESP8266
board: nodemcuv2
wifi:
ssid: "xxxxxxxxxxx"
password: "xxxxxxxxxxxxxxxxxx"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Potager Watering"
password: "xxxxxxxxxxxxxx"
manual_ip:
static_ip: xxxxxxxxxxxxxxxxx
gateway: xxxxxxxxxxxxxxxxx
subnet: 255.255.255.0
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
web_server:
ota:
globals:
- id: leak_boolean
type: int
restore_value: false
initial_value: '0'
- id: pulses_watering_start
type: int
restore_value: false
initial_value: '0'
switch:
- platform: gpio
pin: D7
id: relay
name: "Potager Tap"
restore_mode: ALWAYS_OFF
inverted: true
on_turn_on:
# Initialse global with number of pulses when tap is turned on
- globals.set:
id: pulses_watering_start
value: !lambda |-
return id(total_pulses).state;
on_turn_off:
- wait_until:
sensor.in_range:
id: water_flow
below: 1
- sensor.template.publish:
id: pulses_this_watering
state: !lambda 'return id(total_pulses).state - id(pulses_watering_start) ;'
- homeassistant.event:
event: esphome.potager_watering
data:
name: Watering Finished
sensor:
#
# Flow Meter
#
- platform: pulse_counter
name: "Potager Tap Pulses Per Minute"
pin: D5
update_interval: 20s
id: water_flow
internal: false
on_value:
then:
#
# Above 800 pulses per minute
#
- if:
condition:
sensor.in_range:
id: water_flow
above: 800
then:
- if:
condition:
lambda: 'return id(leak_boolean) == 1;'
then:
#
# This is the 2nd time in a row that threshold has been exceeded so take action
#
- switch.turn_off: relay
- homeassistant.event:
event: esphome.potager_watering
data:
name: Leak Detected
- globals.set:
id: leak_boolean
value: '0'
else:
- globals.set:
id: leak_boolean
value: '1'
else:
#
# Reset leak boolean
#
- globals.set:
id: leak_boolean
value: '0'
total:
name: 'Potager Tap Total Pulses'
id: total_pulses
#
# Soil Moisture Sensor
#
- platform: adc
pin: A0
name: Potager Soil Moisture Value
id: soil_moisture
accuracy_decimals: 1
update_interval: 60s
icon: mdi:flower
#
# Number Of Pulses This Watering
#
- platform: template
name: Potager Tap Pulses This Watering
id: pulses_this_watering`
Thanks for sharing your esphome config. I didn’t realize that testing on the esp board it self is also an option. I will studie your config and see if I can use it in my setup. Have you thought about testing the leak detection in HA?