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

How do I correctly use the DataTransfer Python Api for EnergyPlus?

asked 2021-10-07 04:08:57 -0500

rd1's avatar

updated 2021-10-07 11:05:32 -0500

Im trying to get the "Zone Air Temperature" for "Thermal Zone 1" and the "System Node Temperature" for my "Setpoint Node".

zone_air_temperature = api.exchange.get_variable_handle(state, u"Zone Air Temperature", u"Thermal Zone 1") setpoint_node_temperature = api.exchange.get_variable_handle(state, u"System Node Temperature u"Setpoint Node")

Am I understanding this wrong?

Thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-10-08 02:32:01 -0500

I have a working example of this on https://github.com/jmarrec/OpenStudio...

A Minimum Complete Verifiable Example (MCVE) might be something along these lines:

got_handles = False
zone_temp_handle = -1

def callback_function(state_argument):
    globalgot_handles, oa_temp_handle, zone_temp_handle
    if not got_handles:
        if not api.exchange.api_data_fully_ready(state_argument):
            return
        zone_temp_handle = api.exchange.get_variable_handle(state_argument, "Zone Mean Air Temperature", "Thermal Zone 1")

        if zone_temp_handle == -1:
            print("***Invalid handles, check spelling and sensor/actuator availability")
            sys.exit(1)
        got_handles = True
    if api.exchange.warmup_flag(state_argument):
        return
    zone_temp = api.exchange.get_variable_value(state_argument, zone_temp_handle)
    print(zone_temp)
edit flag offensive delete link more

Your Answer

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

Add Answer

Training Workshops

Careers

Question Tools

Stats

Asked: 2021-10-07 04:08:57 -0500

Seen: 186 times

Last updated: Oct 08 '21