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

Trouble getting variable handle in PythonPlugin

asked 2020-11-28 16:03:55 -0600

updated 2020-12-08 22:43:03 -0600

I'm having trouble getting some variable handles using PythonPlugin in energyplus. I wonder if all the variables listed in the *.rdd output file are available for the python plugin ...

For example here is what I got in the *.rdd file:

Output:Variable,prm,Plant Supply Side Cooling Demand Rate,hourly; !- HVAC Average []

and here is what I used in my python script to get the handle:

self.sensors["demand rate"] = self.e.get_variable_handle(
              state, "Plant Supply Side Cooling Demand Rate", "prm")

Unfortunately, the API returns -1 value for this variable and some other variables. I can't figure out what's the problem. It seems that all the variables listed in the *.rdd file cannot be handled by PythonPlugin. If I'm right, how can one identify available variables(sensors) for each model? I hope that you can help me with this.

P.S.

self.e = self.api.exchange
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2020-12-01 05:38:49 -0600

Red's avatar

The get_variable_handle method of the Data Transfer API takes 3 input parameters:

state, variable_name , and variable_key.

You should first request the variable to be available for access during simulations, by adding an Output:Variable to your input file. Then you can find the variable_name, and variable_key to your desired variable from the output.eso file.

In your case, the variable_key you provided seems incorrect.

edit flag offensive delete link more

Comments

Thank you so much @Red. You are absolutely right!

Mehrdad Vojdani's avatar Mehrdad Vojdani  ( 2020-12-01 16:55:05 -0600 )edit

@Red does frequency of reporting output:variable matters?

Mehrdad Vojdani's avatar Mehrdad Vojdani  ( 2020-12-02 08:50:37 -0600 )edit
1

@Mehrdad I'm actually not sure about that. But it should be pretty straightforward to find out for yourself.

Red's avatar Red  ( 2020-12-06 10:30:41 -0600 )edit

Just to be clear, output:variable reporting frequency doesn't matter for the plugin.

Mehrdad Vojdani's avatar Mehrdad Vojdani  ( 2020-12-07 03:26:22 -0600 )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

Careers

Question Tools

1 follower

Stats

Asked: 2020-11-28 16:03:55 -0600

Seen: 1,020 times

Last updated: Dec 08 '20