From 706fc02295935d7b4828ea65437eba42fadf53c4 Mon Sep 17 00:00:00 2001 From: fboundy Date: Wed, 14 Feb 2024 20:09:39 +0000 Subject: [PATCH] Round savings event times and check for value > 0 --- apps/pv_opt/pvpy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/pv_opt/pvpy.py b/apps/pv_opt/pvpy.py index e7fa24a..c2b680b 100644 --- a/apps/pv_opt/pvpy.py +++ b/apps/pv_opt/pvpy.py @@ -257,11 +257,11 @@ def to_df(self, start=None, end=None, **kwargs): if (self.host is not None) and ("unit" in df.columns): events = self.host.saving_events for id in events: - event_start = pd.Timestamp(events[id]["start"]) - event_end = pd.Timestamp(events[id]["end"]) + event_start = pd.Timestamp(events[id]["start"]).floor("30min") + event_end = pd.Timestamp(events[id]["end"]).ceil("30min") event_value = int(events[id]["octopoints_per_kwh"]) / 8 - if event_start <= end or event_end > start: + if event_start <= end or event_end > start and event_value > 0: event_start = max(event_start, start) event_end = min(event_end - pd.Timedelta(30, "minutes"), end) df["unit"].loc[event_start:event_end] += event_value