Dummy Switch for Growing Stages

Hello everybody, is it possible to make a Dummy switch without real function with the two states true/false ? I need this to make different nutrients schedule for different growing stages. It is planned to make this with a condition controller.
Like this…
Growing stages:

  1. Root
  2. Growth
  3. Bloom
    Example:
    If Root = true and ec_measure_root < range_ec_root_low
    self.run_action (pump_nut_A)

The same with humidity and temp for the three stages

The three stages i want to switch with a time trigger or something else (method ?) like this:
first week = root, week 2-4 = growth, week 4-12 = Bloom.

The dummy switch can then be displayed in the dashboard to see which growing stage is active

Is it possible to make this.

Thanks for your help and your great software

1 Like

Hi Phil. Sure, you can just add a Shell Script (On/Off) Output and just not fill in any commands for the on or off, and you will essentially have an output that you can switch on and off but will do nothing beyond that.

Hi Kyle, thanks for your quick answer :grinning:
Thats perfect, thanks.
And do you have a easy solution to switch between the three stages with a time trigger ?
And can i put the nutrition volumes like 1ml in a constant in the script, because i have for every nutrition different volumes in the different stages ?
Edit:
Or do i have to make more actions to dispense different volumes with the same pump ?

1 Like

Is it possible like this ?

### Edit below to set desired ranges for pH and electrical conductivity ###
# Desired range for electrical conductivity

range_ec_high_root = 600
range_ec_low_root = 300

range_ec_high_growth = 1800
range_ec_low_growth = 1300

range_ec_high_bloom = 2200
range_ec_low_bloom = 1400

# Desired range for pH

range_ph_high = 6.5
range_ph_low = 5.5

# pH range that will immediately cause a pH correction

range_ph_high_danger = 7.0
range_ph_low_danger = 5.0

### Edit below to set the IDs for Conditions and Actions ###

condition_id_measurement_ph_id = "{PH_MEASURE_ID}"  # Condition: measurement, last, pH Input
condition_id_measurement_ec_id = "{EC_MEASURE_ID}"  # Condition: measurement, last, EC Input
action_id_pump_1_acid = "{PUMP_1_ID}"  # Action: Pump 1 (Acid)
action_id_pump_2_base = "{PUMP_2_ID}"  # Action: Pump 2 (Base)

#Growing stages

root_switch = "{switch1_ID}"
growth_switch = "{switch2_ID}"
bloom_switch = "{switch3_ID}"

#Root
action_id_pump_3_nutrient_a_root = "{PUMP_3_ID}"  # Action: Pump 3 (Nutrient A)
action_id_pump_4_nutrient_b_root = "{PUMP_4_ID}"  # Action: Pump 4 (Nutrient B)
action_id_pump_5_nutrient_c_root = "{PUMP_5_ID}"  # Action: Pump 5 (Nutrient C)
action_id_pump_6_nutrient_d_root = "{PUMP_6_ID}"  # Action: Pump 6 (Nutrient D)
action_id_pump_7_nutrient_e_root = "{PUMP_7_ID}"  # Action: Pump 7 (Nutrient E)

#Growth
action_id_pump_3_nutrient_a_growth = "{PUMP_3_ID}"  # Action: Pump 3 (Nutrient A)
action_id_pump_4_nutrient_b_growth = "{PUMP_4_ID}"  # Action: Pump 4 (Nutrient B)
action_id_pump_5_nutrient_c_growth = "{PUMP_5_ID}"  # Action: Pump 5 (Nutrient C)
action_id_pump_6_nutrient_d_growth = "{PUMP_6_ID}"  # Action: Pump 6 (Nutrient D)
action_id_pump_7_nutrient_e_growth = "{PUMP_7_ID}"  # Action: Pump 7 (Nutrient E)

#Bloom
action_id_pump_3_nutrient_a_bloom = "{PUMP_3_ID}"  # Action: Pump 3 (Nutrient A)
action_id_pump_4_nutrient_b_bloom = "{PUMP_4_ID}"  # Action: Pump 4 (Nutrient B)
action_id_pump_5_nutrient_c_bloom = "{PUMP_5_ID}"  # Action: Pump 5 (Nutrient C)
action_id_pump_6_nutrient_d_bloom = "{PUMP_6_ID}"  # Action: Pump 6 (Nutrient D)
action_id_pump_7_nutrient_e_bloom = "{PUMP_7_ID}"  # Action: Pump 7 (Nutrient E)


action_id_email_notification = "{EMAIL_ID}"  # Action: Email Notification

### DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING ###

import time
if 'notify_ec' not in self.variables:  # Initiate EC notification timer
    self.variables['notify_ec'] = 0
if 'notify_ph' not in self.variables:  # Initiate pH notification timer
    self.variables['notify_ph'] = 0
if 'notify_none' not in self.variables:  # Initiate None measurement notification timer
    self.variables['notify_none'] = 0
measure_ec = self.condition(condition_id_measurement_ec_id)
measure_ph = self.condition(condition_id_measurement_ph_id)
self.logger.debug("Conditional check. EC: {}, pH: {}".format(measure_ec, measure_ph))
if None in [measure_ec, measure_ph]:
    if measure_ec is None:
        self.message += "\nWarning: No EC Measurement! Check sensor!"
    if measure_ph is None:
        self.message += "\nWarning: No pH Measurement! Check sensor!"
    if self.variables['notify_none'] < time.time():  # Only notify every 12 hours
        self.variables['notify_none'] = time.time() + 43200  # 12 hours
        self.run_action(action_id_email_notification, message=self.message)  # Email alert
    return
    
# First check if pH is dangerously low or high, and adjust if it is

if measure_ph < range_ph_low_danger:  # pH dangerously low, add base (pH up)
    msg = "pH is dangerously low: {}. Should be > {}. Dispensing 1 ml base".format(measure_ph, range_ph_low_danger)
    self.logger.debug(msg)
    self.message += msg
    self.run_action(action_id_pump_2_base)  # Dispense 1 ml base (pH up)
    if self.variables['notify_ph'] < time.time():  # Only notify every 12 hours
        self.variables['notify_ph'] = time.time() + 43200  # 12 hours
        self.run_action(action_id_email_notification, message=self.message)  # Email alert
elif measure_ph > range_ph_high_danger:  # pH dangerously high, add acid (pH down)
    msg = "pH is dangerously high: {}. Should be < {}. Dispensing 1 ml acid".format(measure_ph, range_ph_high_danger)
    self.logger.debug(msg)
    self.message += msg
    self.run_action(action_id_pump_1_acid)  # Dispense 1 ml acid (pH down)
    if self.variables['notify_ph'] < time.time():  # Only notify every 12 hours
        self.variables['notify_ph'] = time.time() + 43200  # 12 hours
        self.run_action(action_id_email_notification, message=self.message)  # Email alert
        
### If pH isn't dangerously low or high, check if EC is within range

#Root

elif measure_ec < range_ec_low_root and root_switch = True:  # EC too low, add nutrient
    self.logger.debug("EC: {}. Should be > {}. Dosing 3 ml Nut A, 3 ml Nut B".format(measure_ec, range_ec_low_root))
    self.run_action(action_id_pump_3_nutrient_a_root)  # Dispense 3 ml nutrient A
    self.run_action(action_id_pump_4_nutrient_b_root)  # Dispense 3 ml nutrient B
    self.run_action(action_id_pump_5_nutrient_c_root)  # Dispense 3 ml nutrient C
    self.run_action(action_id_pump_6_nutrient_d_root)  # Dispense 3 ml nutrient D
    self.run_action(action_id_pump_7_nutrient_e_root)  # Dispense 3 ml nutrient E
    
#Growth

elif measure_ec < range_ec_low_growth and growth_switch = True:  # EC too low, add nutrient
    self.logger.debug("EC: {}. Should be > {}. Dosing 3 ml Nut A, 3 ml Nut B".format(measure_ec, range_ec_low_growth))
    self.run_action(action_id_pump_3_nutrient_a_growth)  # Dispense 3 ml nutrient A
    self.run_action(action_id_pump_4_nutrient_b_growth)  # Dispense 3 ml nutrient B
    self.run_action(action_id_pump_5_nutrient_c_growth)  # Dispense 3 ml nutrient C
    self.run_action(action_id_pump_6_nutrient_d_growth)  # Dispense 3 ml nutrient D
    self.run_action(action_id_pump_7_nutrient_e_growth)  # Dispense 3 ml nutrient E
    
#Bloom

elif measure_ec < range_ec_low_bloom and bloom_switch = True:  # EC too low, add nutrient
    self.logger.debug("EC: {}. Should be > {}. Dosing 3 ml Nut A, 3 ml Nut B".format(measure_ec, range_ec_low_bloom))
    self.run_action(action_id_pump_3_nutrient_a_bloom)  # Dispense 3 ml nutrient A
    self.run_action(action_id_pump_4_nutrient_b_bloom)  # Dispense 3 ml nutrient B
    self.run_action(action_id_pump_5_nutrient_c_bloom)  # Dispense 3 ml nutrient C
    self.run_action(action_id_pump_6_nutrient_d_bloom)  # Dispense 3 ml nutrient D
    self.run_action(action_id_pump_7_nutrient_e_bloom)  # Dispense 3 ml nutrient E
    
elif measure_ec > range_ec_high:  # EC too high, add water
    msg = "EC: {}. Should be < {}. Need to add water to dilute!".format(measure_ec, range_ec_high)
    self.logger.debug(msg)
    if self.variables['notify_ec'] < time.time():  # Only notify every 12 hours
        self.variables['notify_ec'] = time.time() + 43200  # 12 hours
        self.message += msg
        self.run_action(action_id_email_notification, message=self.message)  # Email alert
        
        
# If EC is in range, make sure pH is within range


elif measure_ph < range_ph_low:  # pH too low, add base (pH up)
    self.logger.debug("pH is {}. Should be > {}. Dispensing 1 ml base".format(measure_ph, range_ph_low))
    self.run_action(action_id_pump_2_base)  # Dispense 1 ml base (pH up)
elif measure_ph > range_ph_high:  # pH too high, add acid (pH down)
    self.logger.debug("pH is {}. Should be < {}. Dispensing 1 ml acid".format(measure_ph, range_ph_high))
    self.run_action(action_id_pump_1_acid)  # Dispense 1 ml acid (pH down)
1 Like

thats exactly what i’m looking for.
i need growth and bloom stage - as well as three-part-nutrient.

i thought about using two conditional controllers (one for growth, one for bloom) for that.
but that combined one looks great.
is it working for you? :slight_smile:

1 Like

Combining multiple stages in one Conditional Controller would be difficult, since you will need to introduce the use of dates/times, and can also introduce all sorts of issues if you haven’t thoroughly tested your code under various conditions. I would recommend that if you do use one Conditional with multiple different desired EC or nutrient ratios/values, that you merely comment out the ones you don’t need and only have one set uncommented and running. You can then comment out the current set and uncomment the new set when you want to switch to another stage. For example:

# germination stage
ec_ppm = 300
nutrient_a = 1
nutrient_b = 1
nutrient_c = 1

# vegetative stage
# ec_ppm = 1200
# nutrient_a = 1
# nutrient_b = 2
# nutrient_c = 3

And to go to the next stage, change to:

# germination stage
# ec_ppm = 300
# nutrient_a = 1
# nutrient_b = 1
# nutrient_c = 1

# vegetative stage
ec_ppm = 1200
nutrient_a = 1
nutrient_b = 2
nutrient_c = 3

You could also contain these in a dictionary to select the variable set by changing just one variable, for example:

# Select the stage
stage = 1

growth_stages = {
    1: {  # germination
        "ec": 400,
        "nutrient_a": 1,
        "nutrient_b": 1,
        "nutrient_c": 1
    },
    2: {  # vegetative
        "ec": 1200,
        "nutrient_a": 1,
        "nutrient_b": 2,
        "nutrient_c": 3
    }
}

self.logger.debug(f"Selected growth stage parameters: {growth_stages[stage]}")

Alternatively, the most foolproof way of doing it, which doesn’t require any changing of code (a single typo could cause an error that will prevent the code from running), involves setting up multiple Conditional Controllers, each with a different set of parameters, and merely deactivating all but the one with the desired parameters. I go a bit further and create Execute Actions Functions and add Actions that deactivate all controllers, and one Action to activate the desired controller. This way I can, in one click, change to a different stage and I’m assured there is no possibility of an issue being introduced by a typo or mixing up which needs to be deactivated or activated. These Execute Actions Functions can be labeled like “Germination Stage”, “Flowering Stage”, be placed at the top of the Function page, and be separated by a Spacer Function to organize them separately from the actual Functions that are doing the work.

1 Like