Can EnergyPlus pass a variable from FMU module to PythonPlugin ?

asked 2025-01-14 03:05:47 -0600

updated 2025-01-14 08:43:01 -0600

I am using an external FMU that provides an output variable (using ExternalInterface:FonctionalMockupUnitImport:To:Variable) which I seem to be able to retrieve and use in EnergyManagement:Program but that, for some reasons, I cannot retrieve and use it in PythonPlugin.

As a first attempt to do so, I used the SetShadeControlState python script example provided and slightly adapted it.

        self.handle_zone_Shading_Fraction = self.api.exchange.get_global_handle(
            state, "Bathroom_SetShadingControl")

gives me an error stating that "the plugin tried to retrieve handle for a nonexistent plugin global variable". While if I write :

        self.handle_zone_Shading_Fraction = self.api.exchange.get_variable_handle(
            state, "Bathroom_SetShadingControl")

it warned me with "get_variable_handle() missing 1 required positional argument: 'variable_key'"

Last thing I have created a new EMS:OuputVariable and then passed it to Output:Variable, then I used :

        self.handle_zone_Shading_Fraction = self.api.exchange.get_variable_handle(
            state, "Bathroom_SSC", "EMS")

This gave the message "Index error in getVariableValue; received handle: -1"

I probably misunderstood something in the way a global variable intended to be passed in between FMU, EMS and Python Plugin should be declared, as well as how to call it in the Output:Variables.

Questions are, what Am I missing to handle properly an FMU:Variable in PythonPlugin ? and Do I have to create an EMS program if I only want that variable to be used in PythonPlugin ? It seems that I cannot declare more than 1 variable in the FMUImport:To:Variable, is that right ?

Thank you in advance for the attention paid to my questions.

edit retag flag offensive close merge delete