Skip to content

Commit

Permalink
Don't enable modal filter unless there are 3 or more data points (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
springfall2008 authored Nov 20, 2023
1 parent 6977437 commit 23ff141
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/predbat/predbat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import appdaemon.plugins.hass.hassapi as hass
import adbase as ad

THIS_VERSION = "v7.13"
THIS_VERSION = "v7.13.1"
TIME_FORMAT = "%Y-%m-%dT%H:%M:%S%z"
TIME_FORMAT_SECONDS = "%Y-%m-%dT%H:%M:%S.%f%z"
TIME_FORMAT_OCTOPUS = "%Y-%m-%d %H:%M:%S%z"
Expand Down Expand Up @@ -2838,7 +2838,7 @@ def previous_days_modal_filter(self, data):
idx += 1

self.log("Historical data totals for days {} are {} - min {}".format(self.days_previous, sum_days, min_sum))
if self.load_filter_modal and total_points >= 2 and (min_sum_day > 0):
if self.load_filter_modal and total_points >= 3 and (min_sum_day > 0):
self.log("Model filter enabled - Discarding day {} as it is the lowest of the {} datapoints".format(min_sum_day, len(self.days_previous)))
del self.days_previous[min_sum_day_idx]
del self.days_previous_weight[min_sum_day_idx]
Expand Down Expand Up @@ -2918,6 +2918,9 @@ def record_status(self, message, debug="", had_errors=False, notify=False, extra
"""
Records status to HA sensor
"""
if not extra:
extra = ""

if notify and self.previous_status != message and self.set_status_notify:
self.call_notify("Predbat status change to: " + message + extra)

Expand Down Expand Up @@ -8483,6 +8486,7 @@ def update_pred(self, scheduled=True):
"""
Update the prediction state, everything is called from here right now
"""
status_extra = ""
self.had_errors = False
self.dashboard_index = []
local_tz = pytz.timezone(self.get_arg("timezone", "Europe/London"))
Expand Down

0 comments on commit 23ff141

Please sign in to comment.