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

Revision history [back]

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

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)