Scheduling multiple stages of growth

Hi Kyle,

First and foremost, thanks for all the effort you have put in here. What an amazing job you’ve done so far!

My question is regarding schedules over time. Is there a way to schedule different sets of parameters for the different stages of growth? IE raising the conductivity over each passing week, changing nutrient ratios, or changing to a different light schedule after so many weeks?

I’m trying to understand more before I start buying parts. I tried running raspberry OS on a HyperV VM to test it out. It fails with the InfluxDB install due to architecture differences.

So I figured I would just ask you and then buy the parts. Thanks in advance for your support!


1 Like

My guess would be that the easiest way is to add the capability to the EC control function. You could probably create an array with a value for each week and have it use those as the setpoints.

I guess the way I would do it is add a variable called start which holds the timestamp for the beginning of the growth cycle. Python can convert this into a timestamp and you can check up against this to see if a week have passed. Something like this:

ECvalues = [[0,900],[1,1000],[2,1100],[3,2000]]
Where the first parameter is the week since start and the second is the desired EC value.

Anyhow, the short answer is yes, it can be done, but there is no build in function I think.

It would be nice with some sort of valuables per time function somewhere. So you could merely link to these valuables from all functions and it would hold all sorts of data like temperature, EC, pH etc.

Jacob, Thank you for your input here! I’m new to this whole thing but I learn pretty quick. I need to do some reading to understand more about how to apply what you’ve said but I’ll take it as a logical option is there and I will figure it out.

I understand the concept of what you’re getting at with the coding experience that I have. I just don’t know python yet. This is a good simple task for me to start with. Thanks.

What @jacobguldbergdk said is one way to do it, and relies on a bit of Python coding. There are a number of ways to accomplish what you’re describing. If using a PID controller, you can use Methods to change the setpoint over time, which can be developed in the UI. But for non-PID control, with something like a Conditional Controller, creating some sort of array with desired measurement at a particular time can accomplish the same effect.

In thinking about developing a Custom Functions, it just dawned on me that there should be a way for the UI to display feedback from the running controller, by periodically executing a status function in the controller, which can return information about it in the current moment, such as how far along in a cycle it is, certain variable values, etc. This can further be used by Custom Widgets to display information on the Dashboard or elsewhere. Currently the only way to get feedback from a running Function Controller is to have it print log lines to the Daemon Log, but this is not the best solution for casually viewing status information.

Mycodo has already been designed to run in Docker, so if you want to try it out without a Pi, this will allow you to install it on virtually any operating system.

There are several functions used by Mycodo that allow comparing the current time to user-set time. I will see if I can make these more accessible to Conditional Controllers and perhaps add it to the Docs and/or FAQs.

Kyle, thanks for the explanation. I am just going to order the Pi since I’m interested in tinkering anyway.

I’m sure I will find a way to make it work and hopefully be able to share my results.

1 Like

Cool. I never looked into the Method thing. I somehow got the idea that Methods was a thing being out phased.

I created for instance a calendar based function here. How do I access this value from inside the conditional controller? Or from a PID function?

Try this. I pulled it from the PID controller and it should work in a Conditional Controller but I haven’t tested it. start_time is only used for Duration Methods, and would be preferable if you wanted to reuse time-based Methods and not have to go back and change all the dates in the Method, since it operates based on time since the start time. You would merely change the start time and it will calculate the setpoint from whatever that start time is.

import datetime
from mycodo.utils.method import load_method_handler

now =
start_time = "2021-05-25 15:00:00"

method = load_method_handler(METHOD_ID)
setpoint, ended = method.calculate_setpoint(now, start_time)"Setpoint: {}, Ended: {}".format(setpoint, ended))

PID controllers have the ability to select a Method in the options, near the bottom.

Here’s the example Function I just got working as a proof-of-concept. Inside the Function Module is a function:

    def function_status(self):
        return_dict = {
            'string_status': "Current time: {}\nLoop count: {}".format(
      , self.loop_counter),
            'error': []
        return return_dict

Which merely returns a dictionary. The frontend will display the “string_status” above the options of the Function, allowing direct feedback about what’s going on with the Function. This one merely shows the current time and an internal counter, and updates on the UI every 60 seconds. I think the first actual implementation I’ll make is the PID controller showing the current P, I, and D values, among other variables. This will also allow custom Widgets to get information about Functions to display, so one could make custom Functions and Widgets that share information and interact in more complex ways.

And a simple Function Status Widget is born!

1 Like

Alright, last update before I commit these additions… The status from PID Controllers is working now. The style will be tweaked before release, but the important part is it’s working. This may even expand into a more universal and direct way for all Controllers to share information to other parts of Mycodo.

1 Like

Just got my Pi 4 in the mail about an hour ago. I have some catching up to do. Anxious to get this stuff loaded up.


Thats pretty cool. I love to be able to see the value of variables and function status on the dashboard.

I have build other control systems in the pass (like a brew system controller) and its nice to also see the setpoints on charts, especially if they change over time.

Like this temp chart from my 3d printer

1 Like

I made a python input that creates a set of variables I can chart as limits. Its not connected to the actual limits, but it does the trick.

Red is upper limit, blue is lower. There are 2 sets because pH and EC are displayed together.

1 Like