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

Schedule Value handle does not work in Python EMS

asked 2025-02-04 18:54:05 -0500

efrainpuerto's avatar

updated 2025-02-05 20:12:43 -0500

Good day!

I'm need to create a user defined object managed by a python plug-in, all works perfect but the handle of schedule value, I've already added the output variable in the IDF file and I've checked the name of the schedule too. I tried a simple box plug-in using the example of E+ (https://wetransfer.com/downloads/6891...) and it happens exactly the same when I change the simulation settings. Can someone explain me what am I missing? Hi Julien, thank your for your celerity to answer. The file I linked is just the example file of EnergyPlus (PythonPluginUserDefinedWindACAuto.py) I just simplified the code to just let the basic concept of the problem, if you keep all the running conditions of the file, the plugin run with the python code:

self.handles["COOLINGCOILAVAILSCHED"] = self.api.exchange.get_variable_handle(
    state,
    "Schedule Value",
    "COOLINGCOILAVAILSCHED"
)

So the python code is fine. However if you changed the running conditions in the IDF file:

SimulationControl,
    No,                      !- Do Zone Sizing Calculation
    No,                      !- Do System Sizing Calculation
    No,                      !- Do Plant Sizing Calculation
    No,                      !- Run Simulation for Sizing Periods
    Yes,                     !- Run Simulation for Weather File Run Periods
    No,                      !- Do HVAC Sizing Simulation for Sizing Periods
    1;                       !- Maximum Number of HVAC Sizing Simulation Passes

Suddenly the file launch the error of "handle not found", i just wanted to change a ZoneHVAC object I'm using to a ZoneHVAC UserDefined object, with the EnergyPlus ZoneHVAC object the IDF file works fine, but when I substituted for the ZoneHVAC:UserDefined, suddenly launched that error. In my opinion, there is a bug in the program, you need to keep "Do Zone Sizing Calculation" in "Yes" and add the Zone Sizing objects even if you don't need them to make the code work correctly. My objective with the schedule is not modified it but to read the availability to turn on or off my User Defined Object.

edit retag flag offensive close merge delete

Comments

(You should try to give out more information about what's not working, that'd be helpful. Going to download a zip file from wetransfer is an extra step that most people won't do)

Julien Marrec's avatar Julien Marrec  ( 2025-02-05 02:27:07 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2025-02-05 02:29:10 -0500

updated 2025-02-05 02:35:04 -0500

I would suggest you look at PythonPluginCustomSchedule.py / PythonPluginCustomSchedule.idf as a starting point.

From a cursory look, you're just using the wrong method: it should be api.exchange.get_actuator_handle not self.api.exchange.get_variable_handle.

Current problem

For reference, your schedule in the IDF is a Schedule:Compact.

Schedule:Compact,
    COOLINGCOILAVAILSCHED,   !- Name
    [...];

You're doing

    self.handles["COOLINGCOILAVAILSCHED"] = self.api.exchange.get_variable_handle(
        state,
        "Schedule Value",
        "COOLINGCOILAVAILSCHED"
    )

and getting this error

 ** Severe  ** Handle not found for 'COOLINGCOILAVAILSCHED'
 **  Fatal  ** Python Plugin "PythonPluginUserDefinedWindACAuto.Zone1WinACModel" returned 1 to indicate EnergyPlus should abort

Solution

You should be doing

    self.handles["COOLINGCOILAVAILSCHED"] = self.api.exchange.get_actuator_handle(
        state,
        "Schedule:Compact", 
        "Schedule Value",
        "COOLINGCOILAVAILSCHED"
    )

And then your file will run to completion.

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

1 follower

Stats

Asked: 2025-02-04 18:54:05 -0500

Seen: 73 times

Last updated: Feb 05