I have a microdrip/ sprinkler setup to pump water from my rainwater bin trough a set of hoses in my garden.
System is powered by a Wemos D1 mini on a breakout pcb board:
Pump is powered by a relais.
Water level in tank is monitored with an ultrasonic sensor( JSN-SR04T ).
Sprinkler is set in motion by either a homeassistant automation, homeassistant button, or a physical button on a gpio on the ESP.
What i would like to do, is setup esphome, so that the relais will not turn on, when the tank level is below a certain point(say 10%), to prevent my pump from running dry.
I could do this in homeassistant, but as the wifi connection is not great in my shed, i think it would be better to do this in esphome.
What is working, is that the pump will shut off when the water level drops below 10%, but what if someone presses the button when the water level is already below 10%, then my pump will burn itself out after running dry.
My code is:
- platform: ultrasonic
trigger_pin: 4
echo_pin: 3
unit_of_measurement: "%"
icon: "mdi:water-percent"
accuracy_decimals: 0
update_interval: 60s
name: "Regenton percentage"
id: regenton_percent
filters:
- lambda: return (1-((x-.05)/1.00))*100;
- filter_out: nan
on_value_range:
- below: 10.0
then:
- switch.turn_off: relais1
- platform: ultrasonic
trigger_pin: 4
echo_pin: 3
update_interval: 60s
name: "Regenton liters"
unit_of_measurement: "l"
accuracy_decimals: 0
filters:
- lambda: return (1-((x-.05)/1.00))*240;
- filter_out: nan
switch:
- platform: gpio
pin: 0
name: "Tuin Water Relais"
id: relais1
icon: mdi:watering-can
inverted: True
restore_mode: ALWAYS_OFF
internal: true
- platform: template
name: Tuin sproeiers
icon: "mdi:watering-can"
turn_on_action:
then:
- switch.turn_on: relais1
- delay: 1200s
- switch.turn_off: relais1
lambda: 'return id(relais1).state;'
binary_sensor:
- platform: gpio
pin:
number: 12
mode:
input: true
output: false
inverted: true
name: waterknop
device_class: power
filters:
- delayed_off: 500ms
disabled_by_default: false
Hoping someone could help me. Thanks in advance.
Greetings
Mark.