Skip to content

Instantly share code, notes, and snippets.

Last active Jul 12, 2021
What would you like to do?
Python Plugin Relative Humidity Actuator Example
Rel Hum Test, !- Name
Yes, !- Run During Warmup Days
PythonTest, !- Python Module Name
Test; !- Plugin Class Name
MyGlobalVariables, !- Name
RelHumFromOutputVar, !- Variable Name 1
RelHumFromActuator; !- Variable Name 2
Rel Hum From Output Variable, !- Name
RelHumFromOutputVar, !- Python Plugin Variable Name
Averaged, !- Type of Data in Variable
SystemTimestep; !- Update Frequency
Rel Hum From Actuator, !- Name
RelHumFromActuator, !- Python Plugin Variable Name
Averaged, !- Type of Data in Variable
SystemTimestep; !- Update Frequency
Output:Variable,*,Site Outdoor Air Relative Humidity,hourly;
Output:Variable,Rel Hum From Output Variable,PythonPlugin:OutputVariable,hourly;
Output:Variable,Rel Hum From Actuator,PythonPlugin:OutputVariable,hourly;
class Test(EnergyPlusPlugin):
def __init__(self):
# class member variables
self.relhum_from_output_var_handle = None
self.relhum_from_actuator_var_handle = None
self.outdoor_air_relhum_handle = None
self.outdoor_air_relhum_actuator_handle = None
self.need_to_get_handles = True
def get_handles(self, state):
# get variable handles and save for later
self.outdoor_air_relhum_handle =,
"Site Outdoor Air Relative Humidity",
self.outdoor_air_relhum_actuator_handle =,
"Weather Data",
"Outdoor Relative Humidity",
self.relhum_from_output_var_handle =, "RelHumFromOutputVar")
self.relhum_from_actuator_var_handle =, "RelHumFromActuator")
self.need_to_get_handles = False
def on_begin_zone_timestep_before_set_current_weather(self, state) -> int:
# initialize if the API is ready
if self.need_to_get_handles:
return 0
# get the current relative humidity value from the output variable, assign it to the global variable
current_relhum =, self.outdoor_air_relhum_handle), self.relhum_from_output_var_handle, current_relhum)
# set the new ODA relhum value via the actuator and assign it to the global variable
new_relhum = 34.56789, self.outdoor_air_relhum_actuator_handle, new_relhum), self.relhum_from_actuator_var_handle, new_relhum)
return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment