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?
First time here? Check out the Help page!
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?
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
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2022-09-01 23:29:19 -0600
Seen: 154 times
Last updated: Sep 08 '22
@halimgur can you confirm that you're using EnergyPlus for this Python plugin?
Correct. I am using the latest version of EnergyPlus with the Python plugin.