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

time value in the plugin call

asked 2022-09-01 23:29:19 -0600

halimgur's avatar

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?

edit retag flag offensive 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 -0600 )edit

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

halimgur's avatar halimgur  ( 2022-09-04 17:56:19 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-09-06 03:36:41 -0600

updated 2022-09-06 03:37:37 -0600

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
edit flag offensive delete link more

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: 2022-09-01 23:29:19 -0600

Seen: 151 times

Last updated: Sep 08 '22