Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Get Indoor Air Temperature of Thermal Zone (during Runtime)

asked 2020-12-24 19:19:29 -0500

Chelydrae's avatar

updated 2021-03-29 08:58:58 -0500

Dear all,

I am looking for a solution on a beginner problem:

I want to extract the indoor air temperature of one specific thermal zone during runtime (with the python api). I did not find a solution in the documentation yet. Any hint is highly welcome!

Best Regards, P

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-12-27 07:02:29 -0500

hermmanhender's avatar

updated 2020-12-27 07:04:11 -0500


Here a possible solution to your problem.

import sys
sys.path.insert(0, 'C:/EnergyPlusV9-4-0')
from pyenergyplus.api import EnergyPlusAPI
api = EnergyPlusAPI()

#Define your function to execute in runtime
def my_function(state):
   if #Necessary condition
        if == 0:
           # Handles
           To_handle =, "Site Outdoor Air Drybulb Temperature", "Environment")
           Ti_handle =, "Zone Mean Air Temperature", "Thermal Zone: Modelo_Simple")
           # Variable value
           To =, To_handle)      
           Ti =, Ti_handle)
           '''Here you can put Ti in a DataFrame, array, other'''

#After define you function, you must initializate the program
state = api.state_manager.new_state() #Necessary condition
api.runtime.callback_begin_zone_timestep_after_init_heat_balance(state, my_function)
api.runtime.run_energyplus(state, ['-d', Folder_Output_path, '-w', Weather_file_path, IDF_file_path])

I hope that this code will be useful.

Best Regards, Germán Henderson

edit flag offensive delete link more


Thank you very much German! I found another solution using EMS but your approach is much better!

Chelydrae's avatar Chelydrae  ( 2020-12-27 14:51:33 -0500 )edit

I tried to put Ti in a DataFrame, but I do not manage to access the dataframe after the simulation complete. I got the error "python cannot be converted to pointer". What would be the best way the get these values ?

LeaGon's avatar LeaGon  ( 2021-06-30 10:21:59 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops


Question Tools

1 follower


Asked: 2020-12-24 19:19:29 -0500

Seen: 206 times

Last updated: Dec 27 '20