Creating An Automation For Dosing Pumps

Home Assistant automation projects, questions, etc. go here.
Post Reply
Gromyjoe
LED Enthusiast
LED Enthusiast
Reactions:
Posts: 48
Joined: Fri Jul 03, 2020 2:28 pm

Good morning everyone! I'm pleased to announce that my new and improved grow room is nearly complete! Everything is controlled and monitored by HA which is great because now I can involve my employee in the projects.
I have the parasaltic pumps inside a box and I know that each pump doses 1.3mL/s when supplied 12Vdc. My Reservoirs are each 200 Liters which last just under a week. The nutrients are pretty easy to use too. (Remo Nutrients)
VEG BLOOM
WEEKS 1 | 2 | 3 | 4 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Grow 1.25 | 1.50 | 1.75 | 2.0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
Micro 1.25 | 1.50 | 1.75 | 2.0 | 2.0 | 2.0 | 2.0 | 2.0 | 2.5 | 2.5 | 2.5 | 0
Bloom 0 | 0 | 0 | 0 | 2.0 | 2.0 | 2.0| 2.0 | 2.5 | 2.5 | 2.5 | 0
Calmg 1.25 | 1.50 | 1.75 | 2.0 | 2.0 | 2.0 | 2.0 | 2.0 | 0 | 0 | 0 | 0
Veloklp 1.25 | 1.50 | 1.75 | 2.0 | 2.0 | 2.0 | 2.0 | 2.0 | 2.5 | 2.5 | 2.5 | 0
Boost 0 | 0 | 0 | 0 | 0 | 2.0 | 2.0 | 2.0 | 2.0 | 2.0 | 2.0 | 0

Now what I want to do is create a script that automatically selects the proper nutrient and amount (mL/L) for which ever week is selected. Then use a simple formula to calculate the total amount of nutrients to dispense.

(input_number.micro_ml_per_liter) X ( input_number.nutrient_batch_size) == (input_number.micro_milliliters)

(input_number.micro_milliliters) X (input_number.dosing_pumps_ml_s) == (parasaltic pump ON duration)

My system is drain to waste so is should only have to set the proper level EC and PH each week and thats it. Has anyone got something similar to work? I've been trying to find some similar examples but no luck so far. Any help or ideas are much appreciated!
Gromyjoe
LED Enthusiast
LED Enthusiast
Reactions:
Posts: 48
Joined: Fri Jul 03, 2020 2:28 pm

I kinda figured out how to do this. Should have it all bugged out today since im stuck at home because of a snowstorm.

Heres my automation.. the first one Im still working on, I want it to trigger whenever the "input_number.current_week" sensor changes

Code: Select all

- id: '1607912650801'
  alias: Weekly value update
  description: Sets the values of nutrients
  trigger:
  - platform: state
    entity_id: sensor.flower_room_main_current_week
    from: '1'
    to: '8'
  condition: []
  action:
  - service: script.turn_on
    data: {}
    entity_id: script.1607903612605
  mode: single
- id: '1607913342970'
  alias: Week 6 Bloom
  description: Sets the values of nutrients
  trigger:
  - platform: state
    entity_id: sensor.flower_room_main_current_week
    to: '6'
  condition: []
  action:
  - service: input_number.set_value
    data:
      value: 2.5
    entity_id: input_number.bloom_ml_per_liter
  - service: input_number.set_value
    data:
      value: 2.5
    entity_id: input_number.micro_ml_per_liter
  - service: input_number.set_value
    data:
      value: 0
    entity_id: input_number.calmag_ml_per_liter
  - service: input_number.set_value
    data:
      value: 0
    entity_id: input_number.velokelp
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.bloom_boosters
  - service: input_number.set_value
    data:
      value: 0
    entity_id: input_number.grow_ml_per_liter
  mode: single
- id: '1607913548229'
  alias: Week 1 Bloom (no big bud)
  description: Sets the values of nutrients
  trigger:
  - platform: state
    entity_id: sensor.flower_room_main_current_week
    to: '1'
  condition: []
  action:
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.bloom_ml_per_liter
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.micro_ml_per_liter
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.calmag_ml_per_liter
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.velokelp
  - service: input_number.set_value
    data:
      value: 0
    entity_id: input_number.bloom_boosters
  - service: input_number.set_value
    data:
      value: 0
    entity_id: input_number.grow_ml_per_liter
  - service: automation.trigger
    data: {}
    entity_id: automation.week_one_bloom
  mode: single
- id: '1607913601468'
  alias: Week 2 Bloom (+ big bud)
  description: Sets the values of nutrients
  trigger:
  - platform: state
    entity_id: sensor.flower_room_main_current_week
    to: '2'
  condition: []
  action:
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.bloom_ml_per_liter
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.micro_ml_per_liter
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.calmag_ml_per_liter
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.velokelp
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.bloom_boosters
  - service: input_number.set_value
    data:
      value: 0
    entity_id: input_number.grow_ml_per_liter
  mode: single
- id: '1607913701713'
  alias: Week 8 Bloom (FLUSH)
  description: Sets the values of nutrients
  trigger:
  - platform: state
    entity_id: sensor.flower_room_main_current_week
    to: '8'
  condition: []
  action:
  - service: input_number.set_value
    data:
      value: 0
    entity_id: input_number.bloom_ml_per_liter
  - service: input_number.set_value
    data:
      value: 0
    entity_id: input_number.micro_ml_per_liter
  - service: input_number.set_value
    data:
      value: 0
    entity_id: input_number.calmag_ml_per_liter
  - service: input_number.set_value
    data:
      value: 0
    entity_id: input_number.velokelp
  - service: input_number.set_value
    data:
      value: 0
    entity_id: input_number.bloom_boosters
  - service: input_number.set_value
    data:
      value: 0
    entity_id: input_number.grow_ml_per_liter
  mode: single
- id: '1607914142214'
  alias: Week 5 Bloom
  description: Sets the values of nutrients
  trigger:
  - platform: state
    entity_id: sensor.flower_room_main_current_week
    to: '5'
  condition: []
  action:
  - service: input_number.set_value
    data:
      value: 2.5
    entity_id: input_number.bloom_ml_per_liter
  - service: input_number.set_value
    data:
      value: 2.5
    entity_id: input_number.micro_ml_per_liter
  - service: input_number.set_value
    data:
      value: 0
    entity_id: input_number.calmag_ml_per_liter
  - service: input_number.set_value
    data:
      value: 2.5
    entity_id: input_number.velokelp
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.bloom_boosters
  - service: input_number.set_value
    data:
      value: 0
    entity_id: input_number.grow_ml_per_liter
  mode: single
- id: '1607957865430'
  alias: Week 3 Bloom
  description: Sets the values of nutrients
  trigger:
  - platform: state
    entity_id: sensor.flower_room_main_current_week
    to: '3'
  condition: []
  action:
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.bloom_ml_per_liter
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.micro_ml_per_liter
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.calmag_ml_per_liter
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.velokelp
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.bloom_boosters
  - service: input_number.set_value
    data:
      value: 0
    entity_id: input_number.grow_ml_per_liter
  mode: single
- id: '1607957909337'
  alias: Week 4 Bloom
  description: Sets the values of nutrients
  trigger:
  - platform: state
    entity_id: sensor.flower_room_main_current_week
    to: '4'
  condition: []
  action:
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.bloom_ml_per_liter
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.micro_ml_per_liter
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.calmag_ml_per_liter
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.velokelp
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.bloom_boosters
  - service: input_number.set_value
    data:
      value: 0
    entity_id: input_number.grow_ml_per_liter
  mode: single
- id: '1607957976700'
  alias: Week 7 Bloom
  description: Sets the values of nutrients
  trigger:
  - platform: state
    entity_id: sensor.flower_room_main_current_week
    to: '7'
  condition: []
  action:
  - service: input_number.set_value
    data:
      value: 2.5
    entity_id: input_number.bloom_ml_per_liter
  - service: input_number.set_value
    data:
      value: 2.5
    entity_id: input_number.micro_ml_per_liter
  - service: input_number.set_value
    data:
      value: 0
    entity_id: input_number.calmag_ml_per_liter
  - service: input_number.set_value
    data:
      value: 0
    entity_id: input_number.velokelp
  - service: input_number.set_value
    data:
      value: 2
    entity_id: input_number.bloom_boosters
  - service: input_number.set_value
    data:
      value: 0
    entity_id: input_number.grow_ml_per_liter
  mode: single
  
  Script that sets the total amount of each nutrients to be dispensed.

Code: Select all

'1607903612605':
  alias: Set Dosing Amount For All Nutrients
  sequence:
  - service: input_number.set_value
    data:
      value: '{{ (states(''input_number.micro_ml_per_liter'') | float * states(''input_number.nutrient_batch_size'')
        | float)}}'
    entity_id: input_number.micro_pump_ml
  - service: input_number.set_value
    data:
      value: '{{ (states(''input_number.bloom_ml_per_liter'') | float * states(''input_number.nutrient_batch_size'')
        | float)}}'
    entity_id: input_number.bloom_pump_ml
  - service: input_number.set_value
    data:
      value: '{{ (states(''input_number.calmag_ml_per_liter'') | float * states(''input_number.nutrient_batch_size'')
        | float)}}'
    entity_id: input_number.magnifical_pump_ml
  - service: input_number.set_value
    data:
      value: '{{ (states(''input_number.velokelp'') | float * states(''input_number.nutrient_batch_size'')
        | float)}}'
    entity_id: input_number.velokelp_pump_ml
  - service: input_number.set_value
    data:
      value: '{{ (states(''input_number.bloom_boosters'') | float * states(''input_number.nutrient_batch_size'')
        | float)}}'
    entity_id: input_number.bloom_booster_pump_ml
  - service: input_number.set_value
    data:
      value: '{{ (states(''input_number.grow_ml_per_liter'') | float * states(''input_number.nutrient_batch_size'')
        | float)}}'
    entity_id: input_number.grow_pump_ml
  mode: single
Configuration:

Code: Select all

  grow_ml_per_liter:
    name: Grow
    min: 0
    max: 2.0
    step: 0.25
    icon: mdi:beaker
    unit_of_measurement: mL/L
  micro_ml_per_liter:
    name: Micro
    min: 0
    max: 2.5
    step: 0.25
    icon: mdi:beaker
    unit_of_measurement: mL/L
  bloom_ml_per_liter:
    name: Bloom
    min: 0
    max: 2.5
    step: 0.25
    icon: mdi:beaker
    unit_of_measurement: mL/L
  calmag_ml_per_liter:
    name: MagNiFiCal
    min: 0
    max: 2.5
    step: 0.25
    icon: mdi:beaker
    unit_of_measurement: mL/L
  velokelp:
    name: VeloKelp
    min: 0
    max: 2.5
    step: 0.25
    icon: mdi:beaker
    unit_of_measurement: mL/L
  bloom_boosters:
    name: Big Bud/OverDrive
    min: 0
    max: 2.5
    step: 0.25
    icon: mdi:beaker
    unit_of_measurement: mL/L
  nutrient_batch_size:
    name: Nute Batch Size
    min: 0
    max: 200
    step: 1
    icon: mdi:cup-water
    unit_of_measurement: Liters
    
  ph_pump_ml:
    name: PH Down
    min: 0
    max: 500
    step: 0.25
    unit_of_measurement: mL
    mode: box
  grow_pump_ml:
    name: Grow
    min: 0
    max: 500
    step: 0.25
    unit_of_measurement: mL
    mode: box
  micro_pump_ml:
    name: Micro
    min: 0
    max: 500
    step: 0.25
    unit_of_measurement: mL
    mode: box
  bloom_pump_ml:
    name: Bloom
    min: 0
    max: 500
    step: 0.25
    unit_of_measurement: mL
    mode: box
  magnifical_pump_ml:
    name: MagNiFiCal
    min: 0
    max: 500
    step: 0.25
    unit_of_measurement: mL
    mode: box
  velokelp_pump_ml:
    name: Velokelp
    min: 0
    max: 500
    step: 0.25
    unit_of_measurement: mL
    mode: box
  bloom_booster_pump_ml:
    name: Bloom Booster
    min: 0
    max: 500
    step: 0.25
    initial: 200
    unit_of_measurement: mL
    mode: box
  dosing_pumps_ml_s:
    name: Dosing Pumps mL/S
    min: 0
    max: 2000
    step: 1
    initial: 1300
    unit_of_measurement: mL/mS
    mode: box
And finally the ESPHOME yaml

Code: Select all

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO12
      mode: INPUT_PULLUP
      inverted: False
    name: "Select Button"
    on_press:
       then:
        - switch.turn_on: 'grow'
        - delay: !lambda "return id(grow_pump_ml).state * 1300;"
        - switch.turn_off: 'grow'
        - delay: 1s
        - switch.turn_on: 'micro'
        - delay: !lambda "return id(micro_pump_ml).state * 1300;"
        - switch.turn_off: 'micro'
        - delay: 1s
        - switch.turn_on: 'bloom'
        - delay: !lambda "return id(bloom_pump_ml).state * 1300;"
        - switch.turn_off: 'bloom'
        - delay: 1s
        - switch.turn_on: 'velokelp'
        - delay: !lambda "return id(velokelp_pump_ml).state * 1300;"
        - switch.turn_off: 'velokelp'
        - delay: 1s
        - switch.turn_on: 'bloom_booster'
        - delay: !lambda "return id(bloom_booster_pump_ml).state * 1300;"
        - switch.turn_off: 'bloom_booster'
        - delay: 1s
        - switch.turn_on: 'magnifical'
        - delay: !lambda "return id(magnifical_pump_ml).state * 1300;"
        - switch.turn_off: 'magnifical'
        - delay: 5s

  - platform: gpio
    pin:
      number: GPIO14
      mode: INPUT_PULLUP
      inverted: False
    name: "R.O. Valve"
    on_press:
       then:
         - switch.toggle: 'ro_valve'

  - platform: gpio
    pin:
      number: GPIO27
      mode: INPUT_PULLUP
      inverted: False
    name: "Down Button"

  - platform: gpio
    pin:
      number: GPIO26
      mode: INPUT_PULLUP
      inverted: False
    name: "Up Button"


sensor:
   - platform: homeassistant
     name: "Micro Pump Doser"
     entity_id: input_number.micro_pump_ml
     id: micro_pump_ml

   - platform: homeassistant
     name: "Bloom Pump Doser"
     entity_id: input_number.bloom_pump_ml
     id: bloom_pump_ml

   - platform: homeassistant
     name: "MagNiFiCal Pump Doser"
     entity_id: input_number.magnifical_pump_ml
     id: magnifical_pump_ml

   - platform: homeassistant
     name: "Bloom Booster Pump Doser"
     entity_id: input_number.bloom_booster_pump_ml
     id: bloom_booster_pump_ml
     
   - platform: homeassistant
     name: "VeloKelp Pump Doser"
     entity_id: input_number.velokelp_pump_ml
     id: velokelp_pump_ml

   - platform: homeassistant
     name: "Grow Pump Doser"
     entity_id: input_number.grow_pump_ml
     id: grow_pump_ml

   - platform: homeassistant
     name: "Nutrient Doser Toggle"
     entity_id: input_boolean.nutrient_dosing_toggle
     id: nutrient_dosing_toggle


 switch:
  - platform: gpio
    pin: GPIO15
    name: "Reverse Osmosis Valve"
    id: ro_valve
    inverted: yes
  - platform: gpio
    pin: GPIO02
    name: "Grow"
    id: grow
    inverted: yes
  - platform: gpio
    pin: GPIO0
    name: "Bloom"
    id: bloom
    inverted: yes
  - platform: gpio
    pin: GPIO04
    name: "Micro"
    id: micro
    inverted: yes
  - platform: gpio
    pin: GPIO16
    name: "MagNiFiCal"
    id: magnifical
    inverted: yes
  - platform: gpio
    pin: GPIO17
    name: "VeloKelp"
    id: velokelp
    inverted: yes
  - platform: gpio
    pin: GPIO5
    name: "Bloom Booster"
    id: bloom_booster
    inverted: yes
  - platform: gpio
    pin: GPIO18
    name: "PH Down"
    inverted: yes
    
User avatar
LEDG
Site Admin
Reactions:
Posts: 1599
Joined: Sun Jun 04, 2017 8:15 pm

Man, you got good at this fast. Nice work.
Want to Support the Site?

Use this Amazon referral link and any purchase you make within 24 hrs will earn LEDgardener a commission at no cost to you!
stud
LED Lover
LED Lover
Reactions:
Posts: 143
Joined: Wed Jun 03, 2020 4:19 pm
Location: Canada

this forum and community rocks ! thx for sharing code
Baylos
LED-Curious
LED-Curious
Reactions:
Posts: 22
Joined: Sat Nov 07, 2020 11:49 am

Dears,

Thanks a lot to all of you. Only with your information, I was able to build my control box.

I purchase Adafriut peristaltic pump (1150). I also had to adjust the value to 1300. I wait for the final parts of my housing and assembly of everything once got it.

Greetings
morrisraybrooks
LED Enthusiast
LED Enthusiast
Reactions:
Posts: 57
Joined: Fri Dec 04, 2020 3:27 am

i have ben trying to mod this to fit my situation but cane seam to get it right i got the configuration.yaml and the ESPhome.yaml out of the way im stuck on the automation.yaml trying to run this on a pi4 my control box has a ESP32
Post Reply