Hi,
Had a working system just with an i2c temp sensor issue, upgraded to master in case this was addressed. But now find my conditional controller is throwing errors:
# Desired range for electrical conductivity
range_ec_high = 1500 # 2.5 During Fruiting
range_ec_low = 1200 # 1.8 During Fruiting
# Desired range for pH
range_ph_high = 6.3
range_ph_low = 5.8
# 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 = "{862e818d}" # Condition: measurement, last, pH Input
condition_id_measurement_ec_id = "{268cc649}" # Condition: measurement, last, EC Input
action_id_pump_1_acid = "{99c85210}" # Action: Pump 1 (Acid)
action_id_pump_2_base = "{b204ce29}" # Action: Pump 2 (Base)
action_id_pump_2_nutrient_a = "{0e20dfa7}" # Action: Pump 3 (Nutrient A)
###action_id_pump_3_nutrient_b = "{14260317}" # Action: Pump 3 (Nutrient B)
action_id_email_notification = "{e4ca2133}" # 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
elif measure_ec < range_ec_low: # 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))
self.run_action(action_id_pump_3_nutrient_a) # Dispense 3 ml nutrient A
self.run_action(action_id_pump_4_nutrient_b) # Dispense 3 ml nutrient B
elif measure_ec > range_ec_high: # EC too high, add nutrient
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)
************* Module mycodo.user_python_code.conditional_432bdfe1-99e2-4212-a3af-4b283c82f836
craig/Mycodo/mycodo/user_python_code/conditional_432bdfe1-99e2-4212-a3af-4b283c82f836.py:41:8: C0415: Import outside toplevel (time) (import-outside-toplevel)
craig/Mycodo/mycodo/user_python_code/conditional_432bdfe1-99e2-4212-a3af-4b283c82f836.py:50:26: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
craig/Mycodo/mycodo/user_python_code/conditional_432bdfe1-99e2-4212-a3af-4b283c82f836.py:62:18: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
craig/Mycodo/mycodo/user_python_code/conditional_432bdfe1-99e2-4212-a3af-4b283c82f836.py:70:18: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
craig/Mycodo/mycodo/user_python_code/conditional_432bdfe1-99e2-4212-a3af-4b283c82f836.py:79:30: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
craig/Mycodo/mycodo/user_python_code/conditional_432bdfe1-99e2-4212-a3af-4b283c82f836.py:80:28: E0602: Undefined variable 'action_id_pump_3_nutrient_a' (undefined-variable)
craig/Mycodo/mycodo/user_python_code/conditional_432bdfe1-99e2-4212-a3af-4b283c82f836.py:81:28: E0602: Undefined variable 'action_id_pump_4_nutrient_b' (undefined-variable)
craig/Mycodo/mycodo/user_python_code/conditional_432bdfe1-99e2-4212-a3af-4b283c82f836.py:83:18: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
craig/Mycodo/mycodo/user_python_code/conditional_432bdfe1-99e2-4212-a3af-4b283c82f836.py:91:30: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
craig/Mycodo/mycodo/user_python_code/conditional_432bdfe1-99e2-4212-a3af-4b283c82f836.py:94:30: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
craig/Mycodo/mycodo/user_python_code/conditional_432bdfe1-99e2-4212-a3af-4b283c82f836.py:37:8: W0612: Unused variable 'action_id_pump_2_nutrient_a' (unused-variable)
craig/Mycodo/mycodo/user_python_code/conditional_432bdfe1-99e2-4212-a3af-4b283c82f836.py:101:58: E1101: Instance of 'ConditionalRun' has no 'loop_count' member (no-member)
craig/Mycodo/mycodo/user_python_code/conditional_432bdfe1-99e2-4212-a3af-4b283c82f836.py:102:26: E1101: Instance of 'ConditionalRun' has no 'loop_count' member (no-member)
-----------------------------------
Your code has been rated at 6.46/10
Any thoughts what has changed. Thanks