Global variables or a similar function?

My current grow room setup has a small anti room that is cooled and than pumps the cool air into a grow room. I have a few functions setup, one is to control the temp inside the grow room. This regulates temp: IF temp >24 fan on else if <22 fan off. The other is a timer duration, which turns the fan on 20 min every 4 hours. This is to cycle fresh air in.

What currently happens is if temp is below 22 then it wont allow the timer duration function to work, i need to cycle air regardless if the temp is below my desired set point.

Is there a way to use like a global variable that i could use to tell one function that another functions if statement is true? Read through a lot of the documentation, but dont seem to find what i require. Any help i how would go about this would be great.
Thanks,

I am assuming your fan control function is a Conditional Controller. So you have:

  1. Conditional Controller - Turn fan on or off based on temperature
  2. Duration Timer - Every 4 hours: Turn fan on for 20 minutes

What immediately comes to mind is deactivating the Conditional Controller for the 20 minute duration the fan is on so that it doesn’t turn it off prematurely, then activating it once the 20 minutes is over. There are a number of ways to do this, but here is one such setup:

  1. Conditional Controller - Turn fan on or off based on temperature
  2. Duration Timer 1 - Period: 1 hour, Start Offset: 20 minutes
    a. Action: Activate Conditional Controller
    b. Action: Deactivate Duration Timer 1
  3. Duration Timer 2 - Period: 4 hours
    a. Action: Deactivate Conditional Controller
    b. Action: Turn fan on for 20 minutes
    c. Action: Activate Duration Timer 1

What this does is deactivate the Conditional Controller so it doesn’t turn the fan off, and activate a second Duration Timer that won’t execute its Actions until 20 minutes have passed, at which time it will activate the Conditional Controller and deactivate itself.

Thanks that makes sense. I was trying to approach the issue without deactivating anything, which lead me down the wrong path of solving my issue.

One thought i had to solve this issue was if it was be possible to determine if a self.condition was true. IE. when setting up a number of conditions, I can have the same output selected but have a unique id for each.


so I thought I could have it that one function could check if another functions unique id is true/running.

So for my example:

  1. Conditional function (Temp control) fan on when above 24 off when below 22
  2. Duration timer (fresh air in regardless of temp) - every four hours turn fan on

and within the temp control function i would have something like…

if measurement < 22 and self.condition("{fc3f5abc}"):  # If the measurement is less than 22 and duration timer fan on self.condition not true, than turn fan off
        self.run_action("{ddf20a0b}")  # Run fan
     elif measurement > 24:
        self.run_action("{2a0a9952}") # Turn fan off

Is this possible? or am wrong in this thought process?