First time here? Check our help page!
1

time value in the plugin call

I would like to access the time of the day from within a plugin function as a python datetime variable or similar. Is this possible?

halimgur's avatar
201
halimgur
asked 2022-09-01 23:29:19 -0500
edit flag offensive 0 remove flag close merge delete

Comments

@halimgur can you confirm that you're using EnergyPlus for this Python plugin?

Aaron Boranian's avatar Aaron Boranian (2022-09-02 09:56:59 -0500) edit

Correct. I am using the latest version of EnergyPlus with the Python plugin.

halimgur's avatar halimgur (2022-09-04 17:56:19 -0500) edit
add a comment see more comments

1 Answer

1

Refer to the Data Transfer API: https://nrel.github.io/EnergyPlus/api...

Potentially of interest are actual_date_time(), actual_time(), current_time(), day_of_month(), month(), year(), minutes()

I have an example here: https://github.com/jmarrec/OpenStudio...

Something along these lines will get you started:

month = api.exchange.month(state)
day = api.exchange.day_of_month(state)
hour = api.exchange.hour(state)
minute = api.exchange.minutes(state)
current_time = api.exchange.current_time(state)
actual_date_time = api.exchange.actual_date_time(state)
actual_time = api.exchange.actual_time(state)

# Year is bogus, seems to be reading the weather file year instead...         
# So harcode it to 2009
# year = api.exchange.year(state)
year = 2009

# E+ uses "end of timestep" conventions, which python does NOT like AT ALL.
timedelta = datetime.timedelta()
if hour >= 24.0:
    hour = 23.0
    timedelta += datetime.timedelta(hours=1)
if minute >= 60.0:
    minute = 59
    timedelta += datetime.timedelta(minutes=1)

dt = datetime.datetime(year=year, month=month, day=day, hour=hour, minute=minute)
dt += timedelta
Julien Marrec's avatar
29.7k
Julien Marrec
answered 2022-09-06 03:36:41 -0500, updated 2022-09-06 03:37:37 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments