PythonPlugIn Variable Handle

asked 2024-01-19 09:54:08 -0500

Lukas_V's avatar

updated 2024-01-20 13:32:34 -0500

Hi, I'm having troubles with the PythonPlugIn when I'm trying to get the handle for Zone Operative Temperature or Zone Mean Temperature. self.api.exchange.get_variable_handle works fine for Zone People Occupant Count but could not get the handle for Zone Operative or Zone Mean Temperature. I have this included in my Output: Variable of EnergyPlus: IDF,Output:Variable,SmallOffice,Zone Operative Temperature,Timestep,; And this is the script for PythonPlugIn:

from pyenergyplus.plugin import EnergyPlusPlugin

class Shades(EnergyPlusPlugin):

  def __init__(self):
    super().__init__()
    self.handles_set = False

  def actuate(self, state, x):
            self.api.exchange.set_actuator_value(state, self.data['schedule_handle'], x)

  def on_begin_zone_timestep_after_init_heat_balance(self, state) -> int:
    if not self.handles_set:

        # Get the handle for the occupant count
        self.data['small_office_handle'] = self.api.exchange.get_variable_handle(
            state, "Zone People Occupant Count", "SmallOffice"
        )
        print("Small Error: Small Office Handle:", self.data['small_office_handle'])
        if self.data['small_office_handle'] == -1:
            self.api.runtime.issue_severe(state, "could not get handle of Zone People Occupant Count")
            return 1

        # Get the handle for the Operative temperature 
        self.data['temperature'] = self.api.exchange.get_variable_handle(
            state, "Zone Operative Temperature","SmallOffice"
        )
        print("Small Error: Glare Index Handle:", self.data['temperature'])
        if self.data['temperature'] == -1:
            self.api.runtime.issue_warning(state, "Temperature handle is -1. ")
            return 1


        self.handles_set = True

    return 0

Thanks

edit retag flag offensive close merge delete